Sha256: 868f1041f1c1216010b7ea5c6f5548a020868c84c9d698aeccd248eb9e3b9531
Contents?: true
Size: 1.56 KB
Versions: 2
Compression:
Stored size: 1.56 KB
Contents
module ActionMailer class NonInferrableMailerError < ::StandardError def initialize(name) super "Unable to determine the mailer to test from #{name}. " + "You'll need to specify it using tests YourMailer in your " + "test case definition" end end class TestCase < ActiveSupport::TestCase include Quoting, TestHelper setup :initialize_test_deliveries setup :set_expected_mail class << self def tests(mailer) write_inheritable_attribute(:mailer_class, mailer) end def mailer_class if mailer = read_inheritable_attribute(:mailer_class) mailer else tests determine_default_mailer(name) end end def determine_default_mailer(name) name.sub(/Test$/, '').constantize rescue NameError => e raise NonInferrableMailerError.new(name) end end protected def initialize_test_deliveries ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries.clear end def set_expected_mail @expected = Mail.new @expected.content_type ["text", "plain", { "charset" => charset }] @expected.mime_version = '1.0' end private def charset "utf-8" end def encode(subject) quoted_printable(subject, charset) end def read_fixture(action) IO.readlines(File.join(Rails.root, 'test', 'fixtures', self.class.mailer_class.name.underscore, action)) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
actionmailer-3.0.0.beta2 | lib/action_mailer/test_case.rb |
actionmailer-3.0.0.beta | lib/action_mailer/test_case.rb |