test/docs/wrap_test.rb in trailblazer-macro-2.1.0.rc1 vs test/docs/wrap_test.rb in trailblazer-macro-2.1.0.rc11
- old
+ new
@@ -28,11 +28,12 @@
step :rehash
}
step :notify
fail :log_error
#~methods
- include Test::Methods
+ include T.def_steps(:find_model, :update, :notify, :log_error)
+ include Rehash
#~methods end
end
#:wrap end
it { Memo::Create.( { seq: [] } ).inspect(:seq).must_equal %{<Result:true [[:find_model, :update, :rehash, :notify]] >} }
@@ -74,10 +75,12 @@
class HandleUnsafeProcess
def self.call((ctx), *, &block)
begin
yield # calls the wrapped steps
rescue
+ puts $!
+ ctx[:exception] = $!.message
[ Trailblazer::Operation::Railway.fail!, [ctx, {}] ]
end
end
end
@@ -88,11 +91,12 @@
}, fail_fast: true
step :notify
fail :log_error
#~methods
- include Test::Methods
+ include T.def_steps(:find_model, :update, :notify, :log_error)
+ include Rehash
#~methods end
end
it { Memo::Create.( { seq: [] } ).inspect(:seq).must_equal %{<Result:true [[:find_model, :update, :rehash, :notify]] >} }
it { Memo::Create.( { seq: [], rehash_raise: true } ).inspect(:seq).must_equal %{<Result:false [[:find_model, :update, :rehash]] >} }
@@ -125,11 +129,12 @@
step :rehash
}, fast_track: true
step :notify
fail :log_error
#~methods
- include Test::Methods
+ include T.def_steps(:find_model, :update, :notify, :log_error)
+ include Rehash
#~methods end
end
#:fail-fast end
it { Memo::Create.( { seq: [] } ).inspect(:seq).must_equal %{<Result:true [[:find_model, :update, :rehash, :notify]] >} }
@@ -174,11 +179,12 @@
step :rehash
}
step :notify
fail :log_error
#~methods
- include Test::Methods
+ include T.def_steps(:find_model, :update, :notify, :log_error)
+ include Rehash
#~methods end
end
#:transaction end
it { Memo::Create.( { seq: [] } ).inspect(:seq).must_equal %{<Result:true [[:find_model, :update, :rehash, :notify]] >} }
@@ -217,11 +223,12 @@
Output(:success) => End(:transaction_worked),
Output(MyTransaction::MyFailSignal, :failure) => End(:transaction_failed)
step :notify
fail :log_error
#~methods
- include Test::Methods
+ include T.def_steps(:find_model, :update, :notify, :log_error)
+ include Rehash
#~methods end
end
#:custom end
it do
@@ -262,10 +269,11 @@
}
step :notify
fail :log_error
#~methods
- include Test::Methods
+ include T.def_steps(:find_model, :update, :notify, :log_error)
+ include Rehash
#~methods end
end
it { Memo::Create.( { seq: [] } ).inspect(:seq).must_equal %{<Result:true [[:find_model, :update, :rehash, :notify]] >} }
it { Memo::Create.( { seq: [], rehash_raise: true } ).inspect(:seq).must_equal %{<Result:true [[:find_model, :update, :rehash, :notify]] >} }