mox icon indicating copy to clipboard operation
mox copied to clipboard

Calling `verify!` should raise a `Mox.VerificationError` if there are too many calls to a mock

Open metavida opened this issue 2 years ago • 5 comments

Similar to comments in Issue #32, there are certain cases when we want to assert that a mocked function is never called (or is not over-called) but where the expected calls happen within code that either async or has aggressive error handling. In these cases it's desirable for verify! (and verify_on_exit!) to inform the user when an expectation has been violated by receiving too many calls.

Currently this PR does not implement a solution but does contribute 4 net-new verify! unit tests that should begin passing once this behavior is implemented.

Does this seem like a reasonable request/approach?

metavida avatar Aug 04 '23 19:08 metavida

Currently this PR does not implement a solution but does contribute 4 net-new verify! unit tests that should begin passing once this behavior is implemented.

Would it be possible to add new tests instead of changing the existing suite?

josevalim avatar Aug 04 '23 20:08 josevalim

Would it be possible to add new tests instead of changing the existing suite?

Thanks for this comment! It inspired me to simplify this PR so that now it only introduces the 4 new (currently failing) tests. If you think these 4 new tests deserve to be in their own describe blocks or in their own test file just let me know!

I've separated the other, tangential improvements to verify tests into separate PR: #142

metavida avatar Aug 07 '23 23:08 metavida

Perfect, Yes, this looks good to me. Looking forward to a possible solution. :)

josevalim avatar Aug 08 '23 10:08 josevalim

@metavida any chance you're picking this up anytime soon? Otherwise, I can give it a try.

whatyouhide avatar Jan 21 '24 14:01 whatyouhide

Go for it! I do not have any near term plans to work on this.

metavida avatar Jan 21 '24 16:01 metavida