Ruby on Rails latest stable (v2.2.1)
-
1 note
- Superclass:
ActiveSupport::TestCase
- v1.0.0
- v1.1.0
- v1.1.1
- v1.1.2
- v1.1.3
- v1.1.4
- v1.1.5
- v1.1.6
- v1.2.0
- v1.2.1
- v1.2.2
- v1.2.3
- v1.2.4
- v1.2.5
- v1.2.6
- 2.0.0 (0)
- 2.0.1 (0)
- 2.0.2 (0)
- 2.0.3 (0)
- 2.1.0 (-38)
- 2.2.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

