Sha256: 4b38ff2c0ea34babe10fb5a4535f8a9d7a46cbfe112f342ec4788380336263cd
Contents?: true
Size: 1.28 KB
Versions: 7
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true require "nokogiri" RSpec.configure do |config| config.before(:each) do ActionMailer::Base.deliveries.clear end 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 last_email emails.last end def last_email_body (last_email.body || last_email.html_part.body).encoded end def last_email_link Nokogiri::HTML(last_email_body).css("table.content a").last["href"] end end RSpec.configure do |config| config.include MailerHelpers end RSpec.configure do |config| config.before :example, perform_enqueued: true do @old_perform_enqueued_jobs = ActiveJob::Base.queue_adapter.perform_enqueued_jobs @old_perform_enqueued_at_jobs = ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = true end config.after :example, perform_enqueued: true do ActiveJob::Base.queue_adapter.perform_enqueued_jobs = @old_perform_enqueued_jobs ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = @old_perform_enqueued_at_jobs end end
Version data entries
7 entries across 7 versions & 1 rubygems