From 194d981996ac6312a32f107469d3890b00fdbc02 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 26 Feb 2015 22:01:46 +0100 Subject: [PATCH] XPath specs for paths with multiple members. --- spec/oga/xpath/parser/paths_spec.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/oga/xpath/parser/paths_spec.rb b/spec/oga/xpath/parser/paths_spec.rb index 501843e..12a79f4 100644 --- a/spec/oga/xpath/parser/paths_spec.rb +++ b/spec/oga/xpath/parser/paths_spec.rb @@ -13,6 +13,23 @@ describe Oga::XPath::Parser do parse_xpath('A').should == s(:axis, 'child', s(:test, nil, 'A')) 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 parse_xpath('/A/B').should == s( :absolute_path, @@ -21,6 +38,15 @@ describe Oga::XPath::Parser do ) 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 parse_xpath('/').should == s(:absolute_path) end