jjh42 / mock

Mocking library for Elixir language
MIT License
654 stars 81 forks source link

Proposal: add `assert_not_called` macro #119

Closed amilkr closed 4 years ago

amilkr commented 4 years ago

In the same way as assert_called validates that a function was called, assert_not_called would validate that a function was not called.

If there's already a way to achieve this, please let me know :)

This would be useful, for example, in cases where you're mocking a service that sends notifications to the users and you want to validate that in some particular cases the system doesn't try to send notifications.

Olshansk commented 4 years ago

I think you can call :meck.num_calls and check that the number is 0.

If you want to create a wrapper for it called assert_not_called, that'd be great!

amilkr commented 4 years ago

Thanks for the answer. I'll try that. If I find some free time, I'll try to add the macro into mock.ex and open a PR.