In the docs it says I can stub Req in tests with a config like this:
# config/test.exs
config :myapp, weather_req_options: [
plug: {Req.Test, MyApp.Weather}
]
What I want is - the same but for development to not make real API calls (they cost money) but to play with the logic.
I added the same config for development, and added this to application.ex
Req.Test.stub(MyApp.Weather, fn conn ->
Req.Test.json(conn, %{"celsius" => 25.0})
end)
but when I make a call in iex, I get an error ** (RuntimeError) cannot find mock/stub MyApp.Weather in process #PID<0.451.0>
Only when I rerun the Req.Test.stub
snippet in iex, then it gets stubbed.
Can I somehow configure Req to globally stub in development?
It works if also add it to .iex.exs
but it will then only stub in iex session.