Skip to content
Myr

Added specs for header()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent df18edc · Browse files · 4 files+41 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+41 added−1 removed

  • tests:+30 added−0 removed
  • other:+11 added−1 removed

4 files+41 added−1 removed

modified:lib/express/spec/mock-routes.js+1 added
modified:lib/express/dsl.js+1 added-1 removed
modified:lib/express/helpers.js+10 added
45 unmodified lines
46exports.jsonEncode = function(object) {47 return JSON.stringify(object)48}4950exports.jsonDecode = function(string) {51 return JSON.parse(string)52}5354exports.dirname = function(path) {55 return path.split('/').slice(0, -1).join('/')56}57
5 unmodified lines
63exports.param = function(key) {64 return Express.router.params[key]65}6667exports.header = function(key, val) {68 return value === undefined ?69 Express.server.response.headers[key.toLowerCase()] :70 Express.server.response.headers[key.toLowerCase()] = val71}7273var status = exports.status = function(code) {74 return Express.server.response.status = code75}76
55 unmodified lines
modified:spec/spec.core.helpers.js+29 added
49 unmodified lines
50 get('/user').status.should.eql 50051 end52 end53 54 describe 'header()'55 describe 'when given a field name and value'56 it 'should set the header'57 get('/user', function(){58 header('x-foo', 'bar')59 })60 get('/user').headers.should.have_property 'x-foo', 'bar'61 end 62 end63 64 describe 'when given a field name'65 it 'should return a response headers current value'66 get('/user', function(){67 header('x-foo', 'bar')68 return header('x-foo')69 })70 get('/user').body.should.eql 'bar'71 end72 73 it 'should base case-insensitive'74 get('/user', function(){75 header('X-Foo', 'bar')76 return header('x-Foo')77 })78 get('/user').body.should.eql 'bar'79 end80 end81 end82 83 describe 'halt()'84 describe 'when given no arguments'85 it 'should respond with 404 Not Found'86 get('/user', function(){ halt() })
75 unmodified lines