ESpecJSONAPIMatchers
Custom ESpec matchers to ease testing of JSON API compliant endpoints.
Installation
-
Add
espec_json_api_matchersto your list of test-only dependencies inmix.exs:
```elixir
def deps do
[{:espec_json_api_matchers, "~> 0.1.0", only: :test}]
end
```import ESpecJSONAPIMatcherson the spec file(s) that will use the custom matchers (these are typically your view tests);Refer to the documentation for instructions on how to use the matchers.
Available Matchers
conform_to_schemahave_relationship_toinclude_relatedignorantly_match
Notes
- All matchers assume the passed node is an Elixir map; if you're working with a JSON string, make sure you encode it into a map first;
-
Matchers are strict when it comes to using atoms or strings as key names. If the map you pass in has a
"title"key and you're checking for:title, the matcher will fail; have_relationship_toandinclude_relatedwon't check the contents of a relationship, only that the appropriate keys exist in the passed node.