We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 20e3ac9 commit 89e22d7Copy full SHA for 89e22d7
lib/mox.ex
@@ -760,6 +760,13 @@ defmodule Mox do
760
761
allow(MyMock, self(), fn -> GenServer.whereis(Deferred) end)
762
763
+ This means that if the process isn’t started yet, you can pass a function
764
+ that resolves to the pid later. When the mock is invoked,
765
+ Mox will call this function. If it returns a pid, the call is allowed.
766
+ If it doesn’t, the expectation fails.
767
+
768
+ This is especially useful when testing a `GenServer` that calls the mock during `init/1`,
769
+ since the server’s pid is not available until after `start_link/1`.
770
"""
771
@spec allow(mock, pid(), term()) :: mock when mock: t()
772
def allow(mock, owner_pid, allowed_via) when is_atom(mock) and is_pid(owner_pid) do
0 commit comments