Module: JobIteration::TestHelper
- Defined in:
- lib/job-iteration/test_helper.rb
Overview
Include JobIteration::TestHelper to mock interruption when testing your jobs.
Instance Method Summary collapse
-
#continue_iterating ⇒ Object
Removes previous stubs and tells the job to iterate until the end.
-
#iterate_exact_times(n_times) ⇒ Object
Stubs interruption adapter to interrupt the job after every N iterations.
-
#iterate_once ⇒ Object
Stubs interruption adapter to interrupt the job after every sing iteration.
-
#mark_job_worker_as_interrupted ⇒ Object
Stubs the worker as already interrupted.
Instance Method Details
#continue_iterating ⇒ Object
Removes previous stubs and tells the job to iterate until the end.
36 37 38 |
# File 'lib/job-iteration/test_helper.rb', line 36 def stub_shutdown_adapter_to_return(false) end |
#iterate_exact_times(n_times) ⇒ Object
Stubs interruption adapter to interrupt the job after every N iterations.
25 26 27 |
# File 'lib/job-iteration/test_helper.rb', line 25 def iterate_exact_times(n_times) JobIteration.stubs(:interruption_adapter).returns(StoppingSupervisor.new(n_times.size)) end |
#iterate_once ⇒ Object
Stubs interruption adapter to interrupt the job after every sing iteration.
31 32 33 |
# File 'lib/job-iteration/test_helper.rb', line 31 def iterate_once iterate_exact_times(1.times) end |
#mark_job_worker_as_interrupted ⇒ Object
Stubs the worker as already interrupted.
41 42 43 |
# File 'lib/job-iteration/test_helper.rb', line 41 def mark_job_worker_as_interrupted stub_shutdown_adapter_to_return(true) end |