class
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