Skip to content

Commit

Permalink
subprocess docs tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Nov 20, 2023
1 parent c585e76 commit f0a78fa
Showing 1 changed file with 36 additions and 30 deletions.
66 changes: 36 additions & 30 deletions test/docs/subprocess_test.rb
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
require "test_helper"

class SubprocessTest < Minitest::Spec
it do
module A
Memo = Class.new

#:nested
class Memo::Validate < Trailblazer::Activity::Railway
step :check_params
step :check_attributes
#~methods
include T.def_steps(:check_params, :check_attributes)
#~methods end
end
#:nested end

#:container
class Memo::Create < Trailblazer::Activity::Railway
step :create_model
step Subprocess(Memo::Validate)
step :save
#~methods
include T.def_steps(:create_model, :save)
#~methods
end
#:container end

class SubprocessDocsTest < Minitest::Spec
Memo = Class.new
#:nested
module Memo::Activity
class Validate < Trailblazer::Activity::Railway
step :check_params
step :text_present?
#~meths
include T.def_steps(:check_params, :text_present?)
#~meths end
end
end
#:nested end

#:container
module Memo::Activity
class Create < Trailblazer::Activity::Railway
step Subprocess(Validate)
step :save
left :handle_errors
step :notify
#~meths
include T.def_steps(:validate, :save, :handle_errors, :notify)
#~meths end
end
end
#:container end

_signal, (ctx, _) = A::Memo::Create.([{seq: []}, {}])
_(ctx.inspect).must_equal %{{:seq=>[:create_model, :check_params, :check_attributes, :save]}}
it "what" do
assert_invoke Memo::Activity::Create, seq: "[:check_params, :text_present?, :save, :notify]"
assert_invoke Memo::Activity::Create, seq: "[:check_params, :text_present?, :save, :handle_errors]", save: false, terminus: :failure
assert_invoke Memo::Activity::Create, seq: "[:check_params, :text_present?, :handle_errors]", text_present?: false, terminus: :failure
assert_invoke Memo::Activity::Create, seq: "[:check_params, :handle_errors]", check_params: false, terminus: :failure
end
end

_signal, (ctx, _) = A::Memo::Create.([{seq: [], check_params: false}, {}])
_(ctx.inspect).must_equal %{{:seq=>[:create_model, :check_params], :check_params=>false}}

class SubprocessTest < Minitest::Spec
it do

module B
Memo = Class.new
Expand Down

0 comments on commit f0a78fa

Please sign in to comment.