module ActiveJob::TestHelper
def assert_no_performed_jobs(only: nil, except: nil, queue: nil, &block)
Note: This assertion is simply a shortcut for:
end
end
HelloJob.set(queue: :other_queue).perform_later("jeremy")
assert_no_performed_jobs queue: :some_queue do
def test_assert_no_performed_jobs_with_queue_option
then only the job(s) enqueued to a specific queue will not be performed.
If the +:queue+ option is specified,
an instance of the job will be passed as argument.
+:only+ and +:except+ options accept Class, Array of Class, or Proc. When passed a Proc,
end
end
HelloJob.perform_later('jeremy')
assert_no_performed_jobs except: HelloJob do
def test_no_logging
then the job(s) except specific class will not be performed.
Also if the +:except+ option is specified,
end
end
HelloJob.perform_later('jeremy')
assert_no_performed_jobs only: LoggingJob do
def test_no_logging
then only the listed job(s) will not be performed.
The block form supports filtering. If the +:only+ option is specified,
end
end
# No job should be performed from this block
assert_no_performed_jobs do
def test_jobs_again
If a block is passed, asserts that the block will not cause any job to be performed.
end
end
assert_performed_jobs 1
HelloJob.perform_later('matthew')
perform_enqueued_jobs do
assert_no_performed_jobs
def test_jobs
Asserts that no jobs have been performed.
def assert_no_performed_jobs(only: nil, except: nil, queue: nil, &block) require_active_job_test_adapter!("assert_no_performed_jobs") assert_performed_jobs 0, only: only, except: except, queue: queue, &block end