Match node types in node_matches?

The method XPath::Evaluator#node_matches? now has a special case to handle
"type-test" nodes. This in turn fixes a bunch of failing tests such as those for
the XPath query "parent::node()".
This commit is contained in:
Yorick Peterse committed 2014-08-14 22:54:19 +02:00
1 parent a437d67573
commit d34e4697de
2 files changed
+43 -2

No files matched your search

+19
View File
@@ -77,6 +77,25 @@ describe Oga::XPath::Evaluator do
example 'return true if a node with a namespace is matched using a wildcard' do
@evaluator.node_matches?(@name_ns_node, s(:test, nil, '*')).should == true
end
example 'return true if the node type matches' do
@evaluator.node_matches?(@name_node, s(:type_test, 'node')).should == true
end
end
context '#type_matches?' do
before do
@element = Oga::XML::Element.new(:name => 'a')
@ns = Oga::XML::Namespace.new(:name => 'a')
end
example 'return true if the type matches' do
@evaluator.type_matches?(@element, s(:type_test, 'node')).should == true
end
example 'return false if the type does not match' do
@evaluator.type_matches?(@ns, s(:type_test, 'node')).should == false
end
end
context '#has_parent?' do