From 1f2e00ef8d00b6785125a989f118599c418b255a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 29 May 2014 22:53:59 -0400 Subject: [PATCH] deps: should@~4.0.0 --- examples/resource/app.js | 8 +++++--- package.json | 4 ++-- test/acceptance/ejs.js | 15 ++++++--------- test/acceptance/mvc.js | 27 ++++++++++---------------- test/acceptance/web-service.js | 8 ++------ test/res.cookie.js | 7 ++----- test/res.download.js | 35 ++++++++++++++++------------------ test/res.redirect.js | 16 ++++++---------- 8 files changed, 49 insertions(+), 71 deletions(-) diff --git a/examples/resource/app.js b/examples/resource/app.js index 7aa5b13d..ed1810e8 100644 --- a/examples/resource/app.js +++ b/examples/resource/app.js @@ -18,7 +18,10 @@ app.resource = function(path, obj) { obj.range(req, res, a, b, format); }); this.get(path + '/:id', obj.show); - this.delete(path + '/:id', obj.destroy); + this.delete(path + '/:id', function(req, res){ + var id = parseInt(req.params.id, 10); + obj.destroy(req, res, id); + }); }; // Fake records @@ -41,8 +44,7 @@ var User = { show: function(req, res){ res.send(users[req.params.id] || { error: 'Cannot find user' }); }, - destroy: function(req, res){ - var id = req.params.id; + destroy: function(req, res, id){ var destroyed = id in users; delete users[id]; res.send(destroyed ? 'destroyed' : 'Cannot find user'); diff --git a/package.json b/package.json index 786a5e9b..88e71591 100644 --- a/package.json +++ b/package.json @@ -65,8 +65,8 @@ "devDependencies": { "ejs": "~0.8.4", "istanbul": "0.2.10", - "mocha": "~1.19.0", - "should": "~3.3.1", + "mocha": "~1.20.0", + "should": "~4.0.0", "jade": "~0.30.0", "hjs": "~0.0.6", "stylus": "~0.40.0", diff --git a/test/acceptance/ejs.js b/test/acceptance/ejs.js index b51c03be..12defcb5 100644 --- a/test/acceptance/ejs.js +++ b/test/acceptance/ejs.js @@ -7,14 +7,11 @@ describe('ejs', function(){ it('should respond with html', function(done){ request(app) .get('/') - .end(function(err, res){ - res.should.have.status(200); - res.should.have.header('Content-Type', 'text/html; charset=utf-8'); - res.text.should.include('
  • tobi <tobi@learnboost.com>
  • '); - res.text.should.include('
  • loki <loki@learnboost.com>
  • '); - res.text.should.include('
  • jane <jane@learnboost.com>
  • '); - done(); - }); + .expect('Content-Type', 'text/html; charset=utf-8') + .expect(/
  • tobi <tobi@learnboost\.com><\/li>/) + .expect(/
  • loki <loki@learnboost\.com><\/li>/) + .expect(/
  • jane <jane@learnboost\.com><\/li>/) + .expect(200, done) }) }) -}) \ No newline at end of file +}) diff --git a/test/acceptance/mvc.js b/test/acceptance/mvc.js index 813c5506..3de481c6 100644 --- a/test/acceptance/mvc.js +++ b/test/acceptance/mvc.js @@ -47,13 +47,11 @@ describe('mvc', function(){ it('should display a list of users', function(done){ request(app) .get('/users') - .end(function(err, res){ - res.text.should.include('

    Users

    '); - res.text.should.include('>TJ<'); - res.text.should.include('>Guillermo<'); - res.text.should.include('>Nathan<'); - done(); - }) + .expect(/

    Users<\/h1>/) + .expect(/>TJGuillermoNathanTJ edit'); - done(); - }) + .expect(200, /

    TJ edit/, done) }) it('should display the users pets', function(done){ request(app) .get('/user/0') - .end(function(err, res){ - res.text.should.include('/pet/0">Tobi'); - res.text.should.include('/pet/1">Loki'); - res.text.should.include('/pet/2">Jane'); - done(); - }) + .expect(/\/pet\/0">Tobi/) + .expect(/\/pet\/1">Loki/) + .expect(/\/pet\/2">Jane/) + .expect(200, done) }) }) diff --git a/test/acceptance/web-service.js b/test/acceptance/web-service.js index 9fdf7a4e..e0f744ad 100644 --- a/test/acceptance/web-service.js +++ b/test/acceptance/web-service.js @@ -98,12 +98,8 @@ describe('web-service', function(){ it('should respond with 404 json', function(done){ request(app) .get('/api/something?api-key=bar') - .end(function(err, res){ - res.should.have.status(404); - res.should.be.json; - res.text.should.equal('{"error":"Lame, can\'t find that"}'); - done(); - }); + .expect('Content-Type', /json/) + .expect(404, '{"error":"Lame, can\'t find that"}', done) }) }) }) diff --git a/test/res.cookie.js b/test/res.cookie.js index a322b1d7..a00c8d14 100644 --- a/test/res.cookie.js +++ b/test/res.cookie.js @@ -89,7 +89,7 @@ describe('res', function(){ request(app) .get('/') .end(function(err, res){ - res.headers['set-cookie'][0].should.not.include('Thu, 01 Jan 1970 00:00:01 GMT'); + res.headers['set-cookie'][0].should.not.containEql('Thu, 01 Jan 1970 00:00:01 GMT'); done(); }) }) @@ -104,10 +104,7 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.headers['set-cookie'][0].should.include('Max-Age=1'); - done(); - }) + .expect('Set-Cookie', /Max-Age=1/, done) }) it('should not mutate the options object', function(done){ diff --git a/test/res.download.js b/test/res.download.js index 614e4320..0b9b0ba4 100644 --- a/test/res.download.js +++ b/test/res.download.js @@ -14,12 +14,9 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.should.have.header('Content-Type', 'text/html; charset=UTF-8'); - res.should.have.header('Content-Disposition', 'attachment; filename="user.html"'); - res.text.should.equal('

    {{user.name}}

    '); - done(); - }); + .expect('Content-Type', 'text/html; charset=UTF-8') + .expect('Content-Disposition', 'attachment; filename="user.html"') + .expect(200, '

    {{user.name}}

    ', done) }) }) @@ -33,11 +30,9 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.should.have.header('Content-Type', 'text/html; charset=UTF-8'); - res.should.have.header('Content-Disposition', 'attachment; filename="document"'); - done(); - }); + .expect('Content-Type', 'text/html; charset=UTF-8') + .expect('Content-Disposition', 'attachment; filename="document"') + .expect(200, done) }) }) @@ -52,10 +47,11 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.should.have.header('Content-Type', 'text/html; charset=UTF-8'); - res.should.have.header('Content-Disposition', 'attachment; filename="user.html"'); - }); + .expect('Content-Type', 'text/html; charset=UTF-8') + .expect('Content-Disposition', 'attachment; filename="user.html"') + .expect(200, function(err){ + assert.ifError(err) + }) }) }) @@ -70,10 +66,11 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.should.have.header('Content-Type', 'text/html; charset=UTF-8'); - res.should.have.header('Content-Disposition', 'attachment; filename="document"'); - }); + .expect('Content-Type', 'text/html; charset=UTF-8') + .expect('Content-Disposition', 'attachment; filename="document"') + .expect(200, function(err){ + assert.ifError(err) + }) }) }) diff --git a/test/res.redirect.js b/test/res.redirect.js index f13a070c..c5aab7f1 100644 --- a/test/res.redirect.js +++ b/test/res.redirect.js @@ -13,11 +13,8 @@ describe('res', function(){ request(app) .get('/') - .end(function(err, res){ - res.statusCode.should.equal(302); - res.headers.should.have.property('location', 'http://google.com'); - done(); - }) + .expect('location', 'http://google.com') + .expect(302, done) }) }) @@ -159,12 +156,11 @@ describe('res', function(){ request(app) .get('/') .set('Accept', 'application/octet-stream') - .end(function(err, res){ - res.should.have.status(302); - res.headers.should.have.property('location', 'http://google.com'); + .expect('location', 'http://google.com') + .expect('content-length', '0') + .expect(302, '', function(err, res){ + if (err) return done(err) res.headers.should.not.have.property('content-type'); - res.headers.should.have.property('content-length', '0'); - res.text.should.equal(''); done(); }) })