Last active
January 4, 2016 18:29
-
-
Save astronomy88/8661016 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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