From a30cdba8d03ef89e6cec412aed17f2f0ebd90618 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Tue, 18 Aug 2015 16:57:14 +0200 Subject: [PATCH] Fixed XPath compiler support for not() --- lib/oga/xpath/compiler.rb | 2 +- spec/oga/xpath/compiler/calls/not_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/oga/xpath/compiler.rb b/lib/oga/xpath/compiler.rb index f7657d2..6de912c 100644 --- a/lib/oga/xpath/compiler.rb +++ b/lib/oga/xpath/compiler.rb @@ -927,7 +927,7 @@ module Oga call_arg.assign(arg_ast).followed_by do converted = conversion.to_boolean(call_arg).not - block_given? ? converted.if_false { yield } : converted + block_given? ? converted.if_true { yield } : converted end end diff --git a/spec/oga/xpath/compiler/calls/not_spec.rb b/spec/oga/xpath/compiler/calls/not_spec.rb index b37f8b6..367411b 100644 --- a/spec/oga/xpath/compiler/calls/not_spec.rb +++ b/spec/oga/xpath/compiler/calls/not_spec.rb @@ -28,7 +28,8 @@ describe Oga::XPath::Compiler do describe 'in a predicate' do it 'returns a NodeSet containing all matching nodes ' do - evaluate_xpath(@document, 'root[not(node())]').should == node_set(@root) + evaluate_xpath(@document, 'root[not(comment())]') + .should == node_set(@root) end end end