Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I test DelayedJob with Cucumber?

We use DelayedJob to run some of our long running processes and would like to test with Cucumber/Webrat.

Currently, we are calling Delayed::Job.work_off in a Ruby thread to get work done in the background, but are looking for a more robust solution

What is the best approach for this?

Thanks.

like image 700
Sean Avatar asked Nov 14 '22 06:11

Sean


1 Answers

The main problem I see with the Delayed:Job.work_off approach is that you are making explicit in your Cucumber scenarios something that belongs to the internals of your system. Mixing both concerns is against the spirit of functional testing:

When I click some link # Some operation is launched in the background
And Jobs are dispatched # Delayed:Job.work_off invoked here
Then I should see the results...

Another problem is that you populate your Cucumber scenarios with repetitive steps for dispatching jobs when needed.

The approach I am currently using is launching delayed_job in the background while cucumber scenarios are being executed. You can check the Cucumber hooks I am using in that link.

like image 73
jmanrubia Avatar answered Dec 06 '22 23:12

jmanrubia