Skip to content

fix(doubles): the misuse advice must name a helper that exists - #1230

Merged
Chemaclass merged 1 commit into
mainfrom
fix/1229-mock-advice-namespace
Aug 14, 2026
Merged

fix(doubles): the misuse advice must name a helper that exists#1230
Chemaclass merged 1 commit into
mainfrom
fix/1229-mock-advice-namespace

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 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 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 each caller as well: bashunit::spy takes a single name, bashunit::mock ls -l means "mock ls with -l as the replacement body", and bashunit::mock_sequence expects answers rather than arguments.

💡 Changes

  • Name the namespaced helper at all three call sites, and advise naming the command alone — which is true for all of them, since mock already forwards the call's own arguments to the replacement
  • Run the recommended form in the tests instead of only string-matching the message; string-matching is what let the invented mock survive
  • Those new assertions check behaviour rather than captured output — under --simple the rendered failure is a one-character marker, which the first attempt tripped over

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
@Chemaclass Chemaclass added the bug Something isn't working label Aug 14, 2026
@Chemaclass Chemaclass self-assigned this Aug 14, 2026
@Chemaclass
Chemaclass merged commit 61c50f5 into main Aug 14, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the fix/1229-mock-advice-namespace branch August 14, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant