summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/exception_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/optional/capi/exception_spec.rb')
-rw-r--r--spec/ruby/optional/capi/exception_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/exception_spec.rb b/spec/ruby/optional/capi/exception_spec.rb
index b0a8a2860e..5bb60608b2 100644
--- a/spec/ruby/optional/capi/exception_spec.rb
+++ b/spec/ruby/optional/capi/exception_spec.rb
@@ -100,6 +100,40 @@ describe "C-API Exception function" do
end
end
+ describe "rb_syserr_new" do
+ it "returns system error with default message when passed message is NULL" do
+ exception = @s.rb_syserr_new(Errno::ENOENT::Errno, nil)
+ exception.class.should == Errno::ENOENT
+ exception.message.should include("No such file or directory")
+ exception.should.is_a?(SystemCallError)
+ end
+
+ it "returns system error with custom message" do
+ exception = @s.rb_syserr_new(Errno::ENOENT::Errno, "custom message")
+
+ exception.message.should include("custom message")
+ exception.class.should == Errno::ENOENT
+ exception.should.is_a?(SystemCallError)
+ end
+ end
+
+ describe "rb_syserr_new_str" do
+ it "returns system error with default message when passed message is nil" do
+ exception = @s.rb_syserr_new_str(Errno::ENOENT::Errno, nil)
+
+ exception.message.should include("No such file or directory")
+ exception.class.should == Errno::ENOENT
+ exception.should.is_a?(SystemCallError)
+ end
+
+ it "returns system error with custom message" do
+ exception = @s.rb_syserr_new_str(Errno::ENOENT::Errno, "custom message")
+ exception.message.should include("custom message")
+ exception.class.should == Errno::ENOENT
+ exception.should.is_a?(SystemCallError)
+ end
+ end
+
describe "rb_make_exception" do
it "returns a RuntimeError when given a String argument" do
e = @s.rb_make_exception(["Message"])