diff options
author | Maxime Boisvert <maxime.boisvert@shopify.com> | 2016-11-16 15:41:30 -0500 |
---|---|---|
committer | Maxime Boisvert <maxime.boisvert@shopify.com> | 2016-11-16 17:19:48 -0500 |
commit | c061236cc7e03ec6c8f71f1b166251cc63377417 (patch) | |
tree | 4623e9410a75670a390f3f0f048fcc91729e0577 /activejob | |
parent | 3b2346ea1393ad5deb049ae071116773c602ddc0 (diff) | |
download | rails-c061236cc7e03ec6c8f71f1b166251cc63377417.tar.gz rails-c061236cc7e03ec6c8f71f1b166251cc63377417.tar.bz2 rails-c061236cc7e03ec6c8f71f1b166251cc63377417.zip |
Use named parameters instead of `assert_valid_keys`
Diffstat (limited to 'activejob')
-rw-r--r-- | activejob/lib/active_job/test_helper.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/activejob/lib/active_job/test_helper.rb b/activejob/lib/active_job/test_helper.rb index 1a8b3375ae..9e45c0da24 100644 --- a/activejob/lib/active_job/test_helper.rb +++ b/activejob/lib/active_job/test_helper.rb @@ -232,16 +232,16 @@ module ActiveJob # MyJob.set(wait_until: Date.tomorrow.noon).perform_later # end # end - def assert_enqueued_with(args = {}) + def assert_enqueued_with(job: nil, args: nil, at: nil, queue: nil) original_enqueued_jobs_count = enqueued_jobs.count - args.assert_valid_keys(:job, :args, :at, :queue) - serialized_args = serialize_args_for_assertion(args) + expected = { job: job, args: args, at: at, queue: queue }.compact + serialized_args = serialize_args_for_assertion(expected) yield in_block_jobs = enqueued_jobs.drop(original_enqueued_jobs_count) matching_job = in_block_jobs.find do |job| serialized_args.all? { |key, value| value == job[key] } end - assert matching_job, "No enqueued job found with #{args}" + assert matching_job, "No enqueued job found with #{expected}" instantiate_job(matching_job) end @@ -256,16 +256,16 @@ module ActiveJob # MyJob.set(wait_until: Date.tomorrow.noon).perform_later # end # end - def assert_performed_with(args = {}) + def assert_performed_with(job: nil, args: nil, at: nil, queue: nil) original_performed_jobs_count = performed_jobs.count - args.assert_valid_keys(:job, :args, :at, :queue) - serialized_args = serialize_args_for_assertion(args) + expected = { job: job, args: args, at: at, queue: queue }.compact + serialized_args = serialize_args_for_assertion(expected) perform_enqueued_jobs { yield } in_block_jobs = performed_jobs.drop(original_performed_jobs_count) matching_job = in_block_jobs.find do |job| serialized_args.all? { |key, value| value == job[key] } end - assert matching_job, "No performed job found with #{args}" + assert matching_job, "No performed job found with #{expected}" instantiate_job(matching_job) end |