trailblazer-activity 0.14.0.beta1 → 0.14.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0b740043e917bb57207fc034770df1dd469e2eb3cea4e144ade7a111848078a
4
- data.tar.gz: 4865723a301ee81a48bfb0b377ac7e1020265493ad2e58529f75dacedea6bd91
3
+ metadata.gz: 5ea76d00d1fbeedcd5160134fff2223300697bd777fb58475fc8de2311c1a5ae
4
+ data.tar.gz: 833e2c3b9fae46af07f07a4422405e1b66606460425d39a8777b84cfed8a0518
5
5
  SHA512:
6
- metadata.gz: cdf5b9fe432c47797742ca3eb7854c408d8775cb8cd7637a4637c5e4df4596f0e9c78a56306aab1d6cb81e5d8eb55b2ff507f63fd0802c7d2a48c740135c6df4
7
- data.tar.gz: d8aee850340b23fc22b90bfd86553c3842e852e41b97f14f098bda2eb313a9be89284657422eb9164bbecd24db7b5640b9acca3c79dd32ff2ce3f04e580ee01a
6
+ metadata.gz: ff4c7f7bcd260b495348ba7286e18a60cc104d83ff176d5e82c3c80c22e23bc69cd73cb7976f3637e64b9067932651478b0538b9eaf6731ca793a31ac70e5535
7
+ data.tar.gz: 34c21e990a083a2a08f203f21304b0ad33ab3616450b285f7ddc4c90861c160c5c548e1ea3af92e4a4828df2f789324d21a0deb00aa1e67c07c8084654430c1f
data/CHANGES.md CHANGED
@@ -9,6 +9,7 @@
9
9
  * Rename `Activity::State::Config` to `Activity::Config`.
10
10
  * Move `VariableMapping` to the `trailblazer-activity-dsl-linear` gem.
11
11
  * Move `Pipeline.prepend` to the `trailblazer-activity-linear-dsl` gem.
12
+ * Add `Testing#assert_call` as a consistent test implementation. (0.14.0.beta2)
12
13
 
13
14
  # 0.13.0
14
15
 
@@ -54,16 +54,18 @@ module Trailblazer
54
54
  Schema = Trailblazer::Activity::Schema
55
55
  TaskWrap = Trailblazer::Activity::TaskWrap
56
56
 
57
+ # `:seq` is always passed into ctx.
57
58
  # @param :seq String What the {:seq} variable in the result ctx looks like. (expected seq)
58
- def assert_call(activity, terminus: :success, seq: "[]", **ctx_variables)
59
+ # @param :expected_ctx_variables Variables that are added during the call by the asserted activity.
60
+ def assert_call(activity, terminus: :success, seq: "[]", expected_ctx_variables: {}, **ctx_variables)
59
61
  # Call without taskWrap!
60
62
  signal, (ctx, _) = activity.([{seq: [], **ctx_variables}, _flow_options = {}]) # simply call the activity with the input you want to assert.
61
63
 
62
- assert_call_for(signal, ctx, terminus: terminus, seq: seq, **ctx_variables)
64
+ assert_call_for(signal, ctx, terminus: terminus, seq: seq, **expected_ctx_variables, **ctx_variables)
63
65
  end
64
66
 
65
67
  # Use {TaskWrap.invoke} to call the activity.
66
- def assert_invoke(activity, terminus: :success, seq: "[]", circuit_options: {}, **ctx_variables) # DISCUSS: only for {activity} gem?
68
+ def assert_invoke(activity, terminus: :success, seq: "[]", circuit_options: {}, expected_ctx_variables: {}, **ctx_variables) # DISCUSS: only for {activity} gem?
67
69
  signal, (ctx, _flow_options) = TaskWrap.invoke(
68
70
  activity,
69
71
  [
@@ -73,13 +75,15 @@ module Trailblazer
73
75
  **circuit_options
74
76
  )
75
77
 
76
- assert_call_for(signal, ctx, terminus: terminus, seq: seq, **ctx_variables)
78
+ assert_call_for(signal, ctx, terminus: terminus, seq: seq, **ctx_variables, **expected_ctx_variables) # DISCUSS: ordering of variables?
77
79
  end
78
80
 
79
81
  def assert_call_for(signal, ctx, terminus: :success, seq: "[]", **ctx_variables)
80
- assert_equal signal.to_h[:semantic], terminus, "assert_call expected #{terminus} terminus, not #{signal}. Use assert_call(activity, terminus: #{signal.to_h[:semantic]})"
82
+ assert_equal signal.to_h[:semantic], terminus, "assert_call expected #{terminus} terminus, not #{signal}. Use assert_call(activity, terminus: #{signal.to_h[:semantic].inspect})"
81
83
 
82
84
  assert_equal ctx.inspect, {seq: "%%%"}.merge(ctx_variables).inspect.sub('"%%%"', seq)
85
+
86
+ return ctx
83
87
  end
84
88
 
85
89
  module Implementing
@@ -95,25 +99,27 @@ module Trailblazer
95
99
  Implementing
96
100
  end
97
101
 
98
- def flat_activity
102
+ def flat_activity(implementing: Implementing)
99
103
  return @_flat_activity if defined?(@_flat_activity)
100
104
 
101
105
  intermediate = Inter.new(
102
106
  {
103
107
  Inter::TaskRef("Start.default") => [Inter::Out(:success, :B)],
104
- Inter::TaskRef(:B, additional: true) => [Inter::Out(:success, :C)],
108
+ Inter::TaskRef(:B, additional: true) => [Inter::Out(:success, :C), Inter::Out(:failure, "End.failure")],
105
109
  Inter::TaskRef(:C) => [Inter::Out(:success, "End.success")],
106
- Inter::TaskRef("End.success", stop_event: true) => [Inter::Out(:success, nil)]
110
+ Inter::TaskRef("End.success", stop_event: true) => [Inter::Out(:success, nil)],
111
+ Inter::TaskRef("End.failure", stop_event: true) => [Inter::Out(:failure, nil)],
107
112
  },
108
- ["End.success"],
113
+ ["End.success", "End.failure"],
109
114
  ["Start.default"], # start
110
115
  )
111
116
 
112
117
  implementation = {
113
118
  "Start.default" => Schema::Implementation::Task(st = Implementing::Start, [Activity::Output(Activity::Right, :success)], []),
114
- :B => Schema::Implementation::Task(b = Implementing.method(:b), [Activity::Output(Activity::Right, :success)], []),
115
- :C => Schema::Implementation::Task(c = Implementing.method(:c), [Activity::Output(Activity::Right, :success)], []),
119
+ :B => Schema::Implementation::Task(b = implementing.method(:b), [Activity::Output(Activity::Right, :success), Activity::Output(Activity::Left, :failure)], []),
120
+ :C => Schema::Implementation::Task(c = implementing.method(:c), [Activity::Output(Activity::Right, :success)], []),
116
121
  "End.success" => Schema::Implementation::Task(_es = Implementing::Success, [Activity::Output(Implementing::Success, :success)], []), # DISCUSS: End has one Output, signal is itself?
122
+ "End.failure" => Schema::Implementation::Task(Implementing::Failure, [Activity::Output(Implementing::Failure, :failure)], []), # DISCUSS: End has one Output, signal is itself?
117
123
  }
118
124
 
119
125
  schema = Inter.(intermediate, implementation)
@@ -1,7 +1,7 @@
1
1
  module Trailblazer
2
2
  module Version
3
3
  module Activity
4
- VERSION = '0.14.0.beta1'.freeze
4
+ VERSION = '0.14.0.beta2'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-activity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0.beta1
4
+ version: 0.14.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-19 00:00:00.000000000 Z
11
+ date: 2022-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trailblazer-context