RSpec HTTP is an extension library that makes it easier to write specs for HTTP/REST APIs
Ruby
Pull request Compare This branch is 3 commits behind c42:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/rspec
spec
.gitignore
CHANGELOG
Gemfile
LICENCE
README.rdoc
Rakefile
rspec-http.gemspec

README.rdoc

RSpec HTTP 0.10.0

© Copyright 2010-2011 C42 Engineering. All Rights Reserved.

RSpec HTTP is a RSpec extension library that adds support for writing specs that cover HTTP based APIs (or more popularly, RESTful APIs).

To use this library, first add the rspec-http gem to your Gemfile like so:

gem 'rspec-http', '~> 0.9'

Then add the following line to your spec_helper.rb:

require 'rspec/http'

This will make matchers such as the ones listed below available to you in your specs.

response.should be_http_ok

response.should be_http_created

response.should be_http_unprocessable_entity

response.should be_http_im_a_teapot

response.should have_header('Content-Type')

response.should have_header('Content-Type' => 'application/json')

response.should have_header('Content-Type' => /json/)

Rails

If you're using Rails (and implicitly, rspec-rails), the same http code matchers will also be available in your controller specs without the http namespace. In other words, in your controller specs you can do:

response.should be_ok

response.should be_created

response.should be_unprocessable_entity

response.should be_im_a_teapot