restful-matchers Build Status Code Climate Gem Version

RSpec matchers to test RESTful HATEOAS-compliant resource links. Currently it supports only JSON representations as an array of link objects with rel and href attributes, like this:

{
  "attribute1": "value1",
  "attribute2": "value2",
  "links": [
    { "rel": "self", "href": "http://example.com" }
  ]
}

Example:

describe MyRestfulController do
  render_views

  it "should have entry-point links" do
    get :index
    response.body.should have_restful_json_link("self", "http://example.com")
    response.body.should have_restful_json_link("resource1", "http://example.com/resource1")
    response.body.should have_restful_json_link("resource2", "http://example.com/resource2")
  end
end

Installation

Add it to the test group in your Gemfile and be happy!

group :test do
  gem 'restful-matchers'
end