fix(doubles): the misuse advice must name a helper that exists - #1230
Merged
Conversation
Passing a quoted command line where a name belongs reported "is not a usable command name for mock; pass arguments after it, as in 'mock ls -l'". A bare `mock` is `command not found` -- the rule this API's docs stress hardest -- so following the advice got the reader nowhere. The example was wrong for every caller too: spy takes a single name, `mock ls -l` means "mock ls with -l as the body", and mock_sequence expects answers rather than arguments. The real mistake is quoting a command line as the name, so the advice is now to name the command alone; mock already forwards the call's own arguments to the replacement. Run the recommended form in the tests rather than only string-matching the message, since string-matching is what let this survive. Those tests assert on behaviour, not on captured output: under --simple the rendered failure is a one-character marker. Closes #1229
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 Background
Related #1229
Passing a quoted command line where a command name belongs reported
is not a usable command name for mock; pass arguments after it, as in 'mock ls -l'. A baremockiscommand not found— the rule this API's docs stress hardest — so following the advice got the reader nowhere.The example was wrong for each caller as well:
bashunit::spytakes a single name,bashunit::mock ls -lmeans "mocklswith-las the replacement body", andbashunit::mock_sequenceexpects answers rather than arguments.💡 Changes
mockalready forwards the call's own arguments to the replacementmocksurvive--simplethe rendered failure is a one-character marker, which the first attempt tripped over