Search code examples
rspecrspec2email-spec

rspec-email - How to get the body text?


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


Solution

  • 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"