diff --git a/spec/oga/xpath/evaluator/axes_spec.rb b/spec/oga/xpath/evaluator/axes_spec.rb index 5b0f2d1..015fadb 100644 --- a/spec/oga/xpath/evaluator/axes_spec.rb +++ b/spec/oga/xpath/evaluator/axes_spec.rb @@ -30,9 +30,51 @@ describe Oga::XPath::Evaluator do it_behaves_like :node_set, :length => 1 - example 'return the ancestor' do + example 'return the ancestor' do @set[0].name.should == 'a' end end end + + context 'ancestor-or-self axis' do + before do + @evaluator = described_class.new(@c_node) + end + + context 'direct ancestors' do + before do + @set = @evaluator.evaluate('ancestor-or-self::b') + end + + it_behaves_like :node_set, :length => 1 + + example 'return the ancestor' do + @set[0].name.should == 'b' + end + end + + context 'higher ancestors' do + before do + @set = @evaluator.evaluate('ancestor-or-self::a') + end + + it_behaves_like :node_set, :length => 1 + + example 'return the ancestor' do + @set[0].name.should == 'a' + end + end + + context 'missing ancestors' do + before do + @set = @evaluator.evaluate('ancestor-or-self::c') + end + + it_behaves_like :node_set, :length => 1 + + example 'return the node' do + @set[0].name.should == 'c' + end + end + end end