Specs for the ancestor-or-self axis.
This commit is contained in:
parent
9a8f53bb49
commit
e0544959ee
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue