Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than f09358b point at it.

Fixed wiki urivisionmediabefore adoptionf09358b

lines 1–10why, 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'

Hooks are now called in context to the requestvisionmediabefore adoption202c74d

lines 11–12why, one step back
11 GLOBAL.before(function(){
12 this.response.body = 'foo'

Fixed wiki urivisionmediabefore adoptionf09358b

line 13why, one step back
13 })

Hooks are now called in context to the requestvisionmediabefore adoption202c74d

lines 14–15why, one step back
14 GLOBAL.before(function(){
15 this.response.body += 'bar'

Fixed wiki urivisionmediabefore adoptionf09358b

lines 16–24why, one step back
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 body

Hooks are now called in context to the requestvisionmediabefore adoption202c74d

lines 25–26why, one step back
25 GLOBAL.after(function(){
26 body = this.response.body

Fixed wiki urivisionmediabefore adoptionf09358b

lines 27–34why, one step back
27 })
28 get('/user', function(){ return 'test' })29 get('/user').body.should.eql 'test'30 body.should.eql 'test'31 end32 end33 end34end