EspecJsonapi

Hex.pmCircleCI

Collection of matchers to help with testing JSONAPI responses with ESpec

Installation

If available in Hex, the package can be installed by adding espec_jsonapi to your list of dependencies in mix.exs:

def deps do
  [
    {:espec_jsonapi, "~> 1.0.1"}
  ]
end

Example

defmodule SomeSpec do
  use ESpec
  import EspecJsonapi
  
  it "has the correct type" do
    response = %{ "data" => %{ "type" => "user" } }
    expect(response["data"]) |> to(have_type("user"))
  end
end

Matchers