6 var assert = require('assert')
7 , http = require('http');
9 var server = http.createServer(function(req, res){
10 if (req.method === 'GET') {
11 if (req.url === '/delay') {
12 setTimeout(function(){
13 res.writeHead(200, {});
17 var body = JSON.stringify({ name: 'tj' });
19 'Content-Type': 'application/json; charset=utf8',
20 'Content-Length': body.length
26 req.setEncoding('utf8');
27 req.addListener('data', function(chunk){ body += chunk });
28 req.addListener('end', function(){
29 res.writeHead(200, {});
30 res.end(req.url + ' ' + body);
36 'test assert.response()': function(done){
37 assert.response(server, {
41 body: '{"name":"tj"}',
44 'Content-Type': 'application/json; charset=utf8'