1

Real emailing works but the test fails. Not sure whats going wrong. Does anyone know what could be the problem?

TasksController POST create with valid params emails the collaborators (FAILED - 1)

  it 'emails the collaborators' do
    post :create, { :task => valid_attributes }

    Emailer.should_receive(:send_email).with(user, :new_task, assigns(:task).project)
  end

Failures:

1) TasksController POST create with valid params emails the collaborators Failure/Error: Emailer.should_receive(:send_email).with(user, :new_task, assigns(:task).project) ().send_email(#, :new_task, 'blah')
expected: 1 time
received: 0 times

I have the following gems:
rails (3.2.7)
rspec-rails (2.11.4)
email_spec (1.2.1)

Pratik Khadloya
  • 12,509
  • 11
  • 81
  • 106
  • Even this assertion is not passing: `expect {post :create, { :task => valid_attributes }}.to change(ActionMailer::Base.deliveries, :size).by(1)` – Pratik Khadloya Oct 18 '12 at 13:45
  • 1
    Had to put `require 'rspec/rails/mocha'` call in spec_helper.rb at the bottom to get it working. – Pratik Khadloya Oct 18 '12 at 14:54
  • Removed mocha as it stopped working after i put the require 'rspec/rails/mocha' line at the bottom. So, am now happy with email_spec working with rspec mocks. – Pratik Khadloya Oct 18 '12 at 22:29

0 Answers0