Spyanator v0.0.3 Spyanator
The main interface to starting and tracking the Spyanator agent and any Spyanator related agents.
This module is used with Spyanator.Macro
to track calls, return values and
arguments sent to spys.
To create a spy, you must use Spyanator
and define functions like normal
defmodule TestTheThing do
use ExUnit.Case, async: true
defmodule AgentSpy do
use Spyanator
def start(_fn, opts), do: {:ok, nil}
end
def start_spy(_context), do:
{:ok, spy: Spyanator.start_spy(AgentSpy)}
describe "when the thing is doing the thing" do
setup [:start_spy]
test "it does the thing" do
#...
end
end
end
Spyanator also provides helper functions to use within your tests. These
functions live in Spyanator.Assertions
defmodule TestAnotherThing do
use ExUnit.Case, async: true
use Spyanator.Assertions
#...
test "it calls :the_function" do
assert Spy |> received(:the_function) |> once
end
end
For more detail, please see Spyanator.Assertions
Summary
Functions
Get the PID for a running spy module
Increments the number of calls to the given function for the given module
Starts the Spyanator process. The process is named Spyanator
Used to start a spy module. Required before any call tracking can be done
Tracks the arguments provided to the function
tracks the returned value for the given function on the given module. Assumes that the value was a result of the last call
Functions
Increments the number of calls to the given function for the given module
Used to start a spy module. Required before any call tracking can be done.
Tracks the arguments provided to the function.