Skip to content

Commit

Permalink
deps: should@~4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed May 30, 2014
1 parent b49453c commit 1f2e00e
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 71 deletions.
8 changes: 5 additions & 3 deletions examples/resource/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 6 additions & 9 deletions test/acceptance/ejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<li>tobi &lt;[email protected]&gt;</li>');
res.text.should.include('<li>loki &lt;[email protected]&gt;</li>');
res.text.should.include('<li>jane &lt;[email protected]&gt;</li>');
done();
});
.expect('Content-Type', 'text/html; charset=utf-8')
.expect(/<li>tobi &lt;tobi@learnboost\.com&gt;<\/li>/)
.expect(/<li>loki &lt;loki@learnboost\.com&gt;<\/li>/)
.expect(/<li>jane &lt;jane@learnboost\.com&gt;<\/li>/)
.expect(200, done)
})
})
})
})
27 changes: 10 additions & 17 deletions test/acceptance/mvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<h1>Users</h1>');
res.text.should.include('>TJ<');
res.text.should.include('>Guillermo<');
res.text.should.include('>Nathan<');
done();
})
.expect(/<h1>Users<\/h1>/)
.expect(/>TJ</)
.expect(/>Guillermo</)
.expect(/>Nathan</)
.expect(200, done)
})
})

Expand All @@ -62,21 +60,16 @@ describe('mvc', function(){
it('should display the user', function(done){
request(app)
.get('/user/0')
.end(function(err, res){
res.text.should.include('<h1>TJ <a href="/user/0/edit">edit');
done();
})
.expect(200, /<h1>TJ <a href="\/user\/0\/edit">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)
})
})

Expand Down
8 changes: 2 additions & 6 deletions test/acceptance/web-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})
7 changes: 2 additions & 5 deletions test/res.cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
})
})
Expand All @@ -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){
Expand Down
35 changes: 16 additions & 19 deletions test/res.download.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<p>{{user.name}}</p>');
done();
});
.expect('Content-Type', 'text/html; charset=UTF-8')
.expect('Content-Disposition', 'attachment; filename="user.html"')
.expect(200, '<p>{{user.name}}</p>', done)
})
})

Expand All @@ -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)
})
})

Expand All @@ -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)
})
})
})

Expand All @@ -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)
})
})
})

Expand Down
16 changes: 6 additions & 10 deletions test/res.redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

Expand Down Expand Up @@ -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();
})
})
Expand Down

0 comments on commit 1f2e00e

Please sign in to comment.