librelist archives

« back to archive

Rails testing strategy

Rails testing strategy

From:
A B
Date:
2011-03-10 @ 18:57
Hi, can anyone recommend a testing strategy for Resque in Rails 3? Where  should 
I put stuff and what should I test (Google has only helped a  little)?

For example, I'm queuing jobs using an after_create  callback in my model, but 
this queues a task for every unit test with my  factory-generated instance, 
defined in a setup method. So even failed  validation tests send a job to the 
queue. I think doing this from a  controller would make testing easier.

How should I verify all the different parts are working?

I'm overriding Resque.enqueue in a test helper as recommended elsewhere, but 
have a long way to go.


      

Re: [resque] Rails testing strategy

From:
Ben VandenBos
Date:
2011-03-10 @ 19:03
You can checkout resque_unit which is a gem to make resque testing easier.


On Mar 10, 2011, at 10:57 AM, A B wrote:

> Hi, can anyone recommend a testing strategy for Resque in Rails 3? Where
should I put stuff and what should I test (Google has only helped a 
little)?
> 
> For example, I'm queuing jobs using an after_create callback in my 
model, but this queues a task for every unit test with my 
factory-generated instance, defined in a setup method. So even failed 
validation tests send a job to the queue. I think doing this from a 
controller would make testing easier.
> 
> How should I verify all the different parts are working?
> 
> I'm overriding Resque.enqueue in a test helper as recommended elsewhere,
but have a long way to go.
> 
> 

Re: [resque] Rails testing strategy

From:
A B
Date:
2011-03-10 @ 19:51
Thanks, I tried resque_unit earlier but had some problems. I'll have to try 
again when I have time to debug.

I found another article at 
http://blog.nragaz.com/post/807519209/architecting-for-resque which favors 
models over controllers. I'll keep thinking about how to manage this. For 
example I want good test coverage but I don't want to actually perform the tasks 
during testing (it costs money).




________________________________
From: Ben VandenBos <bvandenbos@gmail.com>
To: resque@librelist.com
Sent: Thu, March 10, 2011 2:03:48 PM
Subject: Re: [resque] Rails testing strategy

You can checkout resque_unit which is a gem to make resque testing easier.