spec.request.js
This file
Path
spec/spec.request.js
230 lines · 7.5 KiB · JavaScript
Last changed by
Request#pass() accepts a pathname stringvisionmediabefore adoption300cfe7
History of this fileTake it
The walk stopped after 200 commits: lines older than 48bea03 point at it.
Fixing cookie specsvisionmediabefore adoption48bea03
lines 1–5why, one step back12describe 'Express'3 before_each4 reset()5 endAdded specs for requests with content-type of "application/x-www-form-urlencoded"visionmediabefore adoption5a85db1
line 6why, one step back6 Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
lines 7–12why, one step back7 describe 'Request'8 describe '#status()'9 it 'should set the response status'10 get('/user', function(){ this.status(500) })11 get('/user').status.should.eql 50012 endFixing cookie specsvisionmediabefore adoption48bea03
line 13why, one step back13 endMerge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
lines 14–39why, one step back1415 describe '#header()'16 describe 'when given a field name and value'17 it 'should set the header'18 get('/user', function(){19 this.header('x-foo', 'bar')20 })21 get('/user').headers.should.have_property 'x-foo', 'bar'22 end 23 end2425 describe 'when given a field name'26 it 'should return a request header value'27 get('/user', function(){28 return this.header('host')29 })30 get('/user').body.should.eql 'localhost'31 end3233 it 'should be case-insensitive'34 get('/user', function(){35 return this.header('Host')36 })37 get('/user').body.should.eql 'localhost'38 end39 endFixing cookie specsvisionmediabefore adoption48bea03
lines 40–41why, one step back40 end41 Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
lines 42–52why, one step back42 describe '#accepts()'43 describe 'when the Accept header is present'44 it 'should return true if the mime type is acceptable'45 get('/user', function(){ return this.accepts('jpeg').toString() })46 get('/user', { headers: { accept: 'image/jpeg' }}).body.should.eql 'true'47 end48 49 it 'should return false if the mime type is not present'50 get('/user', function(){ return this.accepts('html').toString() })51 get('/user', { headers: { accept: 'image/jpeg' }}).body.should.eql 'false'52 endFixing cookie specsvisionmediabefore adoption48bea03
lines 53–54why, one step back53 end54 Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
lines 55–59why, one step back55 describe 'when the Accept header is not present'56 it 'should return true'57 get('/user', function(){ return this.accepts('jpeg').toString() })58 get('/user', { headers: { accept: null }}).body.should.eql 'true'59 endFixing cookie specsvisionmediabefore adoption48bea03
line 60why, one step back60 endMerge branch 'integration'visionmediabefore adoption406a7f4
lines 61–83why, one step back61 62 describe 'should allow multiple arguments'63 it 'should return true if any mime type is present'64 get('/user', function(){ return this.accepts('jpeg', 'png').toString() })65 get('/user', { headers: { accept: 'image/gif,image/png' }}).body.should.eql 'true'66 end67 68 it 'should return false if none of the mime types are present'69 get('/user', function(){ return this.accepts('jpeg', 'png').toString() })70 get('/user', { headers: { accept: 'text/plain,text/html' }}).body.should.eql 'false'71 end72 end73 74 describe 'when a media type range was sent'75 it 'should return true if the group media type matches'76 get('/user', function(){ return this.accepts('html').toString() })77 get('/user', { headers: { accept: 'text/plain,text/*' }}).body.should.eql 'true'78 end79 it 'should return false if the group media type does not match'80 get('/user', function(){ return this.accepts('ogg').toString() })81 get('/user', { headers: { accept: 'text/plain,text/*' }}).body.should.eql 'false'82 end83 endFixing cookie specsvisionmediabefore adoption48bea03
lines 84–85why, one step back84 end85 Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
lines 86–92why, one step back86 describe '#halt()'87 describe 'when given no arguments'88 it 'should respond with 404 Not Found'89 get('/user', function(){ this.halt() })90 get('/user').status.should.eql 40491 get('/user').body.should.include('Not Found')92 endFixing cookie specsvisionmediabefore adoption48bea03
line 93why, one step back93 endMerge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
lines 94–100why, one step back9495 describe 'when given a status code'96 it 'should respond with that status and its associated default body'97 get('/user', function(){ this.halt(400) })98 get('/user').status.should.eql 40099 get('/user').body.should.include('Bad Request')100 endFixing cookie specsvisionmediabefore adoption48bea03
line 101why, one step back101 endMerge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
lines 102–109why, one step back102103 describe 'when given a status code and body'104 it 'should respond with the status and its body'105 get('/user', function(){ this.halt(400, 'Oh noes!') })106 get('/user').status.should.eql 400107 get('/user').body.should.include('Oh noes!')108 end109 endFixing cookie specsvisionmediabefore adoption48bea03
line 110why, one step back110 endMerge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
lines 111–118why, one step back111112 describe '#contentType()'113 it 'should set Content-Type header with mime type passed'114 get('/style.css', function(){115 this.contentType('css')116 return 'body { background: white; }'117 })118 get('/style.css').headers['content-type'].should.eql 'text/css'Fixing cookie specsvisionmediabefore adoption48bea03
lines 119–120why, one step back119 end120 endMerge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption704c933
lines 121–129why, one step back121 122 describe '#attachment()'123 it 'should set Content-Disposition to attachment'124 get('/report', function(){125 this.attachment()126 return 'foo'127 })128 get('/report').headers['content-disposition'].should.eql 'attachment'129 endMerge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
line 130why, one step back130Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption704c933
lines 131–139why, one step back131 it 'should set attachment filename'132 get('/report', function(){133 this.attachment('report.pdf')134 return 'foo'135 })136 get('/report').headers['content-disposition'].should.eql 'attachment; filename="report.pdf"'137 end138 end139Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
lines 140–185why, one step back140 describe '#param()'141 it 'should return a route placeholder value'142 get('/user/:id', function(){143 return 'user ' + this.param('id')144 })145 get('/user/12').body.should.eql 'user 12'146 end147148 it 'should return several route placeholder values'149 get('/user/:id/:operation', function(){150 return this.param('operation') + 'ing user ' + this.param('id') 151 })152 get('/user/12/edit').body.should.eql 'editing user 12'153 end154155 it 'should allow optional placeholders'156 get('/user/:id?', function(){157 return this.param('id') ? 'user ' + this.param('id') : 'users'158 })159 get('/user/12').body.should.eql 'user 12'160 get('/user').body.should.eql 'users'161 end162163 it 'should allow placeholders as part of a segment'164 get('/report.:format', function(){165 return 'report as ' + this.param('format')166 })167 get('/report.csv').body.should.eql 'report as csv'168 get('/report.pdf').body.should.eql 'report as pdf'169 end170171 it 'should allow optional placeholders in middle segments'172 get('/user/:id?/edit', function(){173 return this.param('id') ? 'editing ' + this.param('id') : 'editing your account'174 })175 get('/user/12/edit').body.should.eql 'editing 12'176 get('/user/edit').body.should.eql 'editing your account'177 end178179 it 'should work with several routes'180 get('/user/:id', function(){ return this.param('id') })181 get('/product/:name', function(){ return this.param('name') })182 get('/user/12').body.should.eql '12'183 get('/product/ipod').body.should.eql 'ipod'184 end185Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption704c933
line 186why, one step back186 it 'should work with a query string'Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
line 187why, one step back187 get('/user', function(){Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption046bee8
line 188why, one step back188 return String(this.param('page') || 'First page')Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
lines 189–190why, one step back189 })190 get('/user').body.should.eql 'First page'Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoptione125ae2
line 191why, one step back191 get('/user?page=2').body.should.eql '2'Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption704c933
line 192why, one step back192 get('/user?foo[]=bar&page=5').body.should.eql '5'Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130
lines 193–200why, one step back193 end194195 it 'should work with splats'196 get('/:path/*.*', function(path, file, ext){197 return [path, file, ext].join(', ')198 })199 get('/public/app.js').body.should.eql 'public, app, js'200 endMerge branch 'pull'visionmediabefore adoptionf008af0
lines 201–204why, one step back201 end202 203 describe '#pass()'204 it 'should pass control to the next matching route'Request#pass() accepts a pathname stringvisionmediabefore adoption300cfe7
line 205why, one step back205 get('/user', function(){ Merge branch 'pull'visionmediabefore adoptionf008af0
lines 206–207why, one step back206 this.pass()207 })Request#pass() accepts a pathname stringvisionmediabefore adoption300cfe7
line 208why, one step back208 get('/user', function(){Merge branch 'pull'visionmediabefore adoptionf008af0
lines 209–211why, one step back209 this.pass()210 return 'nodejs'211 })Request#pass() accepts a pathname stringvisionmediabefore adoption300cfe7
line 212why, one step back212 get('/user', function(){ return 'success'})Merge branch 'pull'visionmediabefore adoptionf008af0
lines 213–214why, one step back213 get('/user').body.should.eql 'success'214 endRequest#pass() accepts a pathname stringvisionmediabefore adoption300cfe7
lines 215–228why, one step back215 216 describe 'given a string'217 it 'should pass to the given route'218 get('/user', function(){219 this.pass('/user/1')220 })221 get('/user/:id', function(){222 return 'Supa doopa usa'223 })224 get('/user').body.should.eql 'Supa doopa usa'225 end226 end227 end228 Fixing cookie specsvisionmediabefore adoption48bea03
lines 229–230why, one step back229 end230end