diff --git a/spec/oga/xpath/evaluator/axes/descendant_or_self_spec.rb b/spec/oga/xpath/evaluator/axes/descendant_or_self_spec.rb index 081c988..5b9f8ca 100644 --- a/spec/oga/xpath/evaluator/axes/descendant_or_self_spec.rb +++ b/spec/oga/xpath/evaluator/axes/descendant_or_self_spec.rb @@ -40,6 +40,32 @@ describe Oga::XPath::Evaluator do end end + context 'chained descendants' do + before do + @set = @evaluator.evaluate( + 'descendant-or-self::a/descendant-or-self::*' + ) + end + + it_behaves_like :node_set, :length => 4 + + example 'return the node' do + @set[0].should == @first_a + end + + example 'return the first node' do + @set[1].should == @first_b + end + + example 'return the second node' do + @set[2].should == @second_b + end + + example 'return the node' do + @set[3].should == @first_c + end + end + context 'nested descendants with a matching predicate' do before do @set = @evaluator.evaluate('descendant-or-self::c[@class="x"]') @@ -139,5 +165,37 @@ describe Oga::XPath::Evaluator do @set[0].should == @first_c end end + + context 'descendants of descendants usign the short form' do + before do + @set = @evaluator.evaluate('//a//*') + end + + it_behaves_like :node_set, :length => 3 + + example 'return the first node' do + @set[0].should == @first_b + end + + example 'return the second node' do + @set[1].should == @second_b + end + + example 'return the node' do + @set[2].should == @first_c + end + end + + context 'children of descendants using the short form' do + before do + @set = @evaluator.evaluate('//a/b') + end + + it_behaves_like :node_set, :length => 1 + + example 'return the first node' do + @set[0].should == @first_b + end + end end end