I'm using the following webrat matcher:
response.should contain(text)
With the following haml:
%p
You have
= current_user.credits
credits
I've written the cucumber step 'Then I should see "You have 10 credits"', which uses the webrat matcher above. The step fails, webrat does not find the text in the response because the haml actually produces
<p>You have
10
credits</p>
How can I get the matcher to match the output that haml produces?
Note: the above is a simplified example to the situation i'm dealing with. Writing the following haml is not an acceptable solution:
%p= "You have #{current_user.credits} credits"
Best Answer
You're right, this is a pain. I've found Webrat to be annoyingly touchy too much of the time.
Two ideas:
response.tr("\n","").should contain(text)
|
to tell Haml not to put line breaks in:See the Haml reference for more obscure stuff like this. (A surprising amount of which has to do with whitespace.)