Class: ActionMailer::TestCase
- Includes:
- Quoting
- Defined in:
- lib/action_mailer/test_case.rb
Overview
New Test Super class for forward compatibility. To override
Class Method Summary collapse
- .determine_default_mailer(name) ⇒ Object
- .mailer_class ⇒ Object
- .method_added(method) ⇒ Object
- .tests(mailer) ⇒ Object
Instance Method Summary collapse
- #setup_with_mailer ⇒ Object (also: #setup)
Class Method Details
.determine_default_mailer(name) ⇒ Object
29 30 31 32 33 |
# File 'lib/action_mailer/test_case.rb', line 29 def determine_default_mailer(name) name.sub(/Test$/, '').constantize rescue NameError => e raise NonInferrableMailerError.new(name) end |
.mailer_class ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/action_mailer/test_case.rb', line 21 def mailer_class if mailer = read_inheritable_attribute(:mailer_class) mailer else tests determine_default_mailer(name) end end |
.method_added(method) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/action_mailer/test_case.rb', line 47 def self.method_added(method) if method.to_s == 'setup' unless method_defined?(:setup_without_mailer) alias_method :setup_without_mailer, :setup define_method(:setup) do setup_with_mailer setup_without_mailer end end end end |
.tests(mailer) ⇒ Object
17 18 19 |
# File 'lib/action_mailer/test_case.rb', line 17 def tests(mailer) write_inheritable_attribute(:mailer_class, mailer) end |
Instance Method Details
#setup_with_mailer ⇒ Object Also known as: setup
36 37 38 39 40 41 42 43 44 |
# File 'lib/action_mailer/test_case.rb', line 36 def setup_with_mailer ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries = [] @expected = TMail::Mail.new @expected.set_content_type "text", "plain", { "charset" => charset } @expected.mime_version = '1.0' end |