BlueBird v0.4.0 BlueBird.ConnLogger
Logs connections in test cases.
BlueBird.ConnLogger
is used to cache %Plug.Conn
structs. To use it, you
have to call start/0
in test/test_helper.exs
:
BlueBird.start()
ExUnit.start(formatters: [ExUnit.CLIFormatter, BlueBird.Formatter])
You can then use BlueBird.ConnLogger.save(conn)
in your tests.
defmodule MyApp.Web.UserControllerTest do
use MyApp.Web.ConnCase
alias BlueBird.ConnLogger
test "returns a single user", %{conn: conn} do
user = user_fixture()
conn = conn
|> get(conn, user_path(conn, :index, user.id))
|> ConnLogger.save()
assert json_response(conn, 200)["data"] == %{name: user.name}
end
end
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor
Returns the logged connections
Resets the logged connections
Saves the given connection to the list
Starts the GenServer
Link to this section Functions
Link to this function
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
Link to this function
get_conns()
get_conns()
get_conns() :: [Plug.Conn.t()]
get_conns() :: [Plug.Conn.t()]
Returns the logged connections.
Example
iex> get_conns()
[%Plug.Conn{}, ...]
Link to this function
reset()
reset()
reset() :: :ok
reset() :: :ok
Resets the logged connections.
Example
iex> reset()
:ok
Link to this function
save(conn)
save(conn)
save(Plug.Conn.t()) :: :ok
save(Plug.Conn.t()) :: :ok
Saves the given connection to the list.
Example
iex> save(conn)
:ok
Link to this function
start_link()
start_link()
start_link() :: {:ok, pid()}
start_link() :: {:ok, pid()}
Starts the GenServer.
Returns {:ok, pid}
on success. Raises error on failure.
Example
iex> start_link()
{:ok, #PID<0.80.0>}