To make my test failures more meaningful when asserting result.success?, I'd like to throw an error when ctx.fail! is called in my test environment. I believe this is best done by adding a callback/hook to an orchestrator that would run when the orchestrator fails. I'm opening this issue to present an idea of how that could work, and welcome people to discuss it (and then I'd be glad to implement it).
Would we rather have something naive like this:
class CalculatesTax
extend LightService::Organizer
def self.call(order)
with(:order => order).reduce(
LooksUpTaxPercentageAction,
CalculatesOrderTaxAction,
ProvidesFreeShippingAction
)
end
def self.after_fail
# Do something
end
end
or something a bit more like Active Record does callbacks, like this:
class CalculatesTax
extend LightService::Organizer
after_fail :do_something
def self.call(order)
with(:order => order).reduce(
LooksUpTaxPercentageAction,
CalculatesOrderTaxAction,
ProvidesFreeShippingAction
)
end
def self.do_something
# Do something
end
end
I'm not sure a given orchestrator is likely to have as many reasons to stack several same-type callbacks on top of each other, so I'm not sure anything beyond the naive solution is needed; but I'd welcome people's take about it.
To make my test failures more meaningful when asserting
result.success?
, I'd like to throw an error whenctx.fail!
is called in my test environment. I believe this is best done by adding a callback/hook to an orchestrator that would run when the orchestrator fails. I'm opening this issue to present an idea of how that could work, and welcome people to discuss it (and then I'd be glad to implement it).Would we rather have something naive like this:
or something a bit more like Active Record does callbacks, like this:
I'm not sure a given orchestrator is likely to have as many reasons to stack several same-type callbacks on top of each other, so I'm not sure anything beyond the naive solution is needed; but I'd welcome people's take about it.