https://github.com/smartlogic/http_spec
RSpec DSL for describing HTTP API interactions
https://github.com/smartlogic/http_spec
Last synced: about 1 year ago
JSON representation
RSpec DSL for describing HTTP API interactions
- Host: GitHub
- URL: https://github.com/smartlogic/http_spec
- Owner: smartlogic
- Created: 2012-06-04T20:17:29.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2025-02-26T23:32:53.000Z (over 1 year ago)
- Last Synced: 2025-05-15T19:11:54.141Z (about 1 year ago)
- Language: Ruby
- Size: 103 KB
- Stars: 119
- Watchers: 6
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/smartlogic/http_spec)
[](https://gemnasium.com/smartlogic/http_spec)
[](https://codeclimate.com/github/smartlogic/http_spec)
[](https://coveralls.io/r/smartlogic/http_spec)
# HTTPSpec
RSpec DSLs for describing API behaviors
## Features
* Supports Rack, Webmachine, and live applications (via Faraday) using pluggable client back-ends.
* Generate documentation from requests with Raddocs.
* Validate requests and responses against a schema with Fdoc.
* Record and play back responses to speed-up tests against live applications. (like VCR)
## Example Usage
```ruby
require "http_spec/dsl/resource"
require "http_spec/clients/rack"
app = lambda { |env| [200, { "Foo" => "Bar" }, ["Hello, World!"]] }
HTTPSpec.client = HTTPSpec::Clients::Rack.new(app)
describe "My Awesome App" do
include HTTPSpec::DSL::Resource
get "/foobar" do
it "should be successful" do
do_request
status.should eq(200)
end
it "should tell us about foo" do
do_request
response_headers["Foo"].should eq("Bar")
end
it "should greet us" do
do_request
response_body.should eq("Hello, World!")
end
end
end
```
Want something more light-weight?
```ruby
require "http_spec/dsl/methods"
require "http_spec/clients/rack"
app = lambda { |env| [200, { "Foo" => "Bar" }, ["Hello, World!"]] }
HTTPSpec.client = HTTPSpec::Clients::Rack.new(app)
describe "My Awesome App" do
include HTTPSpec::DSL::Methods
it "should be successful" do
get("/foo").status.should eq(200)
end
it "should tell us about foo" do
get("/bar").headers["Foo"].should eq("Bar")
end
it "should greet us" do
get("/baz").body.should eq("Hello, World!")
end
end
```
## Changes
### 1.0.0
* Support for ruby 3.X - fixes for stdlib API changes
### 0.4.0
* Support latest versions of RSpec, Raddocs, Webmachine
### 0.3.0
* Expose `last_response` when using the methods dsl
* Allow rack client to control the cgi environment
* [Bug] Fix issue where group-level headers where being mutated by examples