[rspec-devel] [ rspec-Feature Requests-12132 ] succeed matcher
noreply at rubyforge.org
noreply at rubyforge.org
Sat Jul 14 16:11:28 EDT 2007
Feature Requests item #12132, was opened at 2007-07-09 15: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: Brian Takita (btakita)
Date: 2007-07-14 13:11
Message:
David, satisfy depends on the return value of the block. It
has to be true. The intention of succeed is that there is no
exception in the block.
I suppose that unless the last line of the block is false or
nil, it will work, but that seems kind of side-effecty. I'm
worried that would lead to unexpected failures.
Of course, succeed is very similar to satisfy so it may not
justify adding another matcher.
----------------------------------------------------------------------
Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-07-09 15: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 15: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