Make sure server response body is parsed

This commit is contained in:
Juan Cruz Viotti 2014-11-14 11:53:46 -04:00
parent 97d778634d
commit b47adaefa4
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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' }