module ActiveJob::TestHelper

def assert_no_enqueued_jobs(only: nil, except: nil, &block)

assert_enqueued_jobs 0, &block

Note: This assertion is simply a shortcut for:

end
end
HelloJob.perform_later('jeremy')
assert_no_enqueued_jobs except: HelloJob do
def test_no_logging

It can be asserted that no jobs except specific class are enqueued:

end
end
HelloJob.perform_later('jeremy')
assert_no_enqueued_jobs only: LoggingJob do
def test_no_logging

It can be asserted that no jobs of a specific kind are enqueued:

end
end
# No job should be enqueued from this block
assert_no_enqueued_jobs do
def test_jobs_again

If a block is passed, that block should not cause any job to be enqueued.

end
assert_enqueued_jobs 1
HelloJob.perform_later('jeremy')
assert_no_enqueued_jobs
def test_jobs

Asserts that no jobs have been enqueued.
def assert_no_enqueued_jobs(only: nil, except: nil, &block)
  assert_enqueued_jobs 0, only: only, except: except, &block
end