Skip to content

Instantly share code, notes, and snippets.

@tim-smart
Created June 22, 2010 23:24
Show Gist options
  • Save tim-smart/449260 to your computer and use it in GitHub Desktop.
Save tim-smart/449260 to your computer and use it in GitHub Desktop.
// HttpClient only calls 'success' once.
var respondsWith = function (code, body) {
var context = {
topic: function () {
var req = this.context.name.split(/ +/), // ["POST", "/"]
method = req[0].toLowerCase(), // "post"
path = req[1], // "/"
self = this;
new HttpClient({
method: method,
url: HOST + path,
success: function (response) {
self.callback(null, response);
}
}).end();
}
};
context['should respond with ' + code + ', ' + body] = function (err, response) {
assert.equal(code, response.statusCode);
assert.equal(body, response.body.toString('utf8'));
};
return context;
}
// My tests
vow.addBatch({
"GET /": respondsWith(200, "Some text")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment