diff options
Diffstat (limited to 'spec/ruby/core/array/sample_spec.rb')
| -rw-r--r-- | spec/ruby/core/array/sample_spec.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/ruby/core/array/sample_spec.rb b/spec/ruby/core/array/sample_spec.rb index 6ef78594f0..d4e945152d 100644 --- a/spec/ruby/core/array/sample_spec.rb +++ b/spec/ruby/core/array/sample_spec.rb @@ -114,6 +114,13 @@ describe "Array#sample" do -> { [1, 2].sample(random: random) }.should raise_error(RangeError) end + + it "raises a RangeError if the value is greater than the Array size" do + random = mock("array_sample_random") + random.should_receive(:rand).and_return(3) + + -> { [1, 2].sample(random: random) }.should raise_error(RangeError) + end end end |
