module Dynflow::Testing::Assertions

Public Instance Methods

assert_action_planed(action, planned_action_class)
assert_action_planed_with(action, planned_action_class, *plan_input, &block)
assert_action_planned(action, planned_action_class) click to toggle source

assert that assert_actioned_plan was planned by action

# File lib/dynflow/testing/assertions.rb, line 25
def assert_action_planned(action, planned_action_class)
  Match! action.phase, Action::Plan
  Match! action.state, :success
  found = action.execution_plan.planned_plan_steps
                .select { |a| a.is_a?(planned_action_class) }

  assert(!found.empty?, "Action #{planned_action_class} was not planned")
  found
end
Also aliased as: assert_action_planed
assert_action_planned_with(action, planned_action_class, *plan_input, &block) click to toggle source

assert that assert_actioned_plan was planned by action with arguments plan_input alternatively plan-input can be asserted with block

# File lib/dynflow/testing/assertions.rb, line 8
def assert_action_planned_with(action, planned_action_class, *plan_input, &block)
  found_classes = assert_action_planned(action, planned_action_class)
  found         = found_classes.select do |a|
    if plan_input.empty?
      block.call a.plan_input
    else
      a.plan_input == plan_input
    end
  end

  assert(!found.empty?,
    "Action #{planned_action_class} with plan_input #{plan_input} was not planned, " +
        "there were only #{found_classes.map(&:plan_input)}")
  found
end
Also aliased as: assert_action_planed_with
assert_finalize_phase(action) click to toggle source

assert that action has finalize-phase planned

# File lib/dynflow/testing/assertions.rb, line 66
def assert_finalize_phase(action)
  Match! action.phase, Action::Plan
  Match! action.state, :success
  _(action.execution_plan.planned_finalize_steps).must_include action
end
assert_run_phase(action, input = nil, &block) click to toggle source

assert that action has run-phase planned

# File lib/dynflow/testing/assertions.rb, line 50
def assert_run_phase(action, input = nil, &block)
  Match! action.phase, Action::Plan
  Match! action.state, :success
  _(action.execution_plan.planned_run_steps).must_include action
  _(action.input).must_equal Utils.stringify_keys(input) if input
  block.call action.input if block
end
refute_action_planed(action, planned_action_class)
refute_action_planned(action, planned_action_class) click to toggle source
# File lib/dynflow/testing/assertions.rb, line 35
def refute_action_planned(action, planned_action_class)
  Match! action.phase, Action::Plan
  Match! action.state, :success
  found = action.execution_plan.planned_plan_steps
                .select { |a| a.is_a?(planned_action_class) }

  assert(found.empty?, "Action #{planned_action_class} was planned")
  found
end
Also aliased as: refute_action_planed
refute_finalize_phase(action) click to toggle source

refute that action has finalize-phase planned

# File lib/dynflow/testing/assertions.rb, line 73
def refute_finalize_phase(action)
  Match! action.phase, Action::Plan
  Match! action.state, :success
  _(action.execution_plan.planned_finalize_steps).wont_include action
end
refute_run_phase(action) click to toggle source

refute that action has run-phase planned

# File lib/dynflow/testing/assertions.rb, line 59
def refute_run_phase(action)
  Match! action.phase, Action::Plan
  Match! action.state, :success
  _(action.execution_plan.planned_run_steps).wont_include action
end