Module: Dynflow::Testing::Factories
- Includes:
- Algebrick::TypeCheck
- Included in:
- Dynflow::Testing
- Defined in:
- lib/dynflow/testing/factories.rb
Instance Method Summary collapse
- #create_action(action_class, trigger = nil) ⇒ Action::PlanPhase
- #create_action_presentation(action_class) ⇒ Object
- #create_and_plan_action(action_class, *args, &block) ⇒ Object
- #finalize_action(run_action, &stubbing) ⇒ Action::FinalizePhase
- #plan_action(plan_action, *args, &block) ⇒ Action::PlanPhase
- #plan_events(world, delayed_events) ⇒ Object
- #progress_action_time(action) ⇒ Object
- #run_action(plan_action, event = nil, &stubbing) ⇒ Action::RunPhase
Instance Method Details
#create_action(action_class, trigger = nil) ⇒ Action::PlanPhase
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dynflow/testing/factories.rb', line 9 def create_action(action_class, trigger = nil) execution_plan = DummyExecutionPlan.new step = DummyStep.new action_class.new( { step: DummyStep.new, execution_plan_id: execution_plan.id, id: Testing.get_id, phase: Action::Plan, plan_step_id: step.id, run_step_id: nil, finalize_step_id: nil }, execution_plan.world ).tap do |action| action.set_plan_context(execution_plan, trigger, false) end end |
#create_action_presentation(action_class) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dynflow/testing/factories.rb', line 26 def create_action_presentation(action_class) execution_plan = DummyExecutionPlan.new action_class.new( { execution_plan: execution_plan, execution_plan_id: execution_plan.id, id: Testing.get_id, phase: Action::Present, plan_step_id: 1, run_step_id: nil, finalize_step_id: nil, input: nil }, execution_plan.world ) end |
#create_and_plan_action(action_class, *args, &block) ⇒ Object
50 51 52 |
# File 'lib/dynflow/testing/factories.rb', line 50 def create_and_plan_action(action_class, *args, &block) plan_action create_action(action_class), *args, &block end |
#finalize_action(run_action, &stubbing) ⇒ Action::FinalizePhase
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/dynflow/testing/factories.rb', line 88 def finalize_action(run_action, &stubbing) Match! run_action.phase, Action::Plan, Action::Run step = DummyStep.new finalize_action = run_action.class.new( { step: step, execution_plan_id: run_action.execution_plan_id, id: run_action.id, plan_step_id: run_action.plan_step_id, run_step_id: run_action.run_step_id, finalize_step_id: step.id, phase: Action::Finalize, input: run_action.input }, run_action.world ) stubbing.call finalize_action if stubbing finalize_action.execute finalize_action end |
#plan_action(plan_action, *args, &block) ⇒ Action::PlanPhase
42 43 44 45 46 47 48 |
# File 'lib/dynflow/testing/factories.rb', line 42 def plan_action(plan_action, *args, &block) Match! plan_action.phase, Action::Plan plan_action.execute(*args, &block) raise plan_action.error if plan_action.error plan_action end |
#plan_events(world, delayed_events) ⇒ Object
54 55 56 |
# File 'lib/dynflow/testing/factories.rb', line 54 def plan_events(world, delayed_events) delayed_events.each { |event| world.plan_event(event.execution_plan_id, event.step_id, event.event, event.time) } end |
#progress_action_time(action) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/dynflow/testing/factories.rb', line 108 def progress_action_time(action) Match! action.phase, Action::Run if action.world.clock.progress return action.world.executor.progress end end |
#run_action(plan_action, event = nil, &stubbing) ⇒ Action::RunPhase
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/dynflow/testing/factories.rb', line 59 def run_action(plan_action, event = nil, &stubbing) Match! plan_action.phase, Action::Plan, Action::Run step = DummyStep.new run_action = if plan_action.phase == Action::Plan plan_action.class.new( { step: step, execution_plan_id: plan_action.execution_plan_id, id: plan_action.id, plan_step_id: plan_action.plan_step_id, run_step_id: step.id, finalize_step_id: nil, phase: Action::Run, input: plan_action.input }, plan_action.world ) else plan_action end run_action.world.action ||= run_action run_action.world.clock.clear stubbing.call run_action if stubbing run_action.world.executor.execute(run_action, event) raise run_action.error if run_action.error run_action end |