Closed horkhe closed 11 years ago
I also like the idea of using honest
by default. My guess is that 95-99 percent of the mocking done with Meck is with preexisting modules. Perhaps (if we make it default) another option could be added to make them "non-honest"? Like meck:new(mod, [unknown])
?
@eproxus so I will make mocks "honest" by default, and introduce an option to allow mocking of non-existing functions/modules. Though I find "unknown" a little bit confusing. What about "non_strict"?
non_strict
is much better.
Yep, undefined_function
is good.
@eproxus I made mocks honest by default and changed the exception for the undefined function case as we discussed.
@eproxus have you had a chance to take a look at the changes?
@eproxus hey man, how are you? I hope you did not fall off the planet :-)
@horkhe Haha, no. I just moved to Germany so I've been a bit busy. :-) I'll do a last sweep and then we'll merge.
@eproxus Moved to Germany, that is cool. I suppose that was caused by a generous job offer, so my congratulations!
Back to business. The code is rebased and adjusted.
@horkhe You, sir, are correct. :-)
@eproxus I am genuinely curious if you new job is Erlang related?
Yes, it is. I've started working at Wooga in Berlin. If you want a referral, let me know. :-)
Thanks a lot for the suggestion! :-)
Meck is so powerful that it allows mocking non-existent functions and even non-existent modules. But as every coin it comes with two sides. And the bad thing here is that all sorts of problem caused by refactoring/removing/renaming actions are not detected by meck featured unit tests. Namely:
To have such cases detected at the earliest possibility honest mocks were introduced. They expose the following properties:
meck:new(mod, [honest])
for a module that does not exist fails withundefined_module
error;cannot_mock_fake
error.I personally think that all mocks created by meck should be honest by default, but I did not want to break the backwards compatibility.