Fix have_xpath not matching negative expectation in the block.
[#182 state:resolved]
This commit is contained in:
parent
107bdf7cf9
commit
43b19eeafa
|
@ -14,10 +14,12 @@ module Webrat
|
|||
@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 @@ describe "have_xpath" do
|
|||
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|
|
||||
|
|
Loading…
Reference in New Issue