Module: ConflowSpec::TestFlow Private

Defined in:
lib/conflow_spec/test_flow.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Module which, when included, will override logic of queueing jobs.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(flow_class, queue) ⇒ Class

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.

Creates new class which behaves like flow_class (class being tested), but with overriden logic of queueing jobs.

Examples:

flow = ConflowSpec::TestFlow.build(MyFlow, job_queue).new
flow.is_a?(MyFlow) #=> true
flow.name #=> MyFlow

Parameters:

  • flow_class (Class)

    Described class

  • queue (Thread::Queue)

    Queue to which jobs should be pushed

Returns:

  • (Class)

    Class with changed queueing logic



17
18
19
20
21
22
23
# File 'lib/conflow_spec/test_flow.rb', line 17

def build(flow_class, queue)
  Class.new(flow_class).tap do |test_class|
    test_class.prepend(self)
    test_class.name = flow_class.name
    test_class.queue = queue
  end
end

.prepended(base) ⇒ 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.

Adds name and queue attributes on test class



26
27
28
29
30
# File 'lib/conflow_spec/test_flow.rb', line 26

def prepended(base)
  base.singleton_class.instance_exec do
    attr_accessor :name, :queue
  end
end

Instance Method Details

#_conflow_spec_returnsObject

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.

Set of return values of jobs



40
41
42
# File 'lib/conflow_spec/test_flow.rb', line 40

def _conflow_spec_returns
  @_conflow_spec_returns ||= Set.new
end

#queue(job) ⇒ 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.

Queues job pushing it to a Thread::Queue



34
35
36
# File 'lib/conflow_spec/test_flow.rb', line 34

def queue(job)
  self.class.queue << job
end