[rspec-users] syntax for custom messages

ruud144
Mon, 05 Mar 2012 08:18:18 -0000

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