-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
require "test_helper" | ||
|
||
module A | ||
class DocsStepTest < Minitest::Spec | ||
Memo = Module.new | ||
|
||
#:railway | ||
module Memo::Operation | ||
class Create < Trailblazer::Operation | ||
step :validate | ||
step :save | ||
#~step | ||
left :handle_errors | ||
#~left | ||
step :notify | ||
#~meths | ||
# fail :log_error | ||
# step :save | ||
def validate(ctx, params:, **) | ||
ctx[:input] = Form.validate(params) # true/false | ||
end | ||
|
||
# def create(ctx, input:, create:, **) | ||
# create | ||
# end | ||
|
||
# def log_error(ctx, logger:, params:, **) | ||
# logger.error("wrong params: #{params.inspect}") | ||
# end | ||
#~meths end | ||
end | ||
end | ||
#~step end | ||
#~left end | ||
#:railway end | ||
|
||
# it "what" do | ||
# ctx = {params: {text: "Hydrate!"}, create: true} | ||
# signal, (ctx, _flow_options) = D::Create.([ctx, {}]) | ||
# end | ||
end | ||
end | ||
|
||
|
||
module B | ||
class DocsStepTest < Minitest::Spec | ||
Memo = Module.new | ||
|
||
#:fail | ||
module Memo::Operation | ||
class Create < Trailblazer::Operation | ||
step :validate | ||
step :save | ||
fail :handle_errors # just like {#left} | ||
#~meths | ||
step :notify | ||
include T.def_steps(:validate, :save, :handle_errors, :notify) | ||
#~meths end | ||
end | ||
end | ||
#:fail end | ||
|
||
it "what" do | ||
assert_invoke Memo::Operation::Create, seq: "[:validate, :save, :notify]" | ||
assert_invoke Memo::Operation::Create, validate: false, terminus: :failure, seq: "[:validate, :handle_errors]" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters