leshill / resque_spec

RSpec matcher for Resque
MIT License
295 stars 86 forks source link

Would love if have_queued was not so strict #121

Open jchatel opened 8 years ago

jchatel commented 8 years ago

First of al, great gem, super useful, thanks for that.

I have a case where I test if a job can go on the queue or not with before_enqueue and this is the perfect gem for testing that.

That said, in my before_enqueue resque hook, I enrich my arguments.

For example, I create a database entry for error text/status I want to have associated with the job.

So, in the example, this fails:

expect(Person).to have_queued(person.id, :calculate)

Because I added another argument in the queue.

expect(Person).to have_queued(person.id, :calculate, :job_id => 123) would work, but I have no access to 123 since it's an auto increment.

Any suggestion to work around this? E.g. have_queued_at_least or have_gained_arguments, or have_queued_no_check_value...

Right now, I use Resque.peek to check the job and then do args validation. Making sure I do have a job_id, the number is irrelevant for me as much as testing my arguments have been enriched.

leshill commented 8 years ago

Hi @jchatel,

Those sound like great additions. A PR would be greatly appreciated. Also please take note that in issue #119 @pboling is proposing a change to the way have_queued determines what to look at in the queue.