View Source FlEx.Test.Helpers (fl_ex v0.1.1)

Contains the type of response handling and more helpers for all kinds of possible servers that you can create

This module it's pre-imported in the module FlEx.ConnTest

Summary

Functions

Asserts the given status code, that we have a json response and returns the decoded JSON response if one was set or sent.

Asserts the given status code and returns the response body if one was set or sent.

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

Functions

Link to this function

json_response(conn, status)

View Source
@spec json_response(Conn.t(), status :: integer() | atom()) :: term()

Asserts the given status code, that we have a json response and returns the decoded JSON response if one was set or sent.

Examples

body = json_response(conn, 200)
assert "can't be blank" in body["errors"]
@spec response(Plug.Conn.t(), status :: integer() | atom()) :: binary()

Asserts the given status code and returns the response body if one was set or sent.

Examples

conn = get(build_conn(), "/")
assert response(conn, 200) =~ "hello world"
Link to this function

response_content_type(conn, format)

View Source
@spec response_content_type(Plug.Conn.t(), atom()) :: String.t()

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

Examples

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