Skip to content

Commit eb6e6f1

Browse files
bjfisheregon
authored andcommitted
Call Hash#collect from Enumerable#collect only for Hash
1 parent 555a495 commit eb6e6f1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/enumerable/shared/collect.rb

+14
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,19 @@ def register(a, b, c)
8989
end.should raise_error(ArgumentError)
9090
end
9191

92+
it "calls the each method on sub-classes" do
93+
c = Class.new(Hash) do
94+
def each
95+
ScratchPad << 'in each'
96+
super
97+
end
98+
end
99+
h = c.new
100+
h[1] = 'a'
101+
ScratchPad.record []
102+
h.send(@method) { |k,v| v }
103+
ScratchPad.recorded.should == ['in each']
104+
end
105+
92106
it_should_behave_like :enumerable_enumeratorized_with_origin_size
93107
end

0 commit comments

Comments
 (0)