Closed marocchino closed 3 years ago
hi there @marocchino! Thanks for taking the time to dive into this. However, do you think this is something that could be achieved by using the already defined Neuron.Connection
behaviour? It is in the readme, and this way we'd not be mocking the entire library but instead only the piece that hits an external dependency, so that we can still test fragments for example.
Hi @uesteibar. Thank you for your kind answer. Using Neuron.Connection
or HTTPosion.Base
for a mock is an acceptable suggestion, although it makes testing unnecessarily verbose. I'll do that this time, but I still wish to mocking the entire library in the future.
good to hear that it works for you @marocchino. Regarding adding this to the library, I do feel strongly about not providing a behaviour for Neuron
and instead only mocking the Connection
, since this would result on wider tests, covering more code and allows users to test that Neuron is fine with processing their API responses.
If it's a strong preference on your side, I would suggest to implement your own behaviour, then wrap Neuron on a module that implements that behaviour and delegate the functions to Neuron
. Would that work for you? It would solve your problem without having to add it to the library itself.
This makes Neuron a behaviour module and describes how to mock it in the test.
It can now be used directly with Mox without a wrapping module. I know you use mock, but it's a good thing to give the user a choice between mock and mox.