Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/mox.ex
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,16 @@ defmodule Mox do
stub(MockWeatherAPI, :get_temp, fn _loc -> {:ok, 30} end)

`stub/3` will overwrite any previous calls to `stub/3`.

> #### Warning {: .warning}
>
> `stub/3` does **not verify that a call occurred**.
> If the code stops calling the stubbed function
> (for example, after a refactor), the test will still pass.
>
> This can lead to unused stubs lingering in tests.
> Always use `expect/3` when you want to ensure the
> function is actually invoked.
"""
@spec stub(mock, atom(), function()) :: mock when mock: t()
def stub(mock, name, code)
Expand Down
Loading