[rspec-users] Failure Messages in RSpec

Chad Humphries chad at spicycode.com
Tue Sep 4 17:14:52 EDT 2007

I generally write custom expectation matchers when I want more  
specific information on failure scenarios.  Granted this might not  
work in all scenarios (taking time to write a custom matcher I mean),  
but for most things it has made it very nice.


On Sep 4, 2007, at 5:08 PM, Jay Levitt wrote:

> Shane Mingins wrote:
>> On 5/09/2007, at 8:51 AM, Geoffrey Wiseman wrote:
>>> Using this as an example, if a new validation rule is added, this  
>>> test
>>> will fail without indicating /why/.  Sure, I can get that answer in
>>> other ways, but I'd hate to discover things like:
>>> it "should be valid with valid attributes" do
>>>   # puts @person.errors if !@person.valid
>>>   @person.should be_valid
>>> end
>> Sorry if I missed the point of this, but in the context of having an
>> optional failure message....
>> I am curious as to how an optional message param to the assertion  
>> would
>> help you in this case?
> Seems like, in this case, he'd output @person.errors in his message so
> he could see *why* person was invalid; the "puts" is his current
> hack-around for the lack of custom messages.
> Not a bad idea, really.  (the custom messages, not the hackaround!)
> Jay
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list