-
-
Notifications
You must be signed in to change notification settings - Fork 938
Expand file tree
/
Copy patharray_spec.rb
More file actions
25 lines (20 loc) · 786 Bytes
/
array_spec.rb
File metadata and controls
25 lines (20 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# JRuby adds optimized versions of #any?, #all? and #find to Array which only delegate to Enumerable if Array#each has
# been overridden. This spec ensures we don't regress on any of the customizations.
class ArrayExtender < Array
def each
yield "eachElem"
end
end
array_extender = ArrayExtender.new
array_extender << "arrayElem"
describe "Array" do
it "uses the #each method's override for #any? if one exists" do
array_extender.any? { |elem| expect(elem).to eq("eachElem") }
end
it "uses the #each method's override for #all? if one exists" do
array_extender.all? { |elem| expect(elem).to eq("eachElem") }
end
it "uses the #each method's override for #find? if one exists" do
array_extender.find { |elem| expect(elem).to eq("eachElem") }
end
end