Module: Trailblazer::Activity::Testing::Assertions
- Defined in:
- lib/trailblazer/activity/testing.rb
Instance Method Summary collapse
-
#assert_call(activity, terminus: :success, seq: "[]", expected_ctx_variables: {}, **ctx_variables) ⇒ Object
‘:seq` is always passed into ctx.
- #assert_call_for(signal, ctx, terminus: :success, seq: "[]", **ctx_variables) ⇒ Object
- #assert_circuit(schema, circuit) ⇒ Object
-
#assert_invoke(activity, terminus: :success, seq: "[]", circuit_options: {}, flow_options: {}, expected_ctx_variables: {}, **ctx_variables) ⇒ Object
Use Trailblazer::Activity::TaskWrap.invoke to call the activity.
-
#assert_process_for(process, *args) ⇒ Object
(also: #assert_process)
Tests :circuit and :outputs fields so far.
- #Cct(activity) ⇒ Object
Instance Method Details
#assert_call(activity, terminus: :success, seq: "[]", expected_ctx_variables: {}, **ctx_variables) ⇒ Object
‘:seq` is always passed into ctx.
50 51 52 53 54 55 |
# File 'lib/trailblazer/activity/testing.rb', line 50 def assert_call(activity, terminus: :success, seq: "[]", expected_ctx_variables: {}, **ctx_variables) # Call without taskWrap! signal, (ctx, _) = activity.([{seq: [], **ctx_variables}, = {}]) # simply call the activity with the input you want to assert. assert_call_for(signal, ctx, terminus: terminus, seq: seq, **expected_ctx_variables, **ctx_variables) end |
#assert_call_for(signal, ctx, terminus: :success, seq: "[]", **ctx_variables) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/trailblazer/activity/testing.rb', line 73 def assert_call_for(signal, ctx, terminus: :success, seq: "[]", **ctx_variables) assert_equal signal.to_h[:semantic], terminus, "assert_call expected #{terminus} terminus, not #{signal}. Use assert_call(activity, terminus: #{signal.to_h[:semantic].inspect})" assert_equal ctx.inspect, {seq: "%%%"}.merge(ctx_variables).inspect.sub('"%%%"', seq) return ctx end |
#assert_circuit(schema, circuit) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/trailblazer/activity/testing.rb', line 94 def assert_circuit(schema, circuit) cct = Cct(schema) cct = cct.gsub("#<Trailblazer::Activity::TaskBuilder::Task user_proc=", "<*") assert_equal circuit.to_s, cct end |
#assert_invoke(activity, terminus: :success, seq: "[]", circuit_options: {}, flow_options: {}, expected_ctx_variables: {}, **ctx_variables) ⇒ Object
Use Trailblazer::Activity::TaskWrap.invoke to call the activity.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/trailblazer/activity/testing.rb', line 58 def assert_invoke(activity, terminus: :success, seq: "[]", circuit_options: {}, flow_options: {}, expected_ctx_variables: {}, **ctx_variables) signal, (ctx, ) = Activity::TaskWrap.invoke( activity, [ {seq: [], **ctx_variables}, , ], ** ) assert_call_for(signal, ctx, terminus: terminus, seq: seq, **ctx_variables, **expected_ctx_variables) # DISCUSS: ordering of variables? return signal, [ctx, ] end |
#assert_process_for(process, *args) ⇒ Object Also known as: assert_process
Tests :circuit and :outputs fields so far.
82 83 84 85 86 87 88 89 90 |
# File 'lib/trailblazer/activity/testing.rb', line 82 def assert_process_for(process, *args) semantics, circuit = args[0..-2], args[-1] assert_equal semantics.sort, process.to_h[:outputs].collect { |output| output[:semantic] }.sort assert_circuit(process, circuit) process end |
#Cct(activity) ⇒ Object
101 102 103 |
# File 'lib/trailblazer/activity/testing.rb', line 101 def Cct(activity) Activity::Introspect::Render.(activity, inspect_task: Trailblazer::Activity::Testing.method(:render_task)) end |