Skip to content

Commit

Permalink
Add teardown methods to Vows contexts.
Browse files Browse the repository at this point in the history
  • Loading branch information
reid committed Apr 3, 2012
1 parent 26129b1 commit a3fea60
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
8 changes: 7 additions & 1 deletion test/functional.js
Expand Up @@ -216,6 +216,9 @@ function attachServerContext(testContext, explicitRoute) {
vow.callback(null, server); vow.callback(null, server);
}); });
}, },
teardown: function (server) {
server.close();
},
"is connected": function (server) { "is connected": function (server) {
assert.isNumber(server.address().port); assert.isNumber(server.address().port);
}, },
Expand Down Expand Up @@ -260,6 +263,10 @@ function attachServerContext(testContext, explicitRoute) {
"used by the Hub Client": { "used by the Hub Client": {
// TODO: Handle without trailing slash. // TODO: Handle without trailing slash.
topic: hub.clientTopic(route + "/"), topic: hub.clientTopic(route + "/"),
teardown: function (topic) {
// TODO Add end method, bug #54.
// topic.client.end();
},
"a browser for testing": { "a browser for testing": {
topic: hub.phantomTopic(), topic: hub.phantomTopic(),
"visits Yeti": testContext "visits Yeti": testContext
Expand All @@ -270,7 +277,6 @@ function attachServerContext(testContext, explicitRoute) {
} }


function attachServerBatch(definition) { function attachServerBatch(definition) {

var batch = {}, var batch = {},
routeWords = ["foo", "bar", "baz", "quux"]; routeWords = ["foo", "bar", "baz", "quux"];


Expand Down
5 changes: 4 additions & 1 deletion test/lib/blizzard-http.js
Expand Up @@ -28,7 +28,10 @@ exports.sessionContext = function (subContext) {
server: serverBlizzardSession server: serverBlizzardSession
}); });
}); });

},
teardown: function (topic) {
topic.client.end();
topic.server.end();
} }
}; };


Expand Down
4 changes: 4 additions & 0 deletions test/lib/blizzard.js
Expand Up @@ -50,6 +50,10 @@ exports.sessionContext = function (subContext) {
}); });


clientSocket.once("error", vow.callback); clientSocket.once("error", vow.callback);
},
teardown: function (topic) {
topic.client.end();
topic.server.end();
} }
}; };


Expand Down
3 changes: 3 additions & 0 deletions test/lib/hub.js
Expand Up @@ -50,6 +50,9 @@ var clientContext = exports.clientContext = function (subContext) {
}); });
hub.once("error", vow.callback); hub.once("error", vow.callback);
}, },
teardown: function (hub) {
hub.close();
},
"is ok": function (hub) { "is ok": function (hub) {
assert.ok(hub); assert.ok(hub);
assert.isNumber(hub.server.address().port); assert.isNumber(hub.server.address().port);
Expand Down
3 changes: 3 additions & 0 deletions test/listen.js
Expand Up @@ -52,6 +52,9 @@ vows.describe("Yeti Listen").addBatch({
vow.callback(null, server); vow.callback(null, server);
}); });
}, },
teardown: function (server) {
server.close();
},
"is connected": function (topic) { "is connected": function (topic) {
assert.ok(topic.address().port); assert.ok(topic.address().port);
}, },
Expand Down

0 comments on commit a3fea60

Please sign in to comment.