fix(doubles): fail call assertions on a name that was never spied - #904
Merged
Merged
Conversation
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
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 #895
A call assertion on a name that was never passed to
bashunit::spyreported "0 calls" instead of erroring, soassert_not_called tuochpassed while asserting nothing. That silently voids exactly the assertions used to prove a destructive command did not run.💡 Changes
assert_have_been_called*/assert_not_callednow fails withwas never registered as a spywhen the name is unknown or was unmocked.assert_not_calledand_times 0on a registered spy keep passing — unchanged.clear_mocksby asserting 0 calls on a cleared spy: it now asserts the new failure, a stronger signal..claude/references to a non-existentassert_failsassertion.