Specs for nested predicates & self axis.
This commit is contained in:
parent
e858b54c58
commit
3196050978
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
describe Oga::XPath::Evaluator do
|
||||
context 'self axis' do
|
||||
before do
|
||||
@document = parse('<a><b>foo</b><b>bar</b></a>')
|
||||
@document = parse('<a><b>foo</b><b>bar<c>test</c></b></a>')
|
||||
@evaluator = described_class.new(@document)
|
||||
end
|
||||
|
||||
|
@ -41,7 +41,7 @@ describe Oga::XPath::Evaluator do
|
|||
|
||||
context 'matching nodes inside predicates' do
|
||||
before do
|
||||
@set = @evaluator.evaluate('a/b[.="foo"]')
|
||||
@set = @evaluator.evaluate('a/b[. = "foo"]')
|
||||
end
|
||||
|
||||
it_behaves_like :node_set, :length => 1
|
||||
|
@ -50,5 +50,29 @@ describe Oga::XPath::Evaluator do
|
|||
@set[0].should == @document.children[0].children[0]
|
||||
end
|
||||
end
|
||||
|
||||
context 'using self inside a path inside a predicate' do
|
||||
before do
|
||||
@set = @evaluator.evaluate('a/b[c/. = "test"]')
|
||||
end
|
||||
|
||||
it_behaves_like :node_set, :length => 1
|
||||
|
||||
example 'return the second <b> node' do
|
||||
@set[0].should == @document.children[0].children[1]
|
||||
end
|
||||
end
|
||||
|
||||
context 'using self inside a nested predicate' do
|
||||
before do
|
||||
@set = @evaluator.evaluate('a/b[c[. = "test"]]')
|
||||
end
|
||||
|
||||
it_behaves_like :node_set, :length => 1
|
||||
|
||||
example 'return the second <b> node' do
|
||||
@set[0].should == @document.children[0].children[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue