diff options
Diffstat (limited to 'actionmailer/lib/action_mailer/test_case.rb')
-rw-r--r-- | actionmailer/lib/action_mailer/test_case.rb | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/actionmailer/lib/action_mailer/test_case.rb b/actionmailer/lib/action_mailer/test_case.rb index 80f323873d..766215ce96 100644 --- a/actionmailer/lib/action_mailer/test_case.rb +++ b/actionmailer/lib/action_mailer/test_case.rb @@ -1,4 +1,5 @@ require 'active_support/test_case' +require 'rails-dom-testing' module ActionMailer class NonInferrableMailerError < ::StandardError @@ -10,23 +11,19 @@ module ActionMailer end class TestCase < ActiveSupport::TestCase - - # Use AM::TestCase for the base class when describing a mailer - register_spec_type(self) do |desc| - Class === desc && desc < ActionMailer::Base - end - register_spec_type(/Mailer( ?Test)?\z/i, self) - module Behavior extend ActiveSupport::Concern include ActiveSupport::Testing::ConstantLookup include TestHelper + include Rails::Dom::Testing::Assertions::SelectorAssertions + include Rails::Dom::Testing::Assertions::DomAssertions included do class_attribute :_mailer_class setup :initialize_test_deliveries setup :set_expected_mail + teardown :restore_test_deliveries end module ClassMethods @@ -61,11 +58,26 @@ module ActionMailer protected def initialize_test_deliveries - ActionMailer::Base.delivery_method = :test + set_delivery_method :test + @old_perform_deliveries = ActionMailer::Base.perform_deliveries ActionMailer::Base.perform_deliveries = true + end + + def restore_test_deliveries + restore_delivery_method + ActionMailer::Base.perform_deliveries = @old_perform_deliveries ActionMailer::Base.deliveries.clear end + def set_delivery_method(method) + @old_delivery_method = ActionMailer::Base.delivery_method + ActionMailer::Base.delivery_method = method + end + + def restore_delivery_method + ActionMailer::Base.delivery_method = @old_delivery_method + end + def set_expected_mail @expected = Mail.new @expected.content_type ["text", "plain", { "charset" => charset }] |