We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 96a4574 commit 75517e0Copy full SHA for 75517e0
lib/nokogiri/xml/node_set.rb
@@ -198,6 +198,8 @@ def remove_attr name
198
###
199
# Iterate over each node, yielding to +block+
200
def each(&block)
201
+ return to_enum unless block_given?
202
+
203
0.upto(length - 1) do |x|
204
yield self[x]
205
end
test/xml/test_node_set.rb
@@ -672,6 +672,11 @@ def test_include_on_empty_node_set
672
assert ! empty_set.include?(employee)
673
674
675
+ def test_each
676
+ employees = @xml.search("//employee")
677
+ assert_instance_of Enumerator, employees.each
678
+ end
679
680
def test_children
681
employees = @xml.search("//employee")
682
count = 0
0 commit comments