I had some issues with sending confirmation emails in Devise. That's why I would like to write tests for this functionality. How could I do this, when I don't create my own mailers?
I decided, that this should be enough:
it 'should send an email' do
user
put :complete, params
user.send(:send_confirmation_notification?).should == true
end
Please, let me know if I missed something.
Have you looked at the tests which have been written for Devise?
https://github.com/plataformatec/devise/blob/master/test/mailers/confirmation_instructions_test.rb
This worked for me if you want to have a more explicit test and actually test the email is sent with RSpec.
it 'sends a confirmation email' do
user = FactoryGirl.build :user
expect { user.save }.to change(ActionMailer::Base.deliveries, :count).by(1)
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With