README.md

# ESpecJSONAPIMatchers

Custom [ESpec](https://github.com/antonmi/espec) matchers to ease testing of [JSON API](http://jsonapi.org/) compliant endpoints.

## Installation

  1. Add `espec_json_api_matchers` to your list of test-only dependencies in `mix.exs`:

    ```elixir
    def deps do
      [{:espec_json_api_matchers, "~> 0.1.0", only: :test}]
    end
    ```

  2. `import ESpecJSONAPIMatchers` on the spec file(s) that will use the custom matchers (these are typically your view tests);

  3. Refer to the [documentation](https://hexdocs.pm/espec_json_api_matchers/ESpecJSONAPIMatchers.html) for instructions on how to use the matchers.

## Available Matchers
* `conform_to_schema`
* `have_relationship_to`
* `include_related`
* `ignorantly_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_to` and `include_related` won't check the contents of a relationship, only that the appropriate keys exist in the passed node.