When I first looked at the Mox documentation, I found this example confusing:
test "invokes add and mult" do
MyApp.CalcMock
|> expect(:add, fn x, y -> x + y end)
|> expect(:mult, fn x, y -> x * y end)
assert MyApp.CalcMock.add(2, 3) == 5
assert MyApp.CalcMock.mult(2, 3) == 6
end
This demonstrates that Mox works, but it doesn't show using a mock to test other code.
This PR changes the calculator examples to instead mock an API interface and test the code which calls it.
When I first looked at the Mox documentation, I found this example confusing:
This demonstrates that Mox works, but it doesn't show using a mock to test other code. This PR changes the calculator examples to instead mock an API interface and test the code which calls it.