我有一个actionmailer类和相关的开销,它的工作完美.然而,在我的单元测试(rails default minitest)中,电子邮件正文为空.这是为什么?
我的邮件类:
class TermsMailer < ApplicationMailer default from: "info@domain.com" def notice_email(user,filename) @user = user @file = filename mail(to: "info@domain.com",subject: 'Data downloaded') end end
我的测试:
require 'test_helper' class TermsMailerTest < ActionMailer::TestCase test "notice" do email = TermsMailer.notice_email(users(:me),'file.ext').deliver_now assert_not ActionMailer::Base.deliveries.empty? assert_equal ['info@domain.com'],email.from assert_equal ['info@domain.com'],email.to assert_equal 'Data downloaded',email.subject assert_equal 'arbitrary garbage for comparison',email.body.to_s end end