diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-11-30 21:26:52 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-11-30 21:26:52 +0100 |
commit | 1243255c3a36433041012b6107a5ac48658a0895 (patch) | |
tree | 04440f84b48999ff08d4a2a16d066d0ad731400e /spec/ruby/core/array/drop_spec.rb | |
parent | ab8345271eb87ff155d8bd5f22f53a4cf2902c26 (diff) |
Update to ruby/spec@4eec3dc
Diffstat (limited to 'spec/ruby/core/array/drop_spec.rb')
-rw-r--r-- | spec/ruby/core/array/drop_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/ruby/core/array/drop_spec.rb b/spec/ruby/core/array/drop_spec.rb index 89b8534af4..84ea86b04c 100644 --- a/spec/ruby/core/array/drop_spec.rb +++ b/spec/ruby/core/array/drop_spec.rb @@ -30,4 +30,22 @@ describe "Array#drop" do ary.shift ary.drop(1).should == [2] end + + it "tries to convert the passed argument to an Integer using #to_int" do + obj = mock("to_int") + obj.should_receive(:to_int).and_return(2) + + [1, 2, 3].drop(obj).should == [3] + end + + it "raises a TypeError when the passed argument can't be coerced to Integer" do + -> { [1, 2].drop("cat") }.should raise_error(TypeError) + end + + it "raises a TypeError when the passed argument isn't an integer and #to_int returns non-Integer" do + obj = mock("to_int") + obj.should_receive(:to_int).and_return("cat") + + -> { [1, 2].drop(obj) }.should raise_error(TypeError) + end end |