Skip to content

Commit

Permalink
Update Array#rassoc spec to reflect ruby master behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
bolshakov committed Nov 28, 2023
1 parent c3206f6 commit 73bdc21
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions core/array/rassoc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ def o.==(other); other == 'foobar'; end
[[1, :foobar, o], [2, o, 1], [3, mock('foo')]].rassoc(key).should == [2, o, 1]
end

it "does not call to_ary on non-array elements" do
s1 = [1, 2]
s2 = ArraySpecs::ArrayConvertible.new(2, 3)
a = [s1, s2]

s1.should_not_receive(:to_ary)
a.rassoc(2).should equal(s1)

s2.should_not_receive(:to_ary)
a.rassoc(3).should equal(nil)
ruby_version_is "3.3" do
it "calls to_ary on non-array elements" do
s1 = [1, 2]
s2 = ArraySpecs::ArrayConvertible.new(2, 3)
a = [s1, s2]

s1.should_not_receive(:to_ary)
a.rassoc(2).should equal(s1)

a.rassoc(3).should == [2, 3]
s2.called.should equal(:to_ary)
end
end
end

0 comments on commit 73bdc21

Please sign in to comment.