activejob/lib/active_job/test_helper.rb
# 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
Asserts that the job passed in the block has been performed with the given arguments.
Asserts that the job passed in the block has been performed with the given arguments .
def assert_performed_with(args = {}, &_block)
        original_performed_jobs = performed_jobs.dup
        clear_performed_jobs
        args.assert_valid_keys(:job, :args, :at, :queue)
        yield
        matching_job = performed_jobs.any? do |job|
          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
def assert_performed_with ( args = { } , & _block ) original_performed_jobs = performed_jobs . dup clear_performed_jobs args . assert_valid_keys ( :job , :args , :at , :queue ) yield matching_job = performed_jobs . any? do | job | 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
Asserts that the job passed in the block has been performed with the given arguments.
Asserts that the job passed in the block has been performed with the given arguments .
args
_block