-
-
Notifications
You must be signed in to change notification settings - Fork 11
Description
If you configure a Rails application to use the karafka queue adapter as described in https://karafka.io/docs/Active-Job/, then when writing rspec tests that use the have_enqueued_job matcher, they will fail reporting no jobs were enqueued
Expected behavior
When configuring rails to use the karafka ActiveJob adapter with:
config.active_job.queue_adapter = :karafkaThen if I write ruby code to publish a job:
class SomeJob < ApplicationJob
def perform
puts "performed"
end
end
SomeJob.perform_laterI expect an rspec test like this to pass:
expect do
SomeJob.perform_later
end.to have_enqueued_job(SomeJob).onceActual behavior
The rspec test fails with
expected to enqueue exactly 1 jobs, but enqueued 0
I also observed this happens regardless of whether I use the produce_sync option or not
karafka_options(
dispatch_method: :produce_sync
)Steps to reproduce the problem
Create a rails 7 application, and configure it to use the :karafka queue adapter for ActiveJob as per above
Set up the karafka gem
Write a test that enqueues a job
See that it fails to report enqueueing the job
Your setup details
I am using Rails 7.0.4.3 and rspec 3.12.0
Karafka info is below:
$ [bundle exec] karafka info
2023-04-21 09:30:25.307444 I [65649:57120] Rails -- Karafka version: 2.0.38
Ruby version: ruby 3.2.1 (2023-02-08 revision 31819e82c8) +YJIT [arm64-darwin22]
Rdkafka version: 0.12.1
Consumer groups count: 4
Subscription groups count: 4
Workers count: 5
...