spec.plugins.hooks.js
This file
Path
spec/spec.plugins.hooks.js
46 lines · 1.1 KiB · JavaScript
Last changed by
Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b
History of this fileTake it
The walk stopped after 200 commits: lines older than fbf547d point at it.
Added Session classvisionmediabefore adoptionfbf547d
lines 1–4why, one step back12describe 'Express'3 before_each4 reset()Merge branch 'plugin-halt'visionmediabefore adoption1879648
lines 5–8why, one step back5 hooks = require('express/plugins/hooks')6 use(hooks.Hooks)7 hooks.callbacks.before = []8 hooks.callbacks.after = []Added Session classvisionmediabefore adoptionfbf547d
lines 9–21why, one step back9 end10 11 describe 'Hooks'12 describe 'before()'13 it 'should be called before every request'14 GLOBAL.before(function(){15 this.response.body = 'foo'16 })17 GLOBAL.before(function(){18 this.response.body += 'bar'19 })20 get('/user', function(){})21 get('/user').body.should.eql 'foobar'Merge branch 'plugin-halt'visionmediabefore adoption1879648
lines 22–25why, one step back22 end23 24 it 'should be able to halt the request'25 GLOBAL.before(function(){Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b
line 26why, one step back26 this.respond(404, 'woo!')Merge branch 'plugin-halt'visionmediabefore adoption1879648
lines 27–30why, one step back27 })28 get('/user', function(){ return 'fail' })29 get('/user').status.should.eql 40430 get('/user').body.should.eql 'woo!'Added Session classvisionmediabefore adoptionfbf547d
lines 31–46why, one step back31 end32 end33 34 describe 'after()'35 it 'should be called after every request'36 var body37 GLOBAL.after(function(){38 body = this.response.body39 })40 get('/user', function(){ return 'test' })41 get('/user').body.should.eql 'test'42 body.should.eql 'test'43 end44 end45 end46end