vendredi 6 mars 2020

Devise ActiveJob - mock for testing purposes

Since rails 4.2 and ActiveJob - there is a simple way to send devise notifications

def send_devise_notification(notification, *args)
  devise_mailer.send(notification, self, *args).deliver_later
end

and I'd like to mock this method to test sending an email. I've tried the following code in my cucumber steps but it isn't working :(

  RSpec::Mocks.with_temporary_scope do
    User.any_instance.stub(:send_devise_notification).and_return(true)
  end

How to fix/improve this code?

Aucun commentaire:

Enregistrer un commentaire