instance method
assert_performed_with
Ruby on Rails 4.2.9
Since v4.2.9Signature
assert_performed_with(args = {}, &_block)
Asserts that the job passed in the block has been performed with the given arguments.
def test_assert_performed_with assert_performed_with(job: MyJob, args: [1,2,3], queue: 'high') do MyJob.perform_later(1,2,3) end end
Parameters
-
argsopt = {} -
_blockblock
Source
# File activejob/lib/active_job/test_helper.rb, line 179
def assert_performed_with(args = {}, &_block)
original_performed_jobs = performed_jobs.dup
clear_performed_jobs
args.assert_valid_keys(:job, :args, :at, :queue)
serialized_args = serialize_args_for_assertion(args)
perform_enqueued_jobs { yield }
matching_job = performed_jobs.any? do |job|
serialized_args.all? { |key, value| value == job[key] }
end
assert matching_job, "No performed job found with #{args}"
ensure
queue_adapter.performed_jobs = original_performed_jobs + performed_jobs
end
Defined in activejob/lib/active_job/test_helper.rb line 179
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveJob::TestHelper