Skip to content

fix(doubles): add a boundary-exact spy argument assertion - #903

Merged
Chemaclass merged 1 commit into
mainfrom
fix/894-assert-have-been-called-with-arg-boundaries
Jul 27, 2026
Merged

fix(doubles): add a boundary-exact spy argument assertion#903
Chemaclass merged 1 commit into
mainfrom
fix/894-assert-have-been-called-with-arg-boundaries

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #894

assert_have_been_called_with compares against the spy's space-joined record, so cmd "a b" and cmd a b look identical to it. A quoting bug in the code under test therefore produces a green assertion — the worst kind of false positive.

💡 Changes

  • Add assert_have_been_called_with_args <spy> <arg>..., which compares the recorded arguments one by one. No call index: a trailing number could not be told apart from a numeric argument.
  • Fix the per-argument form the spy records — the separator was written as literal text instead of the byte, so the field was unusable (and unread) until now.
  • assert_have_been_called_with behaviour is unchanged.
  • Documented in the assertions, test-doubles, agentic-coding and skill pages.

`assert_have_been_called_with` compares against the spy's space-joined `raw`
field, so `cmd "a b"` is indistinguishable from `cmd a b` and a quoting bug
passes the assertion.

The spy already recorded a per-argument form, but it was unusable: the
separator was written as the literal text `$'\x1f'` rather than the byte
(ANSI-C quoting does not apply inside double quotes), and the trailing-separator
strip therefore never matched. No assertion read the field, so nobody noticed.

Fix the separator and add `assert_have_been_called_with_args <spy> <arg>...`,
which serializes the expected arguments the same way and compares them one by
one. `assert_have_been_called_with` is unchanged. The new assertion takes no
call index: a trailing number could not be told apart from a numeric argument.

Closes #894
@Chemaclass Chemaclass added the bug Something isn't working label Jul 27, 2026
@Chemaclass Chemaclass self-assigned this Jul 27, 2026
@Chemaclass
Chemaclass merged commit 5c96ede into main Jul 27, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the fix/894-assert-have-been-called-with-arg-boundaries branch July 27, 2026 19:29
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