Rewrote XPath evaluator predicates spec.
This commit is contained in:
parent
3893e56ca8
commit
ceed3a6046
|
@ -3,20 +3,18 @@ require 'spec_helper'
|
||||||
describe Oga::XPath::Evaluator do
|
describe Oga::XPath::Evaluator do
|
||||||
context 'predicates' do
|
context 'predicates' do
|
||||||
before do
|
before do
|
||||||
@document = parse('<root><a></a><b>10</b><b>20</b></root>')
|
@document = parse('<root><b>10</b><b>20</b></root>')
|
||||||
@evaluator = described_class.new(@document)
|
|
||||||
|
@b1 = @document.children[0].children[0]
|
||||||
|
@b2 = @document.children[0].children[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'using predicate indexes' do
|
example 'evaluate a predicate that returns the first <b> node' do
|
||||||
before do
|
evaluate_xpath(@document, 'root/b[1]').should == node_set(@b1)
|
||||||
@set = @evaluator.evaluate('root/b[2]')
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it_behaves_like :node_set, :length => 1
|
example 'evaluate a predicate that returns the second <b> node' do
|
||||||
|
evaluate_xpath(@document, 'root/b[2]').should == node_set(@b2)
|
||||||
example 'return the second <b> node' do
|
|
||||||
@set[0].should == @document.children[0].children[-1]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue