Repository navigation
v1.5.0
Typed outcomes (decision D23). Opt-in with typed_outcomes: an action that
doesn't turn it on runs as before, except that a code whose fails or skips
declaration carries a block (new syntax) has its output validated.
Added
typed_outcomesturns typed outcomes on for an action and its
descendants (typed_outcomes enabled: falseturns them off for a subclass);
typed_outcomes?reads it.- A block on
fails/skipsdeclares the output a result with that code
carries, in theoutputDSL.failure_output_schema(code)and
skip_output_schema(code)read it back, anddescribeshows its fields.
Such output is built from the call's keywords alone, never from instance
variables, and validated: output that breaks the schema ends the run as
invalid_output. The block also ends instance-variable capture for that
code, typed outcomes or not. output:onfail/fail!/fail_with/fail_with!, under typed
outcomes only: the failure's output, a Hash or a FieldStruct
(ArgumentErrorotherwise). Without themoutput:onfailis still an
error, andfail_withrefuses it. Under typed outcomes, output for a code
with no schema raisesDefinitionError, naming the code.- Per-action result classes. Under typed outcomes
.runreturns the
action's ownSuccess,FailureorSkipped, each a subclass of the gem
class (or of the parent action's own). A nested failure becomes the parent's
ownFailure, judged by the parent's schema for its code; a parent without
typed outcomes gets a plainActionable::Failure. The RSpec stub helpers
return them too, with output shaped through the code's schema (or empty
without one) as a real run would. - RBS:
Actionable::RBS.generatetypes a typed action's.runas
(Success | Skipped | Failure), with eachcodeandoutputnarrowed and
the output's readers declared on each class. A host's own result subclass,
which.runstill returns as it is, is not described: a known gap.
Changed
- Under typed outcomes, a skip or failure whose code has no schema carries an
empty output, where it used to carry a best-effort capture into the success
schema. The gem's owninvalid_input/invalid_outputkeep theirs. - Under typed outcomes, results compare by class:
Act::Successis not==
to anActionable::Successwith the same output, and the stub helpers
return a new object of the action's own class. Specs that compare results
with==need to compare against the action's class.