XPath support for absolute paths without tests.

This allows Oga to parse and evaluate the XPath expression "/". This expression
can be used to select just the root node/document.

This fixes #35.
This commit is contained in:
Yorick Peterse committed 2014-09-15 17:06:58 +02:00
1 parent 398aaf68bc
commit b06eadc812
4 files changed
+19 -1

No files matched your search

+12
View File
@@ -30,6 +30,18 @@ describe Oga::XPath::Evaluator do
end
end
context 'absolute paths without node tests' do
before do
@set = described_class.new(@document).evaluate('/')
end
it_behaves_like :node_set, :length => 1
example 'return the root document' do
@set[0].is_a?(Oga::XML::Document).should == true
end
end
context 'invalid absolute paths' do
before do
@set = described_class.new(@document).evaluate('/x/a')
+4
View File
@@ -20,5 +20,9 @@ describe Oga::XPath::Parser do
s(:axis, 'child', s(:test, nil, 'B'))
)
end
example 'parse an absolute path without a node test' do
parse_xpath('/').should == s(:absolute_path)
end
end
end