title: rails rspec email different process
body: <p>I am testing email sending for my controller specs, but the tests are not able to detect that an email is being sent. I can see it in the logs, but the tests are not able to see it. My suspicion is that the tests are being executed in a different thread than the email so the tests are not able to see it. Any ideas?</p>
  
  <p>Controller:</p>
  
  <pre><code>def update
    if @task.save!
      Emailer.send_task_email(@task.creator, :task_assigned, @task.project, @task).deliver
    end
  end
  </code></pre>
  
  <p>Controller Spec:</p>
  
  <pre><code>it 'emails the creator' do
    john = build(:user)
    task = create(:task, :creator =&gt; john, project: project)
  
    put :update, { :id =&gt; task.to_param }
  
    Emailer.should_receive(:send_task_email).with(task.creator, :task_assigned, task.project, task)
  end
  </code></pre>