[rspec-users] syntax for custom messages

ruud144 r.grosmann at gmail.com
Mon Mar 5 08:18:18 UTC 2012


hi group,

I read that expectations can print a custom message on failure using a
syntax like

cars.should be_empty, "Cars left"

But when I try this syntax for this expectation:

string.should == 'Cars left', 'Yippee, no cars anymore'

I get a syntax error:

syntax error, unexpected ',', expecting keyword_end (SyntaxError)

I want two things:
- I want a syntax error free expectation for should ==
- I want to understand what the mechanism is. I am afraid that my ruby
knowledge is not sufficient. Clearly, should is a function, but what
are be_empty and == then? Parameters? Can I use parentheses?

Thanks for helping me!

Ruud


More information about the rspec-users mailing list