Class: ConflowSpec::Matchers::RunJob
- Inherits:
-
Object
- Object
- ConflowSpec::Matchers::RunJob
- Includes:
- RSpec::Matchers
- Defined in:
- lib/conflow_spec/matchers/run_job.rb
Overview
Specifies that flow should at some point enqueue specific job.
Instance Attribute Summary collapse
-
#expected_params ⇒ Object
readonly
Returns the value of attribute expected_params.
-
#flow ⇒ Object
readonly
Returns the value of attribute flow.
-
#job_class ⇒ Object
readonly
Returns the value of attribute job_class.
Instance Method Summary collapse
-
#description ⇒ Object
Description of the spec.
-
#failure_message ⇒ Object
Error message when matcher returns false, but it was expected to return true.
-
#failure_message_when_negated ⇒ Object
Error message when matcher returns true, but it was expected to return false.
-
#initialize(job_class) ⇒ RunJob
constructor
A new instance of RunJob.
-
#matches?(flow) ⇒ Boolean
True if all requirements are fulfilled.
-
#times(num) ⇒ Object
Specifies how many times job should be run.
-
#twice ⇒ Object
Convinience method to specify job should be enqueued twice.
-
#with_params(params) ⇒ Object
Specifies parameters that the job should be run with.
Constructor Details
#initialize(job_class) ⇒ RunJob
Returns a new instance of RunJob.
12 13 14 15 |
# File 'lib/conflow_spec/matchers/run_job.rb', line 12 def initialize(job_class) @job_class = job_class @times = 1 end |
Instance Attribute Details
#expected_params ⇒ Object (readonly)
Returns the value of attribute expected_params.
9 10 11 |
# File 'lib/conflow_spec/matchers/run_job.rb', line 9 def expected_params @expected_params end |
#flow ⇒ Object (readonly)
Returns the value of attribute flow.
9 10 11 |
# File 'lib/conflow_spec/matchers/run_job.rb', line 9 def flow @flow end |
#job_class ⇒ Object (readonly)
Returns the value of attribute job_class.
9 10 11 |
# File 'lib/conflow_spec/matchers/run_job.rb', line 9 def job_class @job_class end |
Instance Method Details
#description ⇒ Object
Description of the spec
51 52 53 54 55 56 57 |
# File 'lib/conflow_spec/matchers/run_job.rb', line 51 def description [ "run job #{job_class}", expected_params && "with parameters #{expected_params}", times_text(@times) ].compact.join(" ") end |
#failure_message ⇒ Object
Error message when matcher returns false, but it was expected to return true
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/conflow_spec/matchers/run_job.rb', line 69 def [ "Expected flow to", description, "but", if relevant_jobs.size.zero? run_with_different_params? ? "it was not run with those parameters" : "it was not run at all" elsif relevant_jobs != @times "it was run #{times_text(relevant_jobs.size)}" end ].join(" ") end |
#failure_message_when_negated ⇒ Object
Error message when matcher returns true, but it was expected to return false
60 61 62 63 64 65 66 |
# File 'lib/conflow_spec/matchers/run_job.rb', line 60 def [ "Expected flow to not", description, "but it did" ].join(" ") end |
#matches?(flow) ⇒ Boolean
Returns true if all requirements are fulfilled.
19 20 21 22 23 |
# File 'lib/conflow_spec/matchers/run_job.rb', line 19 def matches?(flow) @flow = flow relevant_jobs.size == @times end |
#times(num) ⇒ Object
Specifies how many times job should be run
45 46 47 48 |
# File 'lib/conflow_spec/matchers/run_job.rb', line 45 def times(num) @times = num self end |
#twice ⇒ Object
Convinience method to specify job should be enqueued twice
36 37 38 39 |
# File 'lib/conflow_spec/matchers/run_job.rb', line 36 def twice @times = 2 self end |
#with_params(params) ⇒ Object
Specifies parameters that the job should be run with.
29 30 31 32 |
# File 'lib/conflow_spec/matchers/run_job.rb', line 29 def with_params(params) @expected_params = params self end |