test/docs/nested_test.rb in trailblazer-macro-2.1.5 vs test/docs/nested_test.rb in trailblazer-macro-2.1.6
- old
+ new
@@ -20,10 +20,15 @@
step :validate
# ... more steps ...
include T.def_steps(:validate)
end
+ class JsonValidate < Validate
+ step :json
+ include T.def_steps(:json)
+ end
+
it "Nested(Edit), without any options" do
module A
create =
#:nested
@@ -77,15 +82,10 @@
#~meths
include T.def_steps(:create, :save)
#~meths end
end
#:nested-dynamic end
-
- class JsonValidate < Validate
- step :json
- include T.def_steps(:json)
- end
# `edit` and `update` can be called from Nested()
# edit/success
create.(seq: [], params: {}).inspect(:seq).must_equal %{<Result:true [[:create, :validate, :save]] >}
@@ -117,15 +117,10 @@
include T.def_steps(:create, :save)
#~meths end
end
#:nested-dynamic end
- class JsonValidate < Validate
- step :json
- include T.def_steps(:json)
- end
-
# `edit` and `update` can be called from Nested()
end
C::Create.(seq: [], params: {}).inspect(:seq).must_equal %{<Result:true [[:create, :validate, :save]] >}
C::Create.(seq: [], params: nil).inspect(:seq).must_equal %{<Result:true [[:create, :validate, :json, :save]] >}
@@ -159,32 +154,37 @@
# pass fast
create.(seq: []).inspect(:seq).must_equal %{<Result:true [[:create, :just_pass_fast, :save]] >}
end
end
- let(:compute_edit) {
- ->(ctx, what:, **) { what }
- }
+ it "Nested(:method, auto_wire: *activities) with :pass_fast => End()" do
+ module E
+ class JsonValidate < Trailblazer::Operation
+ step :validate, Output(:success) => End(:json_validate)
+ include T.def_steps(:validate)
+ end
- it "Nested(:method), :pass_fast => :fail_fast doesn't work with standard wiring" do
- skip "we need to allow adding :outputs"
+ #:nested-with-auto-wire
+ class Create < Trailblazer::Operation
+ step :create
+ step Nested(:compute_nested, auto_wire: [Validate, JsonValidate]),
+ Output(:json_validate) => End(:jsoned)
- compute_edit = self.compute_edit
+ #~meths
+ def compute_nested(ctx, what:, **)
+ what
+ end
- pass_fast = Class.new(Trailblazer::Operation) do
- step :p, pass_fast: true
- include T.def_steps(:p)
- end
+ include T.def_steps(:create)
+ #~meths end
+ end
+ #:nested-with-auto-wire end
- create = Class.new(Trailblazer::Operation) do
- step :a
- step Nested(compute_edit, auto_wire: [pass_fast]), Output(:pass_fast) => Track(:fail_fast)
- step :b
- include T.def_steps(:a, :b)
- end
+ result = Create.(seq: [], what: JsonValidate)
-
- create.(seq: [], what: pass_fast).inspect(:seq).must_equal %{<Result:false [[:a, :c]] >}
+ result.inspect(:seq).must_equal %{<Result:false [[:create, :validate]] >}
+ result.event.inspect.must_equal %{#<Trailblazer::Activity::End semantic=:jsoned>}
+ end
end
end
# TODO: test with :input/:output, tracing