Skip to content

feat(doubles): add an any-call matcher for spy arguments - #906

Merged
Chemaclass merged 1 commit into
mainfrom
feat/897-any-call-spy-matcher
Jul 27, 2026
Merged

feat(doubles): add an any-call matcher for spy arguments#906
Chemaclass merged 1 commit into
mainfrom
feat/897-any-call-spy-matcher

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #897

assert_have_been_called_with only compares one call, so a test that means "this side effect happened" fails as soon as an unrelated call is added after it — and the failure reads as if the call never happened at all.

💡 Changes

  • Add assert_have_been_called_with_any <spy> <expected>, which passes when any recorded call matches. Last-call and indexed behaviour is unchanged.
  • Failures of the last-call assertions now name the call they compared (compared 'the last of 2 calls').
  • Both last-call assertions locate their line in one pure-bash pass, which also drops the per-assertion tail / sed forks.
  • Documented in the assertions, test-doubles, agentic-coding and skill pages.

`assert_have_been_called_with` compares one call — the last, or the one at the
optional index — so a test that means "this side effect happened" breaks as soon
as an unrelated later call is added, and the failure text points at neither the
cause nor the fix.

Add `assert_have_been_called_with_any <spy> <expected>`, which scans every
recorded call, and name the compared call in the last-call failures
(`compared 'the last of 2 calls'`) so the existing assertion stops reading like
the call never happened.

Both last-call assertions now find their line with a single pure-bash pass over
the params file, which yields the total the message needs and drops the `tail`
and `sed` forks they used to pay on every assertion.

Closes #897
@Chemaclass Chemaclass added the enhancement New feature or request label Jul 27, 2026
@Chemaclass Chemaclass self-assigned this Jul 27, 2026
@Chemaclass
Chemaclass merged commit 8b55670 into main Jul 27, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the feat/897-any-call-spy-matcher branch July 27, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant