assert_not_enqueued_with
We only have a assert_no_enqueued_jobs
method in ActiveJob::TestHelper
, but I often want to ensure that a specific job with specific args hasn’t been queued.
1
2
3
4
5
6
7
8
def assert_not_enqueued_with(job: nil, args: nil, &block)
only = proc do |j|
(job ? j[:job] == job : true) &&
(args ? j[:args] == ActiveJob::Arguments.serialize(args) : true)
end
assert_no_enqueued_jobs(only:, &block)
end