wspurgin / rspec-sidekiq

RSpec for Sidekiq
https://github.com/wspurgin/rspec-sidekiq
Other
663 stars 132 forks source link

Add `to` method to `have_enqueued_job` #164

Closed gbrlcustodio closed 1 year ago

gbrlcustodio commented 4 years ago

Allow applying expectations to enqueue queue when setting queue at enqueue time.

Let's say we have a worker listening to old_queue

class TestJob
  include Sidekiq::Worker
  sidekiq_options queue: :old_queue
end

But at enqueue time, we change it to new_queue

TestJob.set(queue: :new_queue).perform_async(1) # queue used is 'new_queue'

This PR enables this feature to be tested using the new queue evaluator when queue is expected by calling to method of have_enqueued_job matcher.

Example:

it { expect(worker).to have_enqueued_sidekiq_job(id).to(queue) }
coveralls commented 4 years ago

Coverage Status

Coverage decreased (-0.5%) to 78.962% when pulling 54bbb3b79455361e69b238c49e2a037f2aadb7ce on trustvox:develop into 2cd15b0fe2b172243e8002c4aefa39696c42d52f on philostler:develop.

coveralls commented 4 years ago

Coverage Status

Coverage decreased (-0.5%) to 78.962% when pulling 54bbb3b79455361e69b238c49e2a037f2aadb7ce on trustvox:develop into 2cd15b0fe2b172243e8002c4aefa39696c42d52f on philostler:develop.

gbrlcustodio commented 4 years ago

I was unable to run the expectations locally since I keep stumbled upon this error:

An app is required to create a GlobalID. Pass the :app option or set the default GlobalID.app.
wspurgin commented 1 year ago

Closing since we've added #on with v4