Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify relationship between different method stub actions.
In 2.13.0 only `and_yield` and `and_return` could be combined, since that was the only combination case that was specified by an example. This was a regression, as reported by a user in #230. I tried here to fully specify all of the various combinations of stub actions. Notes: * `and_return`, `and_raise` and `and_throw` are "terminal" actions in the sense that they terminate the method. They _must_ happen last and it is impossible to support more than one of these. Hence, we allow only one of these, and allow them to be overridden. We also return `nil` from these methods to discourage further stub configuration. * `and_call_original` is a special case that doesn't make sense to be combined with any of the others. Once you've set it up, this causes any further instructions to raise an error. * `and_yield` is treated as an "initial" action. Yielding doesn't exit a method the way the terminal actions do. It is the only initial action. Calling it multiple times sets up multiple yields. * Setting a block implementation (possible by passing a block to almost any method on the fluent interface) sets the block as the "inner" action. It runs between the configured yields (if there are any) and the configured terminal action (if there is one). My thinking here is that in many cases, users use a block implementation to specify a return value, essentially making it like a terminal action (so it should come after the `and_yield` actions), but in other cases, the user may just use a block for a side effect, and may configure an terminal action as well. Only one block implementation is supported and it can be overridden.
- Loading branch information
1 parent
727a9a4
commit f41cfcb
Showing
3 changed files
with
283 additions
and
37 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
Oops, something went wrong.