diff options
author | Benoit Daloze <[email protected]> | 2023-08-02 18:53:03 +0200 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2023-08-02 18:53:03 +0200 |
commit | dc54574adefe798702cc93457655da40f4939669 (patch) | |
tree | bd7ae5d6afc9bc00f6cb7813774543bc6f12b6e2 /spec/ruby/optional/capi/exception_spec.rb | |
parent | e20f1e443f6d0a4d377ef237fffc1f4c6e27c9e1 (diff) |
Update to ruby/spec@9e278f5
Diffstat (limited to 'spec/ruby/optional/capi/exception_spec.rb')
-rw-r--r-- | spec/ruby/optional/capi/exception_spec.rb | 34 |
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"]) |