Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get devise_async working with Cucumber?

I've followed the instructions for devise_async as per the README and I'm rolling Devise 2.1.2 and delayed_job. In my cucumber tests, I no longer receive the confirmation email as part of the sign-up process. Is there something I should be doing as part of testing? I already set delayed job to skip the actual delay for testing by setting the following in my test environment.

Delayed::Worker.delay_jobs = false

But even with this set to true, it still fails, albeit more slowly. If I remove the devise_async gem and the relevant lines, everything bursts back into life.

Thanks, Graeme

like image 208
Simmo Avatar asked Nov 15 '12 21:11

Simmo


3 Answers

The new version of devise-async triggers the emails after the record has been committed to the database. With RSpec, each test is wrapped in a transaction by default. Does Cucumber do the same? In that case you'll need to turn those test transactions off.

Here's what I use for RSpec: http://www.denniskuczynski.com/2012/06/22/changing-individual-test-configuration-based-on-passed-in-options.html

like image 64
Dennis Kuczynski Avatar answered Sep 17 '22 02:09

Dennis Kuczynski


you can turn off transactions in cucumber env

see how to use:

https://github.com/cucumber/cucumber/wiki/Browsers-and-Transactions

like image 45
Tra My Avatar answered Sep 19 '22 02:09

Tra My


Did you try using the Delayed::Worker.new.work_off approach ? Not sure it works for Devise async, but it worked for me previously for checking emails.

Using this step

Given /^Jobs are being dispatched$/ do
  Delayed::Worker.new.work_off 
end

And running this step before testing emails ?

like image 28
tal Avatar answered Sep 18 '22 02:09

tal