v5.1.7 -
Show latest stable
-
1 note
- Superclass:
ActiveSupport::TestCase
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3 (0)
- 2.1.0 (-38)
- 2.2.1 (0)
- 2.3.8 (0)
- 3.0.0 (0)
- 3.0.9 (0)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- 7.2.3 (0)
- 8.1.1 (0)
- What's this?
Register or
log in
to add new notes.
cyu -
September 21, 2008 - (>= v2.1.0)
0 thanks
Test Example
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

