I'm using meck and it works great in most cases. However, I encountered the following error:
elixir
(ErlangError) erlang error: {:undefined_function, {OAuth2.Strategy.AuthCode, :new, 2}}
I found that :new
was a function defined in OAuth2.Strategy
's __using__
macro. That means :new
wasn't defined OAuth2.Strategy.AuthCode
. How do I mock out :new
in this case?
Meck creates mocks in runtime, thus it will never be able to mock macros in Elixir. If your macro eventually creates a function, that is then compiled into a module, you should be able to mock that (provided that you know the name of the function).