class

ActionMailer::TestCase

v4.2.7 - Show latest stable - Superclass: ActiveSupport::TestCase

No documentation available for this class.

Included modules

  • ActionMailer::TestCase::Behavior

Files

  • actionmailer/lib/action_mailer/test_case.rb

Nested classes and modules

1Note

Test Example

cyu · Sep 21, 2008

=== UserMailerTest Example

class UserMailerTest < ActionMailer::TestCase
tests UserMailer

def test_welcome_mail
  user = users(:quentin)

  MyMailer.deliver_welcome_email
  assert !ActionMailer::Base.deliveries.empty?

  sent = ActionMailer::Base.deliveries.first
  assert_equal [@user.email], sent.to
  assert_equal “expected subject”, sent.subject
  assert sent.body =~ /^Welcome to my App/
  assert sent.body =~ /^Username: #{@user.login}$/
  assert sent.body =~ /^Password: [a-z0-9]{10}$/i
end
end

This example is a modified version of the one in this blog post:

http://sablog.com/archives/2006/03/14/how-to-test-actionmailer-in-ruby-on-rails