add `RuleBuilder::then_compute_output` (#4299)
this allows the developer to compute a mocked output using content from
the input.
## Motivation and Context
Some richer use cases for stubbing/mocking require computing a stubbed
output using data from the input, for instance stubbing a method that
returns the item that was put.
## Description
Add a new method to `RuleBuilder` that allows for providing a function
that computes the output. That function takes in a reference to the
input as an argument. I'm not sure how this works with the mutable
inputs like streamed bytes, but seems to work for the simple stuff.
## Testing
added a simple unit test
----
_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
---------
Co-authored-by:
Aaron Todd <aajtodd@users.noreply.github.com>
Loading
Please sign in to comment