[rspec-devel] [ rspec-Feature Requests-12132 ] succeed matcher

noreply at rubyforge.org noreply at rubyforge.org
Mon Jul 9 18:29:08 EDT 2007


Feature Requests item #12132, was opened at 2007-07-09 18:10
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=12132&group_id=797

Category: expectation module
Group: None
Status: Open
Priority: 3
Submitted By: Brian Takita (btakita)
Assigned to: Nobody (None)
Summary: succeed matcher

Initial Comment:
Sometime I want to have a method that has a compound matcher.

The succeed matcher executes the block and returns true if there is no exception.

e.g.

"Foobar".should succeed do |obj|
  obj.to_s.should == "Foobar"
end # success

"Foobar".should succeed do |obj|
  obj.to_s.should == "Baz"
end # Failure

----------------------------------------------------------------------

>Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-07-09 18:29

Message:
What kind of method are you talking about?
Why does it matter what the succeed matcher _returns_?

Can you provide a more illustrative/complete example? I can rewrite your code as (I must be missing something):

"Foobar".to_s.should == "Foobar"
"Foobar".to_s.should == "Baz"

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-07-09 18:26

Message:
Have you tried should satisfy? It's basically what you're asking for:

http://rspec.rubyforge.org/rdoc/classes/Spec/Matchers.html#M000248

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=12132&group_id=797


More information about the rspec-devel mailing list