Skip to content

Clarify Mox.allow/3 usage with deferred functions - #166

Merged
josevalim merged 1 commit into
dashbitco:mainfrom
alexisruccius:clarify-allow-deferred
Aug 27, 2025
Merged

Clarify Mox.allow/3 usage with deferred functions#166
josevalim merged 1 commit into
dashbitco:mainfrom
alexisruccius:clarify-allow-deferred

Conversation

@alexisruccius

Copy link
Copy Markdown
Contributor

When testing a process that calls a mock inside its init/1, I ran into an Mox.UnexpectedCallError because the process wasn’t yet started when defining Mox.allow/3.

The fix was to use a deferred function with Mox.allow/3, so that Mox resolves the process later when the mock is actually invoked.

This change updates the docs to clarify that deferred functions can be used in such cases.

@josevalim
josevalim merged commit 89e22d7 into dashbitco:main Aug 27, 2025
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants