From 8e60c69def03edf22164eed49b59d9df017d16a3 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Tue, 18 Aug 2015 16:52:07 +0200 Subject: [PATCH] Added spec for not() in a predicate --- spec/oga/xpath/compiler/calls/not_spec.rb | 34 +++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/spec/oga/xpath/compiler/calls/not_spec.rb b/spec/oga/xpath/compiler/calls/not_spec.rb index a391a4a..b37f8b6 100644 --- a/spec/oga/xpath/compiler/calls/not_spec.rb +++ b/spec/oga/xpath/compiler/calls/not_spec.rb @@ -4,22 +4,32 @@ describe Oga::XPath::Compiler do describe 'not() function' do before do @document = parse('foo') + + @root = @document.children[0] end - it 'returns false when the argument is a non-zero integer' do - evaluate_xpath(@document, 'not(10)').should == false + describe 'at the top-level' do + it 'returns false when the argument is a non-zero integer' do + evaluate_xpath(@document, 'not(10)').should == false + end + + it 'returns true when the argument is a zero integer' do + evaluate_xpath(@document, 'not(0)').should == true + end + + it 'returns false when the argument is a non-empty node set' do + evaluate_xpath(@document, 'not(root)').should == false + end + + it 'returns itrue when the argument is an empty node set' do + evaluate_xpath(@document, 'not(foo)').should == true + end end - it 'returns true when the argument is a zero integer' do - evaluate_xpath(@document, 'not(0)').should == true - end - - it 'returns false when the argument is a non-empty node set' do - evaluate_xpath(@document, 'not(root)').should == false - end - - it 'returns itrue when the argument is an empty node set' do - evaluate_xpath(@document, 'not(foo)').should == true + describe 'in a predicate' do + it 'returns a NodeSet containing all matching nodes ' do + evaluate_xpath(@document, 'root[not(node())]').should == node_set(@root) + end end end end