Oto jak rozwiązać podobny problem:
# rails_helper.rb
RSpec.configure do |config|
config.before :example, perform_enqueued: true do
@old_perform_enqueued_jobs = ActiveJob::Base.queue_adapter.perform_enqueued_jobs
@old_perform_enqueued_at_jobs = ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true
ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = true
end
config.after :example, perform_enqueued: true do
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = @old_perform_enqueued_jobs
ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = @old_perform_enqueued_at_jobs
end
end
Następnie w specyfikacji możemy użyć:
it "should perform immediately", perform_enqueued: true do
SomeJob.perform_later
end
Może to pomoże https://medium.com/@chuckjhardy/testing-rails-activejob-with-rspec -5c3de1a64b66 – CharlesJHardy