Method: ConflowSpec::TestFlow.build

Defined in:
lib/conflow_spec/test_flow.rb

.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