From 24350fa4572f7f7bbf47a0e964030b23776c8b54 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 12 Nov 2014 09:40:22 +0100 Subject: [PATCH] Added various predicate specs for XPath axes. --- spec/oga/xpath/evaluator/axes/ancestor_or_self_spec.rb | 4 ++++ spec/oga/xpath/evaluator/axes/ancestor_spec.rb | 4 ++++ spec/oga/xpath/evaluator/axes/descendant_or_self_spec.rb | 5 +++++ spec/oga/xpath/evaluator/axes/descendant_spec.rb | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/spec/oga/xpath/evaluator/axes/ancestor_or_self_spec.rb b/spec/oga/xpath/evaluator/axes/ancestor_or_self_spec.rb index e31f65f..799c538 100644 --- a/spec/oga/xpath/evaluator/axes/ancestor_or_self_spec.rb +++ b/spec/oga/xpath/evaluator/axes/ancestor_or_self_spec.rb @@ -22,6 +22,10 @@ describe Oga::XPath::Evaluator do evaluate_xpath(@c1, 'ancestor-or-self::c').should == node_set(@c1) end + example 'return a node set containing the first ancestor' do + evaluate_xpath(@c1, 'ancestor-or-self::*[1]').should == node_set(@c1) + end + example 'return an empty node set for non existing ancestors' do evaluate_xpath(@c1, 'ancestor-or-self::foo').should == node_set end diff --git a/spec/oga/xpath/evaluator/axes/ancestor_spec.rb b/spec/oga/xpath/evaluator/axes/ancestor_spec.rb index 67ee4a5..221155a 100644 --- a/spec/oga/xpath/evaluator/axes/ancestor_spec.rb +++ b/spec/oga/xpath/evaluator/axes/ancestor_spec.rb @@ -18,6 +18,10 @@ describe Oga::XPath::Evaluator do evaluate_xpath(@c1, 'ancestor::a').should == node_set(@a1) end + example 'return a node set containing the first ancestor' do + evaluate_xpath(@c1, 'ancestor::*[1]').should == node_set(@b1) + end + example 'return an empty node set for non existing ancestors' do evaluate_xpath(@c1, 'ancestor::c').should == node_set end diff --git a/spec/oga/xpath/evaluator/axes/descendant_or_self_spec.rb b/spec/oga/xpath/evaluator/axes/descendant_or_self_spec.rb index 909fa06..75ee621 100644 --- a/spec/oga/xpath/evaluator/axes/descendant_or_self_spec.rb +++ b/spec/oga/xpath/evaluator/axes/descendant_or_self_spec.rb @@ -45,6 +45,11 @@ describe Oga::XPath::Evaluator do .should == node_set(@c1) end + example 'return a node set containing the first descendant' do + evaluate_xpath(@document, 'descendant-or-self::b[1]') + .should == node_set(@b1) + end + example 'return an empty node set for a non existing descendant' do evaluate_xpath(@document, 'descendant-or-self::foobar').should == node_set end diff --git a/spec/oga/xpath/evaluator/axes/descendant_spec.rb b/spec/oga/xpath/evaluator/axes/descendant_spec.rb index 5de5330..637fcc1 100644 --- a/spec/oga/xpath/evaluator/axes/descendant_spec.rb +++ b/spec/oga/xpath/evaluator/axes/descendant_spec.rb @@ -22,6 +22,10 @@ describe Oga::XPath::Evaluator do evaluate_xpath(@document, 'a/descendant::a').should == node_set(@a2) end + example 'return a node set containing the first descendant' do + evaluate_xpath(@document, 'descendant::a[1]').should == node_set(@a1) + end + example 'return an empty node set for non existing descendants' do evaluate_xpath(@document, 'a/b/c/descendant::c').should == node_set end