Sha256: ee33b5d46e404d20c9c72acd273d1210b42e644f827d48d29f728150e9d97d6a
Contents?: true
Size: 874 Bytes
Versions: 38
Compression:
Stored size: 874 Bytes
Contents
# frozen_string_literal: true require "nokogiri" RSpec.configure do |config| config.before { clear_emails } end # 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. module MailerHelpers def emails ActionMailer::Base.deliveries end def clear_emails ActionMailer::Base.deliveries.clear end def last_email emails.last end def last_email_body email_body(last_email) end def email_body(email) (email.try(:html_part).try(:body) || email.body).encoded end def last_email_link Nokogiri::HTML(last_email_body).css("table.content a").last["href"] end def last_email_first_link Nokogiri::HTML(last_email_body).css("table.content a").first["href"] end end RSpec.configure do |config| config.include MailerHelpers end
Version data entries
38 entries across 38 versions & 1 rubygems