Fulib v0.1.5 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
build_conn()
View Source
build_conn() :: Plug.Conn.t()
build_conn() :: Plug.Conn.t()
Creates a connection to be used in upcoming requests.
build_conn(method, path) View Source
build_conn(method, path, params_or_body) View Source
build_conn(method, path, params_or_body, headers) View Source
bypass_through(conn)
View Source
bypass_through(Plug.Conn.t()) :: Plug.Conn.t()
bypass_through(Plug.Conn.t()) :: Plug.Conn.t()
bypass_through(conn, router, pipelines \\ []) View Source
Calls the Endpoint and bypasses Router match.
See bypass_through/1
.
delete_req_cookie(conn, key)
View Source
delete_req_cookie(Plug.Conn.t(), binary()) :: Plug.Conn.t()
delete_req_cookie(Plug.Conn.t(), binary()) :: Plug.Conn.t()
Deletes a request cookie.
dispatch(conn, endpoint, method, path_or_action, params_or_body \\ nil) View Source
ensure_recycled(conn)
View Source
ensure_recycled(Plug.Conn.t()) :: Plug.Conn.t()
ensure_recycled(Plug.Conn.t()) :: Plug.Conn.t()
Ensures the connection is recycled if it wasn't already.
See recycle/1
for more information.
put_req_cookie(conn, key, value)
View Source
put_req_cookie(Plug.Conn.t(), binary(), binary()) :: Plug.Conn.t()
put_req_cookie(Plug.Conn.t(), binary(), binary()) :: Plug.Conn.t()
Puts a request cookie.
recycle(conn)
View Source
recycle(Plug.Conn.t()) :: Plug.Conn.t()
recycle(Plug.Conn.t()) :: Plug.Conn.t()
redirected_to(conn, status \\ 302)
View Source
redirected_to(Plug.Conn.t(), status :: non_neg_integer()) :: Plug.Conn.t()
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"
request(method, endpoint, path_or_action, params_or_body, headers) View Source
response(conn) View Source
response_content_type(conn, format)
View Source
response_content_type(Plug.Conn.t(), atom()) :: String.t() | no_return()
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"