Module: Dynflow::Testing::Assertions
- Included in:
- Dynflow::Testing
- Defined in:
- lib/dynflow/testing/assertions.rb
Instance Method Summary collapse
-
#assert_action_planed(action, planned_action_class) ⇒ Object
assert that
assert_actioned_plan
was planned byaction
. -
#assert_action_planed_with(action, planned_action_class, *plan_input, &block) ⇒ Object
assert that
assert_actioned_plan
was planned byaction
with argumentsplan_input
alternatively plan-input can be asserted withblock
. -
#assert_finalize_phase(action) ⇒ Object
assert that
action
has finalize-phase planned. -
#assert_run_phase(action, input = nil, &block) ⇒ Object
assert that
action
has run-phase planned. - #refute_action_planed(action, planned_action_class) ⇒ Object
-
#refute_finalize_phase(action) ⇒ Object
refute that
action
has finalize-phase planned. -
#refute_run_phase(action) ⇒ Object
refute that
action
has run-phase planned.
Instance Method Details
#assert_action_planed(action, planned_action_class) ⇒ Object
assert that assert_actioned_plan
was planned by action
23 24 25 26 27 28 29 30 31 |
# File 'lib/dynflow/testing/assertions.rb', line 23 def assert_action_planed(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 |
#assert_action_planed_with(action, planned_action_class, *plan_input, &block) ⇒ Object
assert that assert_actioned_plan
was planned by action
with arguments plan_input
alternatively plan-input can be asserted with block
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dynflow/testing/assertions.rb', line 6 def assert_action_planed_with(action, planned_action_class, *plan_input, &block) found_classes = assert_action_planed(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 |
#assert_finalize_phase(action) ⇒ Object
assert that action
has finalize-phase planned
60 61 62 63 64 |
# File 'lib/dynflow/testing/assertions.rb', line 60 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) ⇒ Object
assert that action
has run-phase planned
44 45 46 47 48 49 50 |
# File 'lib/dynflow/testing/assertions.rb', line 44 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 input.stringify_keys if input block.call action.input if block end |
#refute_action_planed(action, planned_action_class) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/dynflow/testing/assertions.rb', line 33 def refute_action_planed(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 |
#refute_finalize_phase(action) ⇒ Object
refute that action
has finalize-phase planned
67 68 69 70 71 |
# File 'lib/dynflow/testing/assertions.rb', line 67 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) ⇒ Object
refute that action
has run-phase planned
53 54 55 56 57 |
# File 'lib/dynflow/testing/assertions.rb', line 53 def refute_run_phase(action) Match! action.phase, Action::Plan Match! action.state, :success action.execution_plan.planned_run_steps.wont_include action end |