Allow Document#each_node to skip child nodes.
Child nodes can be skipped by throwing :skip_children.
This commit is contained in:
1 parent
ef1ad5406a
commit
57fcbbd0fc
2 files changed
+34
-5
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user