Specs for nested predicates & self axis.

This commit is contained in:
Yorick Peterse 2014-09-03 20:55:55 +02:00
parent e858b54c58
commit 3196050978
1 changed files with 26 additions and 2 deletions

View File

@ -3,7 +3,7 @@ require 'spec_helper'
describe Oga::XPath::Evaluator do describe Oga::XPath::Evaluator do
context 'self axis' do context 'self axis' do
before 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) @evaluator = described_class.new(@document)
end end
@ -50,5 +50,29 @@ describe Oga::XPath::Evaluator do
@set[0].should == @document.children[0].children[0] @set[0].should == @document.children[0].children[0]
end end
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
end end