0.0
The project is in a healthy, maintained state
An httpbin like Rack module for Rspec
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.5
~> 3.40
~> 2.5.1
~> 5.2.0
~> 1.6
~> 6.4.2
~> 3.0.11
~> 2.1.0
~> 2.1.0
~> 13.2.1
~> 3.13
~> 2.31.0
~> 0.9.3
~> 1.36.0
 Project Readme

rspec-httpbin

An httpbin like Rack app for RSpec.

Note

This implementation is forked from weapp/foxyrb.

Install

gem install rspec-httpbin

Usage

RSpec::HTTPBin is a Rack app. You can mount it like:

require 'capybara'
require 'rspec/httpbin'

let!(:server) do
  server = Capybara::Server.new(RSpec::HTTPBin)
  server.boot
  server
end

And do a test:

require 'http'

res = HTTP.get("#{server.base_url}/get")
json = JSON.parse(res.body.to_s)
expect(json['headers']['User-Agent']).to start_with('http.rb/')

The following API endpoints are supported:

  • /get (GET)
  • /post (POST)
  • /put (PUT)
  • /delete (DELETE)
  • /patch (PATCH)
  • /status/{status} (any HTTP method)

/get, /post, put, /delete and patch return an HTTP response with the following fields.

  • data: Request body.
  • files: Not implemented. TBD.
  • form: Form data.
  • json: JSON data.
  • args: Parsed query strings.
  • headers: Headers.
  • origin: Origin.
  • url: URL.