Module: ConflowSpec::FlowContext
- Extended by:
- RSpec::SharedContext
- Defined in:
- lib/conflow_spec/flow_context.rb
Overview
In test flows jobs will not be performed - it only tests if the jobs were enqueued with proper parameters
Defines context of the spec
-
changes Conflow::Flow class to queue jobs into special test queue
-
defines worker which collects informations about jobs to be performed
Defined Under Namespace
Classes: JobProductStruct
Instance Method Summary collapse
-
#_conflow_spec_queue ⇒ Object
private
Queue which collects queued jobs.
-
#_conflow_spec_test_class ⇒ Object
private
Subclass of a described class with overriden queueing logic.
-
#_conflow_spec_test_instance ⇒ Object
private
Instance of the TestFlow.
-
#allow_job(job_class, params = nil) ⇒ Object
Allows to define returned value by a job (which then can be user by hook attached to the job itself).
-
#produce(result) ⇒ Object
Defines value returned by given job.
Instance Method Details
#_conflow_spec_queue ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Queue which collects queued jobs
70 71 72 |
# File 'lib/conflow_spec/flow_context.rb', line 70 def _conflow_spec_queue @_conflow_spec_queue ||= Thread::Queue.new end |
#_conflow_spec_test_class ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Subclass of a described class with overriden queueing logic
63 64 65 |
# File 'lib/conflow_spec/flow_context.rb', line 63 def _conflow_spec_test_class @_conflow_spec_test_class ||= ConflowSpec::TestFlow.build(described_class, _conflow_spec_queue) end |
#_conflow_spec_test_instance ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Instance of the TestFlow
56 57 58 |
# File 'lib/conflow_spec/flow_context.rb', line 56 def _conflow_spec_test_instance @_conflow_spec_test_instance ||= _conflow_spec_test_class.new end |
#allow_job(job_class, params = nil) ⇒ Object
Allows to define returned value by a job (which then can be user by hook attached to the job itself).
41 42 43 44 45 |
# File 'lib/conflow_spec/flow_context.rb', line 41 def allow_job(job_class, params = nil) JobProductStruct.new(job_class, params).tap do |struct| _conflow_spec_test_instance._conflow_spec_returns << struct end end |
#produce(result) ⇒ Object
Defines value returned by given job
49 50 51 |
# File 'lib/conflow_spec/flow_context.rb', line 49 def produce(result) result end |