From b47adaefa4078401f3850b0b03f08f5404df0d1a Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Fri, 14 Nov 2014 11:53:46 -0400 Subject: [PATCH] Make sure server response body is parsed --- lib/server/server.coffee | 2 +- lib/server/server.spec.coffee | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/server/server.coffee b/lib/server/server.coffee index 9aa9e34b..af06c6f4 100644 --- a/lib/server/server.coffee +++ b/lib/server/server.coffee @@ -33,7 +33,7 @@ exports.request = (method = 'GET', url, json, callback) -> if response?.statusCode >= 400 error = new Error(response.body) - return callback(error, response, body) + return callback(error, response, response.body) ], callback diff --git a/lib/server/server.spec.coffee b/lib/server/server.spec.coffee index 14296d8e..2587b998 100644 --- a/lib/server/server.spec.coffee +++ b/lib/server/server.spec.coffee @@ -69,6 +69,13 @@ describe 'Server:', -> expect(response.body).to.equal(RESPONSE.nojson) done() + it 'should parse the body', (done) -> + server.request 'GET', URI.ok, null, (error, response, body) -> + expect(error).to.not.exist + expect(body).to.be.an.object + expect(body).not.to.be.a.string + done() + it 'should be able to send data in the body', (done) -> body = { hello: 'world' }