Fork me on GitHub
#midje
<
2019-01-04
>
dbernal15:01:09

is it possible to mock out and test macros? For example, let's say I would like to mock and test the or macro. Is this possible?

eraserhd15:01:20

You can test a macro with eval. Otherwise it will have executed before your test runs.

eraserhd15:01:42

I'm guessing mocking won't work, because if your code is in another namespace, it will have already expanded the macro by test time, and rebinding the macro won't cause it to re-expand.

eraserhd15:01:58

You might be able to jury-rig something to reload the dependent namespace every time you rebind the macro, but that seems like it might be really flakey.

dbernal15:01:56

I see ok thank you. I'm guessing another way would be to wrap the macro around a function and mock that