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:
1 parent
398aaf68bc
commit
b06eadc812
4 files changed
+19
-1
No files matched your search
@@ -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')
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user