1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2022-03-28 17:47:04 +02:00
parent ae650f0372
commit 8db4f25bf4
41 changed files with 821 additions and 56 deletions

View file

@ -19,10 +19,18 @@ describe "Array#sample" do
[].sample.should be_nil
end
it "returns nil for an empty array when called without n and a Random is given" do
[].sample(random: Random.new(42)).should be_nil
end
it "returns a single value when not passed a count" do
[4].sample.should equal(4)
end
it "returns a single value when not passed a count and a Random is given" do
[4].sample(random: Random.new(42)).should equal(4)
end
it "returns an empty Array when passed zero" do
[4].sample(0).should == []
end