diff options
author | Benoit Daloze <eregontp@gmail.com> | 2023-04-25 17:04:25 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2023-04-25 17:09:53 +0200 |
commit | d562663e4098801c1d7fa7c64a335ea71231a598 (patch) | |
tree | 5b2ab2c9fbb86b4223263485fc5a3224562ae78d /spec/ruby/core/integer/try_convert_spec.rb | |
parent | d3da01cd110ca99dd0249ee9af92e12cf845998c (diff) | |
download | ruby-d562663e4098801c1d7fa7c64a335ea71231a598.tar.gz |
Update to ruby/spec@7f69c86
Diffstat (limited to 'spec/ruby/core/integer/try_convert_spec.rb')
-rw-r--r-- | spec/ruby/core/integer/try_convert_spec.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/spec/ruby/core/integer/try_convert_spec.rb b/spec/ruby/core/integer/try_convert_spec.rb index 45c66eec79..4bc7d3851a 100644 --- a/spec/ruby/core/integer/try_convert_spec.rb +++ b/spec/ruby/core/integer/try_convert_spec.rb @@ -28,7 +28,17 @@ ruby_version_is "3.1" do it "sends #to_int to the argument and raises TypeError if it's not a kind of Integer" do obj = mock("to_int") obj.should_receive(:to_int).and_return(Object.new) - -> { Integer.try_convert obj }.should raise_error(TypeError) + -> { + Integer.try_convert obj + }.should raise_error(TypeError, "can't convert MockObject to Integer (MockObject#to_int gives Object)") + end + + it "responds with a different error message when it raises a TypeError, depending on the type of the non-Integer object :to_int returns" do + obj = mock("to_int") + obj.should_receive(:to_int).and_return("A String") + -> { + Integer.try_convert obj + }.should raise_error(TypeError, "can't convert MockObject to Integer (MockObject#to_int gives String)") end it "does not rescue exceptions raised by #to_int" do |