Closed horkhe closed 11 years ago
Might I suggest a few changes?
ok
(more Erlang-ish){stub_all, ReturnValue}
or even {stub_all, Fun}
(tip: use proplists:expand/2
and family)It is a neat idea to allow defining values returned by stubs. I just implemented it in a more general way. Any valid ret_spec()
can be specified as a return value of the stub_all option.
Alternatively we have to expand the stub_all
option to {stub_all, ok}
first, and then use that in combination with proplists:is_defined(stub_all, Options)
to see if we can trust the return value of proplists:get_value(stub_all, Options)
or not.
Fixed this case too.
I wonder, why my pull request does not have that nice green label from Travis-CI that it is ok to merge...
Nice work!
For those who use mocks in record-then-verify manner (and I am one of them :-)) it would be very convenient to create mocks that have stubs for all exported functions out-of-the-box. This feature introduces such capability. The default stubs allow everything as input arguments and return
meck_stub
. If in the scope of a test a more specific stub (expectation) is required, then the out-of-the-box stub (expectation) can be overridden by explicit call tomeck:expect/3,4
.E.g. If there is a module
m1
that exports functionf/2
then: