BlueBird v0.3.1 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 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 get_conns()
get_conns() :: [Plug.Conn.t]

Returns the logged connections.

Example

iex> get_conns()
[%Plug.Conn{}, ...]
Link to this function reset()
reset() :: :ok

Resets the logged connections.

Example

iex> reset()
:ok
Link to this function save(conn)
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() :: {:ok, pid}

Starts the GenServer.

Returns {:ok, pid} on success. Raises error on failure.

Example

iex> start_link()
{:ok, #PID<0.80.0>}