From 30bbd2378e3772c41ed7d5a07c7d540becbc934c Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 14 Jul 2014 00:11:03 +0200 Subject: [PATCH] Basic specs for the "ancestor" axis. --- spec/oga/xpath/evaluator/axes_spec.rb | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 spec/oga/xpath/evaluator/axes_spec.rb diff --git a/spec/oga/xpath/evaluator/axes_spec.rb b/spec/oga/xpath/evaluator/axes_spec.rb new file mode 100644 index 0000000..8799462 --- /dev/null +++ b/spec/oga/xpath/evaluator/axes_spec.rb @@ -0,0 +1,50 @@ +require 'spec_helper' + +describe Oga::XPath::Evaluator do + before do + @document = parse('') + end + + context 'ancestor axis' do + before do + c_node = @document.children[0].children[0].children[0] + @evaluator = described_class.new(c_node) + end + + context 'direct ancestors' do + before do + @set = @evaluator.evaluate('ancestor::b') + end + + example 'return a NodeSet instance' do + @set.is_a?(Oga::XML::NodeSet).should == true + end + + example 'return the right amount of rows' do + @set.length.should == 1 + end + + example 'return the ancestor' do + @set[0].name.should == 'b' + end + end + + context 'higher ancestors' do + before do + @set = @evaluator.evaluate('ancestor::a') + end + + example 'return a NodeSet instance' do + @set.is_a?(Oga::XML::NodeSet).should == true + end + + example 'return the right amount of rows' do + @set.length.should == 1 + end + + example 'return the ancestor' do + @set[0].name.should == 'a' + end + end + end +end