activejob/lib/active_job/test_helper.rb
# Asserts that the number of performed jobs matches the given number.
#
#   def test_jobs
#     assert_performed_jobs 0
#     HelloJob.perform_later('xavier')
#     assert_performed_jobs 1
#     HelloJob.perform_later('yves')
#     assert_performed_jobs 2
#   end
#
# If a block is passed, that block should cause the specified number of
# jobs to be performed.
#
#   def test_jobs_again
#     assert_performed_jobs 1 do
#       HelloJob.perform_later('robin')
#     end
#
#     assert_performed_jobs 2 do
#       HelloJob.perform_later('carlos')
#       HelloJob.perform_later('sean')
#     end
#   end
Asserts that the number of performed jobs matches the given number.

If a block is passed, that block should cause the specified number of
jobs to be performed.




Asserts that the number of performed jobs matches the given number . If a block is passed that block should cause the specified number of jobs to be performed .
def assert_performed_jobs(number)
        if block_given?
          original_count = performed_jobs.size
          yield
          new_count = performed_jobs.size
          assert_equal original_count + number, new_count,
                       "#{number} jobs expected, but #{new_count - original_count} were performed"
        else
          performed_jobs_size = performed_jobs.size
          assert_equal number, performed_jobs_size, "#{number} jobs expected, but #{performed_jobs_size} were performed"
        end
      end
def assert_performed_jobs ( number ) if block_given? original_count = performed_jobs . size yield new_count = performed_jobs . size assert_equal original_count + number , new_count , "#{number} jobs expected, but #{new_count - original_count} were performed" else performed_jobs_size = performed_jobs . size assert_equal number , performed_jobs_size , "#{number} jobs expected, but #{performed_jobs_size} were performed" end end
Asserts that the number of performed jobs matches the given number.
Asserts that the number of performed jobs matches the given number .
number