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
last_email_first_link()
click to toggle source
# File lib/decidim/dev/test/rspec_support/action_mailer.rb, line 37 def last_email_first_link Nokogiri::HTML(last_email_body).css("table.content a").first["href"] end
last_email_link()
click to toggle source
# File lib/decidim/dev/test/rspec_support/action_mailer.rb, line 33 def last_email_link Nokogiri::HTML(last_email_body).css("table.content a").last["href"] end