method
assert_enqueued_jobs
v5.0.0.1 -
Show latest stable
-
0 notes -
Class: TestHelper
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (36)
- 5.1.7 (38)
- 5.2.3 (38)
- 6.0.0 (37)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
assert_enqueued_jobs(number, only: nil)
public
Asserts that the number of enqueued jobs matches the given number.
def test_jobs assert_enqueued_jobs 0 HelloJob.perform_later('david') assert_enqueued_jobs 1 HelloJob.perform_later('abdelkader') assert_enqueued_jobs 2 end
If a block is passed, that block should cause the specified number of jobs to be enqueued.
def test_jobs_again assert_enqueued_jobs 1 do HelloJob.perform_later('cristian') end assert_enqueued_jobs 2 do HelloJob.perform_later('aaron') HelloJob.perform_later('rafael') end end
The number of times a specific job is enqueued can be asserted.
def test_logging_job assert_enqueued_jobs 1, only: LoggingJob do LoggingJob.perform_later HelloJob.perform_later('jeremy') end end