Closed ayrat555 closed 7 years ago
One of the guidelines in Elixir is that every time you you generate a function in the user code it should be to abide to some behaviour, so yes, you need behaviours.
Please see discussion in #9.
Another approach is for you to use atoms instead of defining functions, so you instead of SomeModule.foo
, you would do SomeModule.request(:foo)
or similar. This way you have a single interface and no longer rely on the function generation.
Thanks, I guess, my approach with dynamic code generation was wrong
Is it possible to mock methods that are generated by macro?
For example, there is some behaviour
and there is some macro that implements this behaviour
and then there are a couple of client that implement only request/1 method
this clients are used in other modules so I need somehow mock methods generated by Client.Macro. Should I define behaviour for every dynamically generated method (maybe also dynamically)? or there is no other way but to define ad-hoc mock module? Right now I'm using exvcr for all external request but I know it's not very clean.
P.S. Actually there are a lot of apis whose methods are the same except for their names so I think I'm not the only one having problems mocking them.