diff --git a/bin/expresso b/bin/expresso index a7edd2f..1f64d09 100755 --- a/bin/expresso +++ b/bin/expresso @@ -433,6 +433,9 @@ assert.response = function(server, req, res, msg){ response.on('end', function(){ if (timer) clearTimeout(timer); + // Shut down the server + check(); + // Assert response body if (res.body !== undefined) { var eql = res.body instanceof RegExp @@ -475,10 +478,9 @@ assert.response = function(server, req, res, msg){ ); } } - + // Callback callback(response); - check(); }); }); request.end(); diff --git a/test/http.test.js b/test/http.test.js index 1f9d249..509048f 100644 --- a/test/http.test.js +++ b/test/http.test.js @@ -68,6 +68,26 @@ module.exports = { }) }, + 'test assert.response(req, res, fn) with POSTed body': function(beforeExit){ + var calls = 0; + + assert.response(server, { + url: '/echo', + method: 'POST', + body: 'Hello, Expresso!' + },{ + body: '/echo Hello, Expresso!', + status: 200 + }, function(res){ + ++calls; + assert.ok(res); + }); + + beforeExit(function(){ + assert.equal(1, calls); + }) + }, + 'test assert.response(req, fn)': function(beforeExit){ var calls = 0;