Basic support for the preceding-sibling xpath axis
This commit is contained in:
1 parent
e34a1ed481
commit
8a9b26fa73
2 files changed
+60
No files matched your search
@@ -0,0 +1,33 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Oga::XPath::Evaluator do
|
||||
context 'preceding-sibling axis' do
|
||||
before do
|
||||
@document = parse(<<-EOF.strip.gsub(/\s+/m, ''))
|
||||
<root>
|
||||
<foo>
|
||||
</foo>
|
||||
<bar>
|
||||
<foo></foo>
|
||||
<baz></baz>
|
||||
</bar>
|
||||
</root>
|
||||
EOF
|
||||
|
||||
@second_foo = @document.children[0].children[1].children[0]
|
||||
@evaluator = described_class.new(@document)
|
||||
end
|
||||
|
||||
context 'matching nodes in the current context' do
|
||||
before do
|
||||
@set = @evaluator.evaluate('root/bar/baz/preceding-sibling::foo')
|
||||
end
|
||||
|
||||
it_behaves_like :node_set, :length => 1
|
||||
|
||||
example 'return the second <foo> node' do
|
||||
@set[0].should == @second_foo
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user