Alex Rivera | Logout

rspec-email - How to get the body text?

Asked 2011-03-21T22:25:34.233
20

I'm using rspec with the email-spec gem. I'm trying to do:

last_delivery = ActionMailer::Base.deliveries.last
last_delivery.body.should include "This is the text of the email"

But that doesn't work, is there a way to say body, text version? Content-Type: text/text?

Thanks

Edit
Report

1 Answer

40

Body is actually a Mail::Body instance. Calling raw_source on it should do the trick:

last_delivery = ActionMailer::Base.deliveries.last
last_delivery.body.raw_source.should include "This is the text of the email"
answered 2011-03-22T11:31:20.590

Your Answer