Testing ActionMailer
I am searching for a good solution to automatically test multipart - emails in Rails.
This brought me to that article which didn't help me but summarized some basics of how to test your ActionMailer:
First of all: Test, whether mails have been sent
ActionMailer::Base.deliveries # [] ActionMailer::Base.delieveries.last # TMail... ActionMailer:;Base.delieveries.last.body.match "my cool string"
Second: Bring your Test - Environment to send your mails
def setup
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []
@expected = TMail::Mail.new
@expected.set_content_type "text", "plain", { "charset" => CHARSET }
end
Also it's worth to read the Wikibook about Action Mailer.
And this is, how it goes:
should('be multipart') do
assert ActionMailer::Base.deliveries.last.header["content-type"].to_s.match('multipart')
end
Trackbacks
Verwenden Sie den folgenden Link zur Rückverlinkung von Ihrer eigenen Seite:
http://praktikanten.brueckenschlaeger.org/trackbacks?article_id=236