Added various predicate specs for XPath axes.

This commit is contained in:
Yorick Peterse 2014-11-12 09:40:22 +01:00
parent c15604a86f
commit 24350fa457
4 changed files with 17 additions and 0 deletions

View File

@ -22,6 +22,10 @@ describe Oga::XPath::Evaluator do
evaluate_xpath(@c1, 'ancestor-or-self::c').should == node_set(@c1)
end
example 'return a node set containing the first ancestor' do
evaluate_xpath(@c1, 'ancestor-or-self::*[1]').should == node_set(@c1)
end
example 'return an empty node set for non existing ancestors' do
evaluate_xpath(@c1, 'ancestor-or-self::foo').should == node_set
end

View File

@ -18,6 +18,10 @@ describe Oga::XPath::Evaluator do
evaluate_xpath(@c1, 'ancestor::a').should == node_set(@a1)
end
example 'return a node set containing the first ancestor' do
evaluate_xpath(@c1, 'ancestor::*[1]').should == node_set(@b1)
end
example 'return an empty node set for non existing ancestors' do
evaluate_xpath(@c1, 'ancestor::c').should == node_set
end

View File

@ -45,6 +45,11 @@ describe Oga::XPath::Evaluator do
.should == node_set(@c1)
end
example 'return a node set containing the first descendant' do
evaluate_xpath(@document, 'descendant-or-self::b[1]')
.should == node_set(@b1)
end
example 'return an empty node set for a non existing descendant' do
evaluate_xpath(@document, 'descendant-or-self::foobar').should == node_set
end

View File

@ -22,6 +22,10 @@ describe Oga::XPath::Evaluator do
evaluate_xpath(@document, 'a/descendant::a').should == node_set(@a2)
end
example 'return a node set containing the first descendant' do
evaluate_xpath(@document, 'descendant::a[1]').should == node_set(@a1)
end
example 'return an empty node set for non existing descendants' do
evaluate_xpath(@document, 'a/b/c/descendant::c').should == node_set
end