-
Notifications
You must be signed in to change notification settings - Fork 137
Closed
Milestone
Description
There is a slight problem with the existing have_enqueued_sidekiq_job
matcher, specifically that it's prone to the incidental state error, unlike rspec-rails
's Active Job-oriented have_enqueued_job
that is a block syntax matcher. E.g.:
class Model < ActiveRecord::Base
after_save :schedule_job
def foo!
# I do nothing!
end
private
def schedule_job
AwesomeJob.perform_async('hello')
end
end
RSpec.describe Model do
describe '#foo!' do
subject!(:model) { Model.create! }
it 'schedules AwesomeJob' do
model.foo!
expect(AwesomeJob).to have_enqueued_sidekiq_job('hello')
end
end
end
In the above example, the job was scheduled. But it would be scheduled no matter if model.foo!
was called or not.
I suggest adding a block-syntax enqueue_sidekiq_job
matcher that would work similarly to rspec-rails
's one:
RSpec.describe Model do
describe '#foo!' do
subject!(:model) { Model.create! }
it 'schedules AwesomeJob' do
expect { model.foo! }
.to enqueue_sidekiq_job(AwesomeJob).with('hello')
end
end
end
I can handle adding it if you have no objections on the idea.
Metadata
Metadata
Assignees
Labels
No labels
Projects
Status
Done