Permalink
Browse files

add inspect() to body messages

  • Loading branch information...
1 parent b974ce6 commit 76df78a8c596a9de98290e1499418a3fea5dd0b7 @tj tj committed Jun 26, 2012
Showing with 8 additions and 3 deletions.
  1. +4 −1 lib/test.js
  2. +4 −2 test/supertest.js
View
@@ -5,6 +5,7 @@
*/
var request = require('superagent')
+ , util = require('util')
, Request = request.Request;
/**
@@ -113,7 +114,9 @@ Test.prototype.assert = function(res, fn){
// body
if (null != body && body !== res.text) {
- return fn(new Error('expected "' + body + '" response body, got "' + res.text + '"'));
+ var a = util.inspect(body);
+ var b = util.inspect(res.text);
+ return fn(new Error('expected ' + a + ' response body, got ' + b));
}
fn(null, res);
View
@@ -59,15 +59,17 @@ describe('request(app)', function(){
it('should assert the response body', function(done){
var app = express();
+ app.set('json spaces', 0);
+
app.get('/', function(req, res){
- res.send('heys');
+ res.send({ foo: 'bar' });
});
request(app)
.get('/')
.expect('hey')
.end(function(err, res){
- err.message.should.equal('expected "hey" response body, got "heys"');
+ err.message.should.equal('expected \'hey\' response body, got \'{"foo":"bar"}\'');
done();
});
})

0 comments on commit 76df78a

Please sign in to comment.