Allow Document#each_node to skip child nodes.

Child nodes can be skipped by throwing :skip_children.
This commit is contained in:
Yorick Peterse committed 2014-08-04 10:00:32 +02:00
1 parent ef1ad5406a
commit 57fcbbd0fc
2 files changed
+34 -5

No files matched your search

+16
View File
@@ -53,6 +53,22 @@ describe Oga::XML::Document do
names.should == %w{books book1 title1 Foo book2 title2 Bar}
end
example 'skip child nodes when skip_children is thrown' do
names = []
@document.each_node do |node|
if node.is_a?(Oga::XML::Element)
if node.name == 'book1'
throw :skip_children
else
names << node.name
end
end
end
names.should == %w{books book2 title2}
end
end
context '#to_xml' do