Skip to content
Myr

spec.modules.js

This file

Path

spec/spec.modules.js

87 lines · 1.9 KiB · JavaScript

Last changed by

Module init now accepts arguments [#28]visionmediabefore adoption4b368af

History of this file

Take it

Added hookImmutable()visionmediabefore adoption78ee497

lines 1–3why, one step back
1
2use({3 name : 'foo',

Module init now accepts arguments [#28]visionmediabefore adoption4b368af

lines 4–5why, one step back
4 init : function(a, b) {
5 argA = a, argB = b

Added hookImmutable()visionmediabefore adoption78ee497

line 6why, one step back
6 initCalled = true

Module init now accepts arguments [#28]visionmediabefore adoption4b368af

line 7why, one step back
7 initContext = this

Added hookImmutable()visionmediabefore adoption78ee497

lines 8–20why, one step back
8 },
9 10 settings : {11 one : 1,12 two : 213 },14 15 utilities : {16 foo : function(){17 return 'bar'18 }19 },20

Fixed hookImmutable()visionmediabefore adoption2035c31

lines 21–24why, one step back
21 onFoo : {
22 'return bar' : function(one, two) {23 return 'bar ' + one + ' ' + two24 }

Added hookImmutable()visionmediabefore adoption78ee497

lines 25–26why, one step back
25 },
26

Fixed hookImmutable()visionmediabefore adoption2035c31

lines 27–34why, one step back
27 onFooImmutable : {
28 'test one' : function(immutable, arg) {29 return 'one ' + immutable30 },31 32 'test two' : function(immutable, arg) {33 return immutable + ' two'34 }

Added hookImmutable()visionmediabefore adoption78ee497

line 35why, one step back
35 }

Module init now accepts arguments [#28]visionmediabefore adoption4b368af

line 36why, one step back
36}, 'foo', 'bar')

Added hookImmutable()visionmediabefore adoption78ee497

lines 37–45why, one step back
37
38describe 'Express'39 describe 'Modules'40 before_each41 Express.routes = []42 end43 44 it 'should call init when passed to use()'45 initCalled.should.be_true

Module init now accepts arguments [#28]visionmediabefore adoption4b368af

lines 46–54why, one step back
46 end
47 48 it 'should pass args to init'49 argA.should.eql 'foo'50 argB.should.eql 'bar'51 end52 53 it 'should have module context'54 initContext.name.should.eql 'foo'

Added hookImmutable()visionmediabefore adoption78ee497

lines 55–82why, one step back
55 end
56 57 it 'should merge utilities'58 Express.utilities.foo().should.eql 'bar'59 end60 61 it 'should expose utilities to routes'62 get('foo', function(){ foo() })63 get('foo').body.should.eql 'bar'64 end65 66 it 'should merge settings'67 Express.settings.foo.one.should.eql 168 Express.settings.foo.two.should.eql 269 end70 71 it 'should throw error when trying to merge settings without module name'72 -{ use({ settings : { foo : 'bar' }}) }.should.throw_error(/module name is required/)73 end74 75 describe 'hook()'76 it 'should call hook implementations returning an array of results'77 Express.hook('onFoo', 'test', 'stuff').should.eql ['bar test stuff']78 end79 end80 81 describe 'hookImmutable'82 it 'should call hook implementations sequencially passing the first argument passed'

Fixed hookImmutable()visionmediabefore adoption2035c31

line 83why, one step back
83 Express.hookImmutable('onFooImmutable', 'test').should.eql 'one test two'

Added hookImmutable()visionmediabefore adoption78ee497

lines 84–87why, one step back
84 end
85 end86 end87end