Skip to content

Instantly share code, notes, and snippets.

@astronomy88
Last active January 4, 2016 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astronomy88/8661016 to your computer and use it in GitHub Desktop.
Save astronomy88/8661016 to your computer and use it in GitHub Desktop.
# encoding: utf-8
require 'spec_helper'
describe "Test JSON response" do
before :all do
host = http://localhost:3000
@url = "api/v1/foobar"
headers = {
:'Content-Type' => 'application/json',
:'User-Agent' => 'Testing API Response',
}
@conn = Faraday.new(url: host, headers: headers) do |builder|
builder.use Faraday::Request::UrlEncoded
builder.adapter :net_http
end
end
it "Get correct JSON response" do
data = File.read("path/to/json/file.json"))
r = @conn.post( @url, data )
resp = File.read("path/to/response/response.json")
r.body.squish.should eql(resp.squish)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment