Skip to content

Instantly share code, notes, and snippets.

@wmnnd
Last active November 7, 2025 10:32
Show Gist options
  • Select an option

  • Save wmnnd/cb80d4eae79d5d35b8229d6eec188ee5 to your computer and use it in GitHub Desktop.

Select an option

Save wmnnd/cb80d4eae79d5d35b8229d6eec188ee5 to your computer and use it in GitHub Desktop.
Capture Token in Phoenx test
test "verify something from a token", %{conn: conn} do
{:ok, agent_pid} = Agent.start_link(fn -> nil end)
capture_token = fn token ->
Agent.update(agent_pid, fn _ -> token end)
end
MyApp.SomeContext.send_verification_email(&capture_token.(&1))
token = Agent.get(token_agent, & &1)
assert something(token)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment