Simmo
Simmo

Reputation: 1729

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

Upvotes: 5

Views: 1351

Answers (4)

Eero
Eero

Reputation: 4754

In case you use devise-async with sidekiq, as some commenters here ask, the solution is to have tests run the workers inline:

require 'sidekiq/testing'
Sidekiq::Testing.inline!

See https://github.com/mperham/sidekiq/wiki/Testing

Upvotes: 1

Tra My
Tra My

Reputation: 21

you can turn off transactions in cucumber env

see how to use:

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

Upvotes: 2

Dennis Kuczynski
Dennis Kuczynski

Reputation: 800

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

Upvotes: 3

tal
tal

Reputation: 3433

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 ?

Upvotes: 1

Related Questions