lib/active_job/test_helper.rb in activejob-6.0.0.beta3 vs lib/active_job/test_helper.rb in activejob-6.0.0.rc1

- old
+ new

@@ -351,11 +351,11 @@ # assert_enqueued_with(job: MyJob, at: Date.tomorrow.noon) # end # # # The +args+ argument also accepts a proc which will get passed the actual - # job's arguments. Your proc needs to returns a boolean value determining if + # job's arguments. Your proc needs to return a boolean value determining if # the job's arguments matches your expectation. This is useful to check only # for a subset of arguments. # # def test_assert_enqueued_with # expected_args = ->(job_args) do @@ -424,11 +424,11 @@ # # assert_performed_with(job: MyJob, at: Date.tomorrow.noon) # end # # The +args+ argument also accepts a proc which will get passed the actual - # job's arguments. Your proc needs to returns a boolean value determining if + # job's arguments. Your proc needs to return a boolean value determining if # the job's arguments matches your expectation. This is useful to check only # for a subset of arguments. # # def test_assert_performed_with # expected_args = ->(job_args) do @@ -629,9 +629,23 @@ end def prepare_args_for_assertion(args) args.dup.tap do |arguments| arguments[:at] = arguments[:at].to_f if arguments[:at] + arguments[:args] = round_time_arguments(arguments[:args]) if arguments[:args] + end + end + + def round_time_arguments(argument) + case argument + when Time, ActiveSupport::TimeWithZone, DateTime + argument.change(usec: 0) + when Hash + argument.transform_values { |value| round_time_arguments(value) } + when Array + argument.map { |element| round_time_arguments(element) } + else + argument end end def deserialize_args_for_assertion(job) job.dup.tap do |new_job|