Closed JamieREvans closed 5 years ago
I tried running your test and it passed for me.
There were two tiny syntax changes I had to make:
)
on line 8use ExUnit.Case
defmodule MyApp.MyModuleTest do
use ExUnit.Case
import Mock
alias MyApp.MyModule
describe "see if I can mock" do
test "Try mocking" do
assert MyModule.do_something("a thing") == "Doing a thing"
with_mock(MyModule, [do_something: fn(_the_something) -> "Something else" end]) do
assert MyModule.do_something("another thing") == "Something else"
end
end
end
end
Could you perhaps push a branch where I could try to reproduce it?
I have a custom module
MyApp.MyModule
with a functiondo_something
in a compiled file (my_module.ex).And I have a test that is trying to mock the function and see that it was called, but I'm getting an error saying that the module is not available.
And the error is:
As you can see, I can call the function perfectly fine outside of the mock, but if I can't call it inside the mock, it defeats the entire purpose of the mocking tool.