Skip to content

Commit 8b010d5

Browse files
committed
Fix SystemCallError.new called with nil message value
1 parent a097d6f commit 8b010d5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

core/exception/system_call_error_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ def initialize
5353
e.should be_an_instance_of(@example_errno_class)
5454
end
5555

56+
it "sets an error message corresponding to an appropriate Errno class" do
57+
e = SystemCallError.new(@example_errno)
58+
e.message.should == 'Invalid argument'
59+
end
60+
5661
it "accepts an optional custom message preceding the errno" do
5762
exc = SystemCallError.new("custom message", @example_errno)
5863
exc.should be_an_instance_of(@example_errno_class)
@@ -81,6 +86,17 @@ def initialize
8186
SystemCallError.new('foo', 2.9).should == SystemCallError.new('foo', 2)
8287
end
8388

89+
it "treats nil errno as unknown error value" do
90+
SystemCallError.new(nil).should be_an_instance_of(SystemCallError)
91+
end
92+
93+
it "treats nil custom message as if it is not passed at all" do
94+
exc = SystemCallError.new(nil, @example_errno)
95+
exc.should be_an_instance_of(@example_errno_class)
96+
exc.errno.should == @example_errno
97+
exc.message.should == 'Invalid argument'
98+
end
99+
84100
it "converts to Integer if errno is a Complex convertible to Integer" do
85101
SystemCallError.new('foo', Complex(2.9, 0)).should == SystemCallError.new('foo', 2)
86102
end

0 commit comments

Comments
 (0)