Accept do/end blocks in matchers. [#157 state:resolved]
This commit is contained in:
parent
7fe667da73
commit
24eab77ecd
|
@ -6,9 +6,10 @@
|
|||
|
||||
* Bug fixes
|
||||
|
||||
* Accept do/end blocks in matchers. [#157] (Peter Jaros)
|
||||
* Quote --chdir option to mongrel_rails to support RAILS_ROOTs with spaces
|
||||
(T.J. VanSlyke)
|
||||
|
||||
|
||||
== 0.4.1 / 2009-01-31
|
||||
|
||||
* Minor enhancements
|
||||
|
|
|
@ -10,7 +10,9 @@ module Webrat
|
|||
@block = block
|
||||
end
|
||||
|
||||
def matches?(stringlike)
|
||||
def matches?(stringlike, &block)
|
||||
@block ||= block
|
||||
|
||||
if Webrat.configuration.parse_with_nokogiri?
|
||||
matches_nokogiri?(stringlike)
|
||||
else
|
||||
|
|
|
@ -26,12 +26,16 @@ describe Webrat::Matchers do
|
|||
end
|
||||
|
||||
it "should be able to loop over all the matched elements" do
|
||||
@body.should have_xpath("//div") { |node| node.first.name.should == "div" }
|
||||
@body.should have_xpath("//div") do |node|
|
||||
node.first.name.should == "div"
|
||||
end
|
||||
end
|
||||
|
||||
it "should not match of any of the matchers in the block fail" do
|
||||
it "should not match if any of the matchers in the block fail" do
|
||||
lambda {
|
||||
@body.should have_xpath("//div") { |node| node.first.name.should == "p" }
|
||||
@body.should have_xpath("//div") do |node|
|
||||
node.first.name.should == "p"
|
||||
end
|
||||
}.should raise_error(Spec::Expectations::ExpectationNotMetError)
|
||||
end
|
||||
|
||||
|
@ -90,12 +94,16 @@ describe Webrat::Matchers do
|
|||
end
|
||||
|
||||
it "should be able to loop over all the matched elements" do
|
||||
@body.should have_selector("div") { |node| node.first.name.should == "div" }
|
||||
@body.should have_selector("div") do |node|
|
||||
node.first.name.should == "div"
|
||||
end
|
||||
end
|
||||
|
||||
it "should not match of any of the matchers in the block fail" do
|
||||
lambda {
|
||||
@body.should have_selector("div") { |node| node.first.name.should == "p" }
|
||||
@body.should have_selector("div") do |node|
|
||||
node.first.name.should == "p"
|
||||
end
|
||||
}.should raise_error(Spec::Expectations::ExpectationNotMetError)
|
||||
end
|
||||
|
||||
|
@ -158,12 +166,16 @@ describe Webrat::Matchers do
|
|||
end
|
||||
|
||||
it "should be able to loop over all the matched elements" do
|
||||
@body.should have_tag("div") { |node| node.first.name.should == "div" }
|
||||
@body.should have_tag("div") do |node|
|
||||
node.first.name.should == "div"
|
||||
end
|
||||
end
|
||||
|
||||
it "should not match of any of the matchers in the block fail" do
|
||||
lambda {
|
||||
@body.should have_tag("div") { |node| node.first.name.should == "p" }
|
||||
@body.should have_tag("div") do |node|
|
||||
node.first.name.should == "p"
|
||||
end
|
||||
}.should raise_error(Spec::Expectations::ExpectationNotMetError)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue