开发者

rails/cucumber - how to .should == text with formatting?

I'm using cucumber with my rails 3 app.

My step definition works like so:

开发者_Python百科Given /^a email reply from gmail$/ do
  # Get the Raw Email
  raw_email = File.read("#{Rails.root}/features/step_definitions/email_replies/gmail_webapp_standard_1.txt")
  # Send it to the mailingjob to find the reply
  parsed_email = ::MailingJob::find_reply(raw_email)
  # Does the reply match correctly?
  parsed_email.should == 'This is my reply. This is paragraph one.

  This is paragraph two. Capture everything before me as this is the last sentence.
  '   
end

The issue here is that the parsed_email is two paragraphs, text formatted, not html. If it's just one sentence it's easy to compare to see if the two sentences match, but with formatting it fails. How can I do a .should where formatting works?

Thanks


Try replacing the line breaks with \n in the step definition and that should work.


The email-spec gem may can help you with your problem:

https://github.com/bmabey/email-spec

Examples for the generated email steps are here:

https://github.com/bmabey/email-spec/wiki/Use-Cucumber-to-Test-Email

especially the step I should see "your email text" in the email body could be interesting for you ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜