Specs for the ancestor-or-self axis.

This commit is contained in:
Yorick Peterse 2014-07-15 09:37:47 +02:00
parent 9a8f53bb49
commit e0544959ee
1 changed files with 43 additions and 1 deletions

View File

@ -30,9 +30,51 @@ describe Oga::XPath::Evaluator do
it_behaves_like :node_set, :length => 1
example 'return the <b> ancestor' do
example 'return the <a> 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 <b> 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 <a> 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 <c> node' do
@set[0].name.should == 'c'
end
end
end
end