/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def setup @user = users(:myfixtureuser) ActionMailer::Base.deliveries = [] end def test_welcome_mail 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