Module: Trailblazer::Test::Helper::MockStep

Defined in:
lib/trailblazer/test/helper/mock_step.rb

Instance Method Summary collapse

Instance Method Details

#mock_step(activity, path:, &block) ⇒ Object

Raises:

  • (ArgumentError)


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/trailblazer/test/helper/mock_step.rb', line 4

def mock_step(activity, path:, &block)
  raise ArgumentError, "Missing block: `#mock_step` requires a block." unless block_given?

  mocked_step_id, path = path.last, path[0..-2]

  mock_step = ->(ctx, **) { yield(ctx) }
  mock_instruction = -> { step mock_step, replace: mocked_step_id }


  Trailblazer::Activity::DSL::Linear::Patch.(activity, path, mock_instruction)
end