-
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.
rename
Result#event
to Result#terminus
for consistency.
deprecate `Result#event`.
- Loading branch information
Showing
2 changed files
with
51 additions
and
7 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,38 @@ | ||
require "test_helper" | ||
|
||
module A | ||
class DocsResultTest < Minitest::Spec | ||
Memo = Class.new | ||
module Memo::Operation | ||
class Create < Trailblazer::Operation | ||
step :validate, Output(:failure) => End(:validation_error) | ||
step :save | ||
include T.def_steps(:validate, :save) | ||
end | ||
end | ||
|
||
it "exposes {#terminus}" do | ||
result = Memo::Operation::Create.(seq: []) | ||
assert_equal result.terminus.to_h.inspect, %({:semantic=>:success}) | ||
|
||
result = Memo::Operation::Create.(validate: false, seq: []) | ||
assert_equal result.terminus.to_h.inspect, %({:semantic=>:validation_error}) | ||
|
||
result = Memo::Operation::Create.(save: false, seq: []) | ||
assert_equal result.terminus.to_h.inspect, %({:semantic=>:failure}) | ||
end | ||
|
||
it "deprecates Result#event" do | ||
result = Memo::Operation::Create.(seq: []) | ||
terminus = nil | ||
|
||
_, warning = capture_io do | ||
terminus = result.event | ||
end | ||
line_no = __LINE__ - 2 | ||
|
||
assert_equal warning, %{[Trailblazer] #{File.realpath(__FILE__)}:#{line_no} Using `Result#event` is deprecated, please use `Result#terminus`\n} | ||
assert_equal terminus.to_h.inspect, %({:semantic=>:success}) | ||
end | ||
end | ||
end |