Fulib v0.1.4 Fulib.MockRequestUtil View Source

Link to this section Summary

Functions

Creates a connection to be used in upcoming requests

Calls the Endpoint and bypasses Router match

Deletes a request cookie

Ensures the connection is recycled if it wasn't already

Puts a request cookie

Returns the location header from the given redirect response

Returns the content type as long as it matches the given format

Link to this section Functions

Creates a connection to be used in upcoming requests.

Link to this function

build_conn(method, path) View Source

Link to this function

build_conn(method, path, params_or_body) View Source

Link to this function

build_conn(method, path, params_or_body, headers) View Source

Link to this function

bypass_through(conn) View Source
bypass_through(Plug.Conn.t()) :: Plug.Conn.t()

Link to this function

bypass_through(conn, router, pipelines \\ []) View Source
bypass_through(Conn.t(), module(), :atom | list()) :: Conn.t()

Calls the Endpoint and bypasses Router match.

See bypass_through/1.

Link to this function

delete_req_cookie(conn, key) View Source
delete_req_cookie(Plug.Conn.t(), binary()) :: Plug.Conn.t()

Deletes a request cookie.

Link to this function

dispatch(conn, endpoint, method, path_or_action, params_or_body \\ nil) View Source

Link to this function

ensure_recycled(conn) View Source
ensure_recycled(Plug.Conn.t()) :: Plug.Conn.t()

Ensures the connection is recycled if it wasn't already.

See recycle/1 for more information.

Link to this function

put_req_cookie(conn, key, value) View Source
put_req_cookie(Plug.Conn.t(), binary(), binary()) :: Plug.Conn.t()

Puts a request cookie.

Link to this function

redirected_to(conn, status \\ 302) View Source
redirected_to(Plug.Conn.t(), status :: non_neg_integer()) :: Plug.Conn.t()

Returns the location header from the given redirect response.

Raises if the response does not match the redirect status code (defaults to 302).

Examples

assert redirected_to(conn) =~ "/foo/bar"
assert redirected_to(conn, 301) =~ "/foo/bar"
assert redirected_to(conn, :moved_permanently) =~ "/foo/bar"
Link to this function

request(method, endpoint, path_or_action, params_or_body, headers) View Source

Link to this function

response_content_type(conn, format) View Source
response_content_type(Plug.Conn.t(), atom()) :: String.t() | no_return()

Returns the content type as long as it matches the given format.

Examples

# Assert we have an html repsonse with utf-8 charset
assert response_content_type(conn, :html) =~ "charset=utf-8"