spec.plugins.hooks.js
This file
Path
spec/spec.plugins.hooks.js
34 lines · 784 bytes · JavaScript
Last changed by
Hooks are now called in context to the requestvisionmediabefore adoption202c74d
History of this fileTake it
The walk stopped after 200 commits: lines older than 521fb0b point at it.
Pre-loading view engine modules to prevent overhead of module loadingvisionmediabefore adoption521fb0b
lines 1–10why, one step back12describe 'Express'3 before_each4 reset()5 use(require('express/plugins/hooks').Hooks)6 end7 8 describe 'Hooks'9 describe 'before()'10 it 'should be called before every request'Hooks are now called in context to the requestvisionmediabefore adoption202c74d
lines 11–12why, one step back11 GLOBAL.before(function(){12 this.response.body = 'foo'Pre-loading view engine modules to prevent overhead of module loadingvisionmediabefore adoption521fb0b
line 13why, one step back13 })Hooks are now called in context to the requestvisionmediabefore adoption202c74d
lines 14–15why, one step back14 GLOBAL.before(function(){15 this.response.body += 'bar'Pre-loading view engine modules to prevent overhead of module loadingvisionmediabefore adoption521fb0b
lines 16–24why, one step back16 })17 get('/user', function(){})18 get('/user').body.should.eql 'foobar'19 end20 end21 22 describe 'after()'23 it 'should be called after every request'24 var bodyHooks are now called in context to the requestvisionmediabefore adoption202c74d
lines 25–26why, one step back25 GLOBAL.after(function(){26 body = this.response.bodyPre-loading view engine modules to prevent overhead of module loadingvisionmediabefore adoption521fb0b
lines 27–34why, one step back27 })28 get('/user', function(){ return 'test' })29 get('/user').body.should.eql 'test'30 body.should.eql 'test'31 end32 end33 end34end