Skip to content

fix(doubles): fail call assertions on a name that was never spied - #904

Merged
Chemaclass merged 1 commit into
mainfrom
fix/895-call-assertions-fail-when-never-spied
Jul 27, 2026
Merged

fix(doubles): fail call assertions on a name that was never spied#904
Chemaclass merged 1 commit into
mainfrom
fix/895-call-assertions-fail-when-never-spied

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #895

A call assertion on a name that was never passed to bashunit::spy reported "0 calls" instead of erroring, so assert_not_called tuoch passed while asserting nothing. That silently voids exactly the assertions used to prove a destructive command did not run.

💡 Changes

  • Track spy registration next to the call count; every assert_have_been_called* / assert_not_called now fails with was never registered as a spy when the name is unknown or was unmocked.
  • assert_not_called and _times 0 on a registered spy keep passing — unchanged.
  • Update the acceptance test that proved clear_mocks by asserting 0 calls on a cleared spy: it now asserts the new failure, a stronger signal.
  • Drop two .claude/ references to a non-existent assert_fails assertion.

Call assertions resolved their state from a dynamically-named global. When the
name was never spied that global is unset, the call count reads as 0, and the
assertion behaved as if the command existed and simply had not been invoked.
`assert_not_called tuoch` therefore passed while asserting nothing — worst on
the two assertions agents reach for to prove a guard clause held.

Track registration alongside the call count and fail with a distinct message
naming the cause. `assert_not_called` / `_times 0` on a registered spy still
pass; an unmocked spy fails like an unknown name.

`tests/acceptance/mock_test.sh` proved clear_mocks by asserting 0 calls on a
cleared spy, which is exactly the case now rejected; it asserts the new failure
instead, which is the stronger signal.

Also drop the two references to `assert_fails` in `.claude/` — no such
assertion exists in the framework.

Closes #895
@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 7661252 into main Jul 27, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the fix/895-call-assertions-fail-when-never-spied branch July 27, 2026 19:49
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