[rspec-users] Failure Messages in RSpec

Jay Levitt lists-rspec at shopwatch.org
Tue Sep 4 17:08:30 EDT 2007

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!)


More information about the rspec-users mailing list