XPath specs for paths with multiple members.

This commit is contained in:
Yorick Peterse 2015-02-26 22:01:46 +01:00
parent 4ebfc849a4
commit 194d981996
1 changed files with 26 additions and 0 deletions

View File

@ -13,6 +13,23 @@ describe Oga::XPath::Parser do
parse_xpath('A').should == s(:axis, 'child', s(:test, nil, 'A')) parse_xpath('A').should == s(:axis, 'child', s(:test, nil, 'A'))
end end
it 'parses a relative path using two steps' do
parse_xpath('A/B').should == s(
:path,
s(:axis, 'child', s(:test, nil, 'A')),
s(:axis, 'child', s(:test, nil, 'B')),
)
end
it 'parses a relative path using three steps' do
parse_xpath('A/B/C').should == s(
:path,
s(:axis, 'child', s(:test, nil, 'A')),
s(:axis, 'child', s(:test, nil, 'B')),
s(:axis, 'child', s(:test, nil, 'C')),
)
end
it 'parses an expression using two paths' do it 'parses an expression using two paths' do
parse_xpath('/A/B').should == s( parse_xpath('/A/B').should == s(
:absolute_path, :absolute_path,
@ -21,6 +38,15 @@ describe Oga::XPath::Parser do
) )
end end
it 'parses an expression using three paths' do
parse_xpath('/A/B/C').should == s(
:absolute_path,
s(:axis, 'child', s(:test, nil, 'A')),
s(:axis, 'child', s(:test, nil, 'B')),
s(:axis, 'child', s(:test, nil, 'C'))
)
end
it 'parses an absolute path without a node test' do it 'parses an absolute path without a node test' do
parse_xpath('/').should == s(:absolute_path) parse_xpath('/').should == s(:absolute_path)
end end