diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-01-26 18:34:18 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-01-26 19:45:58 +0900 |
commit | d4e1d4e94e866d498ead1f370236df216917a6c7 (patch) | |
tree | a489f1382ade60a75ee704e063384eb8069ef012 /spec/ruby/core | |
parent | 29eb1b16028928139dcaa236beb6d351c85f434c (diff) | |
download | ruby-d4e1d4e94e866d498ead1f370236df216917a6c7.tar.gz |
Moved Array#sample to rbinc
Diffstat (limited to 'spec/ruby/core')
-rw-r--r-- | spec/ruby/core/array/sample_spec.rb | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/spec/ruby/core/array/sample_spec.rb b/spec/ruby/core/array/sample_spec.rb index 44be91ba18..87f81999f4 100644 --- a/spec/ruby/core/array/sample_spec.rb +++ b/spec/ruby/core/array/sample_spec.rb @@ -65,21 +65,24 @@ describe "Array#sample" do end describe "with options" do - it "calls #to_hash to convert the passed Object" do - obj = mock("array_sample") - obj.should_receive(:to_hash).and_return({}) - obj.should_not_receive(:to_int) - - [1, 2].sample(obj).should be_an_instance_of(Fixnum) - end + ruby_version_is ""..."2.8" do + # keyword argument since 2.8 + it "calls #to_hash to convert the passed Object" do + obj = mock("array_sample") + obj.should_receive(:to_hash).and_return({}) + obj.should_not_receive(:to_int) + + [1, 2].sample(obj).should be_an_instance_of(Fixnum) + end - it "calls #to_int on the first argument and #to_hash on the second when passed Objects" do - count = mock("array_sample_count") - count.should_receive(:to_int).and_return(2) - options = mock("array_sample_options") - options.should_receive(:to_hash).and_return({}) + it "calls #to_int on the first argument and #to_hash on the second when passed Objects" do + count = mock("array_sample_count") + count.should_receive(:to_int).and_return(2) + options = mock("array_sample_options") + options.should_receive(:to_hash).and_return({}) - [1, 2].sample(count, options).size.should == 2 + [1, 2].sample(count, options).size.should == 2 + end end it "calls #rand on the Object passed by the :random key in the arguments Hash" do |