title: In Rails why is my mail body empty only in my test?
body: <p>I have an actionmailer class and associated overhead, it works perfectly. In my unit test (rails default minitest) however, the email body is empty. Why is that?</p>
  
  <p>my mailer class:</p>
  
  <pre><code>class TermsMailer &lt; 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
  </code></pre>
  
  <p>my test:</p>
  
  <pre><code>require 'test_helper'
  
  class TermsMailerTest &lt; 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
  </code></pre>
  
  <p>The views for this mailer are not blank, and the correct contents are in fact sent in the emails. So why is the email body blank in my test?</p>