title: Can't test if method was called when using delayed_job 'delay' method
body: <p>I use Mocha, Test::Unit and delayed_job and wanted to test whether mailer method has been executed, like this:</p>
  
  <pre><code>  test "should send info about paid payment" do
      payment = Payment.new :contractor_name =&gt; "notempty", :address =&gt; "notempty"
  
      UserMailer.expects(:send_payment_info)
  
      payment.set_paid!
  
    end
  
  
    # model method
    def set_paid!
      self.status = 'paid'
      self.paid_at = Date.today
      self.save!
  
      UserMailer.delay.send_payment_info self
    end
  </code></pre>
  
  <p>Without using delay method test works as expected, but with it (and I have Delayed::Worker.delay_jobs = !Rails.env.test? in initializer config) I get:</p>
  
  <blockquote>
    <p>NoMethodError: undefined method <code>deliver' for nil:NilClass
    app/models/payment.rb:33:in</code>set_paid!'
        test/unit/payment_test.rb:50:in `test_should_send_info_about_paid_payment'</p>
  </blockquote>
  
  <p>And I have no clue how to fix this? Maybe I should moch UserMailer differently?</p>