module Rworkflow::Minitest::Test

Include in your test classes to add functionality for worker and workflow tests

Public Instance Methods

rworkflow_worker(worker_class, flow: ::SidekiqFlow, name: nil, meta: {}) { |workflow| ... } click to toggle source

@params [Class] the worker class to instantiate @params [Hash] options hash @option [Class] :flow workflow class to instantiate; defaults to SidekiqFlow @option [Class] :name the state name

# File lib/rworkflow/minitest/test.rb, line 25
def rworkflow_worker(worker_class, flow: ::SidekiqFlow, name: nil, meta: {})
  name ||= worker_class.name
  worker = worker_class.new
  workflow = flow.new(name)
  meta.each { |key, value| workflow.set(key, value) }

  worker.instance_variable_set(:@workflow, workflow)
  worker.instance_variable_set(:@state_name, name)

  workflow.extend(WorkerUnitTestFlow)
  if defined?(flexmock)
    flexmock(workflow.class).should_receive(:terminal?).and_return(true)
  end

  yield(workflow) if block_given?

  return worker, workflow
end
setup() click to toggle source
Calls superclass method
# File lib/rworkflow/minitest/test.rb, line 5
def setup
  super
  rworkflow_setup
end
teardown() click to toggle source
Calls superclass method
# File lib/rworkflow/minitest/test.rb, line 10
def teardown
  super
  rworkflow_teardown
end

Protected Instance Methods

rworkflow_setup() click to toggle source
# File lib/rworkflow/minitest/test.rb, line 15
def rworkflow_setup; end
rworkflow_teardown() click to toggle source
# File lib/rworkflow/minitest/test.rb, line 18
def rworkflow_teardown; end