-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Test::Endpoint to allow a "global" invocation method for the
entire test suite.
- Loading branch information
Showing
2 changed files
with
55 additions
and
29 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,42 @@ | ||
module Trailblazer | ||
module Test | ||
# DISCUSS: this is not really endpoint related, it's more like setting a "global" invocation mechanism. | ||
module Endpoint | ||
# DISCUSS: not sure this is the final "technique" to use the global endpoint invoker. | ||
def self.module(receiver, invoke_method:, invoke_method_wtf:) | ||
receiver.class_eval do | ||
@@INVOKE_METHOD = invoke_method | ||
@@INVOKE_METHOD_WTF = invoke_method_wtf | ||
|
||
def trailblazer_test_invoke_method | ||
@@INVOKE_METHOD | ||
end | ||
|
||
def trailblazer_test_invoke_method_wtf | ||
@@INVOKE_METHOD_WTF | ||
end | ||
end | ||
|
||
Assertion | ||
end | ||
|
||
module Assertion | ||
def assert_pass(*args, invoke: trailblazer_test_invoke_method, **options, &block) | ||
super(*args, **options, invoke: invoke, &block) | ||
end | ||
|
||
def assert_fail(*args, invoke: trailblazer_test_invoke_method, **options, &block) | ||
super(*args, **options, invoke: invoke, &block) | ||
end | ||
|
||
def assert_pass?(*args, **options, &block) | ||
assert_pass(*args, **options, invoke: trailblazer_test_invoke_method_wtf, &block) | ||
end | ||
|
||
def assert_fail?(*args, **options, &block) | ||
assert_fail(*args, **options, invoke: trailblazer_test_invoke_method_wtf, &block) | ||
end | ||
end | ||
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