Module: Trailblazer::Activity::Testing::Assertions
- Defined in:
- lib/trailblazer/activity/testing.rb
Defined Under Namespace
Modules: Implementing
Constant Summary collapse
- Activity =
Trailblazer::Activity
- Inter =
Trailblazer::Activity::Schema::Intermediate
- Schema =
Trailblazer::Activity::Schema
- TaskWrap =
Trailblazer::Activity::TaskWrap
Instance Method Summary collapse
- #assert_circuit(schema, circuit) ⇒ Object
-
#assert_process_for(process, *args) ⇒ Object
Tests :circuit and :outputs fields so far.
- #Cct(activity) ⇒ Object
- #flat_activity ⇒ Object (also: #bc)
-
#implementing ⇒ Object
TODO: Remove this once all it’s references are removed.
- #nested_activity ⇒ Object (also: #bde)
Instance Method Details
#assert_circuit(schema, circuit) ⇒ Object
144 145 146 147 148 |
# File 'lib/trailblazer/activity/testing.rb', line 144 def assert_circuit(schema, circuit) cct = Cct(schema) cct = cct.gsub("#<Trailblazer::Activity::TaskBuilder::Task user_proc=", "<*") assert_equal %{#{circuit}}, cct end |
#assert_process_for(process, *args) ⇒ Object
Tests :circuit and :outputs fields so far.
132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/trailblazer/activity/testing.rb', line 132 def assert_process_for(process, *args) semantics, circuit = args[0..-2], args[-1] inspects = semantics.collect { |semantic| %{#<struct Trailblazer::Activity::Output signal=#<Trailblazer::Activity::End semantic=#{semantic.inspect}>, semantic=#{semantic.inspect}>} } assert_equal %{[#{inspects.join(", ")}]}, process.to_h[:outputs].inspect assert_circuit(process, circuit) process end |
#Cct(activity) ⇒ Object
65 66 67 |
# File 'lib/trailblazer/activity/testing.rb', line 65 def Cct(activity) Trailblazer::Developer::Render::Circuit.(activity) end |
#flat_activity ⇒ Object Also known as: bc
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/trailblazer/activity/testing.rb', line 74 def flat_activity return @_flat_activity if defined?(@_flat_activity) intermediate = Inter.new( { Inter::TaskRef("Start.default") => [Inter::Out(:success, :B)], Inter::TaskRef(:B, additional: true) => [Inter::Out(:success, :C)], Inter::TaskRef(:C) => [Inter::Out(:success, "End.success")], Inter::TaskRef("End.success", stop_event: true) => [Inter::Out(:success, nil)] }, ["End.success"], ["Start.default"], # start ) implementation = { "Start.default" => Schema::Implementation::Task(st = Implementing::Start, [Activity::Output(Activity::Right, :success)], []), :B => Schema::Implementation::Task(b = Implementing.method(:b), [Activity::Output(Activity::Right, :success)], []), :C => Schema::Implementation::Task(c = Implementing.method(:c), [Activity::Output(Activity::Right, :success)], []), "End.success" => Schema::Implementation::Task(_es = Implementing::Success, [Activity::Output(Implementing::Success, :success)], []), # DISCUSS: End has one Output, signal is itself? } schema = Inter.(intermediate, implementation) @_flat_activity = Activity.new(schema) end |
#implementing ⇒ Object
TODO: Remove this once all it’s references are removed
70 71 72 |
# File 'lib/trailblazer/activity/testing.rb', line 70 def implementing Implementing end |
#nested_activity ⇒ Object Also known as: bde
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/trailblazer/activity/testing.rb', line 100 def nested_activity return @_nested_activity if defined?(@_nested_activity) intermediate = Inter.new( { Inter::TaskRef("Start.default") => [Inter::Out(:success, :B)], Inter::TaskRef(:B, more: true) => [Inter::Out(:success, :D)], Inter::TaskRef(:D) => [Inter::Out(:success, :E)], Inter::TaskRef(:E) => [Inter::Out(:success, "End.success")], Inter::TaskRef("End.success", stop_event: true) => [Inter::Out(:success, nil)] }, ["End.success"], ["Start.default"] # start ) implementation = { "Start.default" => Schema::Implementation::Task(st = Implementing::Start, [Activity::Output(Activity::Right, :success)], []), :B => Schema::Implementation::Task(b = Implementing.method(:b), [Activity::Output(Activity::Right, :success)], []), :D => Schema::Implementation::Task(c = bc, [Activity::Output(Implementing::Success, :success)], []), :E => Schema::Implementation::Task(e = Implementing.method(:f), [Activity::Output(Activity::Right, :success)], []), "End.success" => Schema::Implementation::Task(_es = Implementing::Success, [Activity::Output(Implementing::Success, :success)], []), # DISCUSS: End has one Output, signal is itself? } schema = Inter.(intermediate, implementation) @_nested_activity = Activity.new(schema) end |