Maru v0.10.5 Maru.Test

Unittest wrapper for designated router.

Summary

Functions

Create a test connection

Get response from conn as json

Put body or params into conn

Put a plug called before endpoint into conn

Get response from conn as text

Functions

build_conn()

Create a test connection.

get("/") is used to test a simple request. build_conn/0 is useful when test a complex request with headers or params.

Examples

get("/", "v1")
build_conn() |> put_body_or_params("body params") |> post("/path", "v2")
build_conn() |> put_req_header("Authorisation", "something") |> get("/path")
json_response(conn)

Get response from conn as json.

put_body_or_params(conn, body_or_params)

Put body or params into conn.

put_plug(conn, plug, opts)

Put a plug called before endpoint into conn.

text_response(conn)

Get response from conn as text.