Project

rspec-http

0.03
No commit activity in last 3 years
No release in over 3 years
RSpec HTTP is an extension library that makes it easier to write specs for HTTP/REST APIs
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

~> 1.0
~> 3.0
 Project Readme

RSpec HTTP 0.11.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'

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.

expect(response).to be_http_ok

expect(response).to be_http_created

expect(response).to be_http_unprocessable_entity

expect(response).to be_http_im_a_teapot

expect(response).to have_header('Content-Type')

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

expect(response).to 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:

expect(response).to be_ok

expect(response).to be_created

expect(response).to be_unprocessable_entity

expect(response).to be_im_a_teapot