Open oliyh opened 8 years ago
Ah, upon further investigation it seems that this is explicitly disallowed in v2.2.0 by this commit - my code above will throw an exception stating that nesting is not allowed. However in 2.1.3 (the version suggested in the README, which is what I am using) the code is allowed but results in the unexpected message I posted.
@AlexBaranosky I appreciate it was a long time ago, but why did you choose to disallow nested mocking rather than make changes to support it?
Hi,
I have noticed that when nesting mocking or stubbing macros, all the mocks or stubs are cleared out when the first macro exits which leads to unexpected behaviour.
Consider the following:
I would expect this to work, but I get the following exception:
It will only work if I keep all the
stubbing
calls nested, like so:I believe this is because the atom tracking stubs is reset at the end of each
with-installed-fakes
call, rather than just dissoccing the stubbed functions. This makes it hard to write more involved tests where several steps may call the same functions but different return values and assertions are required.