ShouldI.Matchers.Plug

Convenience macros for generating short test cases of common structure. These matchers work with Plug connections.

Source

Summary

plug_should_respond_with(atom1, context)
should_match_body_to(expected)

The connection body (connection.resp_body) should match the expected result

should_respond_with(expected_result)

The connection status (connection.status) should match the expected result

Functions

plug_should_respond_with(atom1, context)
Source

Macros

should_match_body_to(expected)

The connection body (connection.resp_body) should match the expected result.

setup context do
  some_plug_call_returning_a_context_having_a_connection_key
end

should_match_body_to "this_string_must_be_present_in_body"
Source
should_respond_with(expected_result)

The connection status (connection.status) should match the expected result.

Rather than match a specific value, the matchers work against ranges:

success: (200…299) redirect: (300…399) bad_request: 400 unauthorized: 401 missing: 404 error: (500..599)

Examples

setup context do
  some_plug_call_returning_a_context_having_a_connection_key
end

should_respond_with :success
Source