Permalink
Browse files

Change the response assertion to kill the server as soon as it enters…

… the response.on('end',...) callback
  • Loading branch information...
1 parent 1d2c78a commit e8505bffdbe70195e2e37f26c0198c30803ae259 @mjumbewu committed May 17, 2011
Showing with 19 additions and 4 deletions.
  1. +19 −4 bin/expresso
View
@@ -433,6 +433,25 @@ assert.response = function(server, req, res, msg){
response.on('end', function(){
if (timer) clearTimeout(timer);
+ // Shut down the server
+ check();
+
+ /**
+ * I feel like this is almost right. Instead, I think all these
+ * asserts should be wrapped in a try/catch block and that there
+ * should be an error callback that is passed in as a parameter.
+ * If an error is caught, it should be passed along to the error
+ * callback along with the response. Otherwise the normal
+ * callback should be called.
+ *
+ * For now, since I don't want to go through the logic of
+ * checking for an error callback (and should it come before or
+ * after the normal one), I'm going to leave this.
+ */
+
+ // Callback
+ callback(response);
+
// Assert response body
if (res.body !== undefined) {
var eql = res.body instanceof RegExp
@@ -475,10 +494,6 @@ assert.response = function(server, req, res, msg){
);
}
}
-
- // Callback
- callback(response);
- check();
});
});
request.end();

0 comments on commit e8505bf

Please sign in to comment.