Hey everyone!
I've been using Mox a lot and one thing that bothers me a little is that when I define an expectation that I expect to be called 0 times (i.e. I refute it), it's not very evident since the only "different" thing is the 0 passed as argument, which sometimes gets lost in the surrounding noise.
My proposal is the introduction of a refute (or some other name, naming things is hard etc etc) function which makes the intention more evident when reading the test. I would also allow to pass the arity as an integer instead of passing a lambda (possibly allowing both), since I find that having to define a fun for something I expect not to be called is what generates most of the noise.
So the interface would look something like that
# Passing a fun
refute(MockWeatherAPI, :get_temp, fn _ -> {:ok, 30} end)
# Passing the arity
refute(MockWeatherAPI, :get_temp, 1)
If this sounds interesting I'd be happy to take a stab at it.
Hey everyone! I've been using Mox a lot and one thing that bothers me a little is that when I define an expectation that I expect to be called 0 times (i.e. I refute it), it's not very evident since the only "different" thing is the
0
passed as argument, which sometimes gets lost in the surrounding noise.My proposal is the introduction of a
refute
(or some other name, naming things is hard etc etc) function which makes the intention more evident when reading the test. I would also allow to pass the arity as an integer instead of passing a lambda (possibly allowing both), since I find that having to define afun
for something I expect not to be called is what generates most of the noise.So the interface would look something like that
If this sounds interesting I'd be happy to take a stab at it.