Flowdock
method

assert_performed_jobs

Importance_2
v4.2.1 - Show latest stable - 0 notes - Class: TestHelper
assert_performed_jobs(number) public

Asserts that the number of performed jobs matches the given number. If no block is passed, perform_enqueued_jobs must be called around the job call.

def test_jobs
  assert_performed_jobs 0

  perform_enqueued_jobs do
    HelloJob.perform_later('xavier')
  end
  assert_performed_jobs 1

  perform_enqueued_jobs do
    HelloJob.perform_later('yves')
    assert_performed_jobs 2
  end
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
Show source
Register or log in to add new notes.