spec.plugins.hooks.js
This file
Path
spec/spec.plugins.hooks.js
46 lines · 1.1 KiB · JavaScript
Last changed by
Merge branch 'plugin-halt'visionmediabefore adoption1879648
History of this fileTake it
The walk stopped after 200 commits: lines older than 2b02305 point at it.
CommonLogger showing "/" as rootvisionmediabefore adoption2b02305
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 = []CommonLogger showing "/" as rootvisionmediabefore adoption2b02305
lines 9–13why, one step back9 end10 11 describe 'Hooks'12 describe 'before()'13 it 'should be called before every request'Hooks are now called in context to the requestvisionmediabefore adoption202c74d
lines 14–15why, one step back14 GLOBAL.before(function(){15 this.response.body = 'foo'CommonLogger showing "/" as rootvisionmediabefore adoption2b02305
line 16why, one step back16 })Hooks are now called in context to the requestvisionmediabefore adoption202c74d
lines 17–18why, one step back17 GLOBAL.before(function(){18 this.response.body += 'bar'CommonLogger showing "/" as rootvisionmediabefore adoption2b02305
lines 19–21why, one step back19 })20 get('/user', function(){})21 get('/user').body.should.eql 'foobar'Merge branch 'plugin-halt'visionmediabefore adoption1879648
lines 22–30why, one step back22 end23 24 it 'should be able to halt the request'25 GLOBAL.before(function(){26 this.halt(404, 'woo!')27 })28 get('/user', function(){ return 'fail' })29 get('/user').status.should.eql 40430 get('/user').body.should.eql 'woo!'CommonLogger showing "/" as rootvisionmediabefore adoption2b02305
lines 31–36why, one step back31 end32 end33 34 describe 'after()'35 it 'should be called after every request'36 var bodyHooks are now called in context to the requestvisionmediabefore adoption202c74d
lines 37–38why, one step back37 GLOBAL.after(function(){38 body = this.response.bodyCommonLogger showing "/" as rootvisionmediabefore adoption2b02305
lines 39–46why, one step back39 })40 get('/user', function(){ return 'test' })41 get('/user').body.should.eql 'test'42 body.should.eql 'test'43 end44 end45 end46end