-
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
1 changed file
with
112 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
require "test_helper" | ||
|
||
module Y | ||
class DocsMechanicsTest < Minitest::Spec | ||
Memo = Module.new | ||
it "what" do | ||
#:instance-method | ||
module Memo::Operation | ||
class Create < Trailblazer::Operation | ||
step :validate | ||
|
||
#~meths | ||
def validate(ctx, params:, **) | ||
params.key?(:memo) ? true : false # return value matters! | ||
end | ||
#~meths end | ||
end | ||
end | ||
#:instance-method end | ||
|
||
#:instance-method-call | ||
result = Memo::Operation::Create.call(params: {memo: nil}) | ||
#:instance-method-call end | ||
assert_equal result.success?, true | ||
|
||
#:instance-method-implicit-call | ||
result = Memo::Operation::Create.(params: {memo: nil}) | ||
#:instance-method-implicit-call end | ||
assert_equal result.success?, true | ||
end | ||
end | ||
end | ||
|
||
class Classmethod_DocsMechanicsTest < Minitest::Spec | ||
Memo = Module.new | ||
it "what" do | ||
#:class-method | ||
module Memo::Operation | ||
class Create < Trailblazer::Operation | ||
#~meths | ||
# Define {Memo::Operation::Create.validate} | ||
def self.validate(ctx, params:, **) | ||
params.key?(:memo) ? true : false # return value matters! | ||
end | ||
#~meths end | ||
|
||
step method(:validate) | ||
end | ||
end | ||
#:class-method end | ||
end | ||
end | ||
|
||
class Module_Classmethod_DocsMechanicsTest < Minitest::Spec | ||
Memo = Module.new | ||
it "what" do | ||
#:module-step | ||
# Reusable steps in a module. | ||
module Steps | ||
def self.validate(ctx, params:, **) | ||
params.key?(:memo) ? true : false # return value matters! | ||
end | ||
end | ||
#:module-step end | ||
|
||
#:module-method | ||
module Memo::Operation | ||
class Create < Trailblazer::Operation | ||
step Steps.method(:validate) | ||
end | ||
end | ||
#:module-method end | ||
end | ||
end | ||
|
||
class Callable_DocsMechanicsTest < Minitest::Spec | ||
Memo = Module.new | ||
it "what" do | ||
#:callable-step | ||
module Validate | ||
def self.call(ctx, params:, **) | ||
valid?(params) ? true : false # return value matters! | ||
end | ||
|
||
def valid?(params) | ||
params.key?(:memo) | ||
end | ||
end | ||
#:callable-step end | ||
|
||
#:callable-method | ||
module Memo::Operation | ||
class Create < Trailblazer::Operation | ||
step Validate | ||
end | ||
end | ||
#:callable-method end | ||
end | ||
end | ||
|
||
class Lambda_DocsMechanicsTest < Minitest::Spec | ||
Memo = Module.new | ||
it "what" do | ||
#:lambda-step | ||
module Memo::Operation | ||
class Create < Trailblazer::Operation | ||
step ->(ctx, params:, **) { p params.inspect } | ||
end | ||
end | ||
#:lambda-step end | ||
end | ||
end |