module MailerHelpers

A set of helpers meant to make your life easier when testing emails, especially given the fact that ActionMailer's API can be a bit inconsistent.

Public Instance Methods

clear_emails() click to toggle source
# File lib/decidim/dev/test/rspec_support/action_mailer.rb, line 17
def clear_emails
  ActionMailer::Base.deliveries.clear
end
email_body(email) click to toggle source
# File lib/decidim/dev/test/rspec_support/action_mailer.rb, line 29
def email_body(email)
  (email.try(:html_part).try(:body) || email.try(:body))&.encoded
end
emails() click to toggle source
# File lib/decidim/dev/test/rspec_support/action_mailer.rb, line 13
def emails
  ActionMailer::Base.deliveries
end
last_email() click to toggle source
# File lib/decidim/dev/test/rspec_support/action_mailer.rb, line 21
def last_email
  emails.last
end
last_email_body() click to toggle source
# File lib/decidim/dev/test/rspec_support/action_mailer.rb, line 25
def last_email_body
  email_body(last_email)
end