From aef3e0f27e203df9c6fd7e78a8ac14fa359261c5 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 11 Aug 2014 09:27:50 +0200 Subject: [PATCH] Evaluator specs for the attribute axis short form. --- .../oga/xpath/evaluator/axes/attribute_spec.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/spec/oga/xpath/evaluator/axes/attribute_spec.rb b/spec/oga/xpath/evaluator/axes/attribute_spec.rb index c8f366f..5ca78d6 100644 --- a/spec/oga/xpath/evaluator/axes/attribute_spec.rb +++ b/spec/oga/xpath/evaluator/axes/attribute_spec.rb @@ -7,7 +7,7 @@ describe Oga::XPath::Evaluator do @evaluator = described_class.new(document.children[0]) end - context 'element attributes' do + context 'matching existing attributes' do before do @set = @evaluator.evaluate('attribute::foo') end @@ -18,17 +18,29 @@ describe Oga::XPath::Evaluator do @set[0].is_a?(Oga::XML::Attribute).should == true end - example 'return the correct attribute' do + example 'return the "foo" attribute' do @set[0].name.should == 'foo' end end - context 'non existing attributes' do + context 'matching non existing attributes' do before do @set = @evaluator.evaluate('attribute::bar') end it_behaves_like :empty_node_set end + + context 'matching attributes using the short form' do + before do + @set = @evaluator.evaluate('@foo') + end + + it_behaves_like :node_set, :length => 1 + + example 'return the "foo" attribute' do + @set[0].name.should == 'foo' + end + end end end