Skip to content
Myr

spec.plugins.hooks.js

This file

Path

spec/spec.plugins.hooks.js

34 lines · 778 bytes · JavaScript

Last changed by

Added before / after hook utilities [#54]visionmediabefore adoptiona8409ba

History of this file

Take it

Added before / after hook utilities [#54]visionmediabefore adoptiona8409ba

lines 1–34why, one step back
1
2describe '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'11 GLOBAL.before(function(e){12 e.response.body = 'foo'13 })14 GLOBAL.before(function(e){15 e.response.body += 'bar'16 })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 body25 GLOBAL.after(function(e){26 body = e.response.body27 })28 get('/user', function(){ return 'test' })29 get('/user').body.should.eql 'test'30 body.should.eql 'test'31 end32 end33 end34end