fixed overriding of path by mock request
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by csausdev · committed by csausdev · parent 14aded1 · Browse files · 6 files·+22 added−24 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+22 added−24 removed
- tests:+12 added−5 removed
- other:+10 added−19 removed
Provenance
- Commit
9fb91c6- Tree
a846751- Author
csausdev <gareth.jones@sensis.com.au>- Committer
csausdev <gareth.jones@sensis.com.au>- Parent
14aded1
6 files changed+22 added−24 removed
modified:lib/express.cookie.js+1 added-1 removed
30 unmodified lines3132333435353637383913 unmodified lines30 unmodified lines onRequest : { 'parse cookie' : function() { Express.response.cookie = Express.request.cookie = Express.parseCookie(Express.header('Cookie')) Express.parseCookie(Express.requestHeader('Cookie')); } }, onResponse : {13 unmodified linesmodified:lib/express.core.js+1 added-14 removed
306 unmodified lines307 308 arrayToHash : function(array) {309 var hash = {}310 for (var i = 0, len = array.length; i < len; ++i)311- hash[array[i][0]] = array[i][1]311+ hash[array[i][0].toLowerCase()] = array[i][1]312 return hash313 },314 315 /**406 unmodified lines722 use(Express.RedirectHelpers)723 724 })()725 726-get('user', function(){727- 'Foo'728-})729-730-put('user', function(){731- p('PUT')732-})733-734-del('user', function(){735- p('DELETE')736-})737-738-// Express.start()modified:lib/express.mocks.js+8 added-4 removed
82 unmodified lines83848586878889878889909191929394959697989920 unmodified lines82 unmodified lines function mockRouteFunctionFor(method) { var orig = Express.routeFunctionFor(method) return function(path, options, callback) { if ((options && options.constructor == Function) || (callback && callback.constructor == Function)) return orig.apply(Express, arguments) if ((options && options.constructor == Function) || (callback && callback.constructor == Function)) { return orig.apply(Express, arguments) } var request = mockRequest({ method : method.toUpperCase(), uri : { path : path }}) if (options) { if (options) JSpec.extend(request, options.request) JSpec.extend(request, options.request) //restore the path, since the mockRequest defaults it to "/" request.uri.path = path } var response = mockResponse() Express.server.callback(request, response) return Express.response }20 unmodified linesmodified:spec/spec.cookie.js+4 added-1 removed
16 unmodified lines17 it 'should parse cookie fields'18 get('foo', function() {19 cookie('q')20 })21- response = get('foo', { headers : [['Cookie', 'path=/; q=something; domain=.example.net']] })21+ request = mockRequest({ 22+ headers : [['Cookie', 'path=/; q=something; domain=.example.net']]23+ })24+ response = get('foo', { request: request })25 response.body.should.eql 'something'26 end27 end28 19 unmodified linesmodified:spec/spec.core.js+3 added-3 removed
143 unmodified lines144 145 describe '.arrayToHash()'146 it 'should map an assoc array to an object'147 headers = [['Content-Type', 'text/plain']]148- Express.arrayToHash(headers).should.eql { 'Content-Type' : 'text/plain' }148+ Express.arrayToHash(headers).should.eql { 'content-type' : 'text/plain' }149 end150 end151 152 describe '.redirect()'24 unmodified lines177 178 describe '.back'179 it 'should redirect to the referrer'180 uri = 'http://vision-media.ca'181- request = mockRequest({ headers : [['Referer', uri]] })181 get('foo', function(){ redirect(back) })182+ request = mockRequest({ headers : [['Referer', uri]] })183- get('foo', { request : request }).headers.location.should.eql uri183+ get('foo', { request: request }).headers.location.should.eql uri184 Express.back.should.eql uri185 end186 end187 end52 unmodified linesmodified:spec/spec.node.js+5 added-1 removed
13 unmodified lines14 })15 promise.wait()16 }17 18+if (process.ARGV[2]) {19+ JSpec.exec('spec/spec.'+process.ARGV[2]+'.js') 20+} else {21 JSpec22 .exec('spec/spec.core.js')23 .exec('spec/spec.routing.js')24 .exec('spec/spec.mocks.js')25 .exec('spec/spec.modules.js')26 .exec('spec/spec.mime.js')27 .exec('spec/spec.cookie.js')28 .exec('spec/spec.session.js')26- .exec('spec/spec.view.js')29+ .exec('spec/spec.view.js') 30+}31 JSpec.run({ formatter : JSpec.formatters.Terminal, failuresOnly : true })32 JSpec.report()33