Permalink
Browse files

Fix have_xpath not matching negative expectation in the block.

[#182 state:resolved]
  • Loading branch information...
cavalle authored and djanowski committed Apr 13, 2009
1 parent 107bdf7 commit 43b19eeafa44311b01d4755c43a74972dea07302
Showing with 10 additions and 2 deletions.
  1. +4 −2 lib/webrat/core/matchers/have_xpath.rb
  2. +6 −0 spec/public/matchers/have_xpath_spec.rb
@@ -14,10 +14,12 @@ def matches?(stringlike, &block)
@block ||= block
matched = matches(stringlike)
+ @block.call(matched) if @block
+
if @options[:count]
- matched.size == @options[:count].to_i && (!@block || @block.call(matched))
+ matched.size == @options[:count].to_i
else
- matched.any? && (!@block || @block.call(matched))
+ matched.any?
end
end
@@ -88,6 +88,12 @@
end
}.should raise_error(Spec::Expectations::ExpectationNotMetError)
end
+
+ it "should match negative expectations in the block" do
+ @body.should have_xpath("//div") do |node|
+ node.should_not have_xpath("//div[@id='main']")
+ end
+ end
it "should match descendants of the matched elements in the block" do
@body.should have_xpath("//ul") do |node|

0 comments on commit 43b19ee

Please sign in to comment.