Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

RSpec HTTP is an extension library that makes it easier to write specs for HTTP/REST APIs

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENCE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 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
Something went wrong with that request. Please try again.