Skip to content
Myr

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 file

Take it

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

Fixing cookie specsvisionmediabefore adoption48bea03

lines 1–5why, one step back
1
2describe 'Express'3 before_each4 reset()5 end

Added specs for requests with content-type of "application/x-www-form-urlencoded"visionmediabefore adoption5a85db1

line 6why, one step back
6

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130

lines 7–12why, one step back
7 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 end

Fixing cookie specsvisionmediabefore adoption48bea03

line 13why, one step back
13 end

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130

lines 14–39why, one step back
14
15 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 end

Fixing cookie specsvisionmediabefore adoption48bea03

lines 40–41why, one step back
40 end
41

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130

lines 42–52why, one step back
42 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 end

Fixing cookie specsvisionmediabefore adoption48bea03

lines 53–54why, one step back
53 end
54

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130

lines 55–59why, one step back
55 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 end

Fixing cookie specsvisionmediabefore adoption48bea03

line 60why, one step back
60 end

Merge branch 'integration'visionmediabefore adoption406a7f4

lines 61–83why, one step back
61
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 end

Fixing cookie specsvisionmediabefore adoption48bea03

lines 84–85why, one step back
84 end
85

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130

lines 86–92why, one step back
86 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 end

Fixing cookie specsvisionmediabefore adoption48bea03

line 93why, one step back
93 end

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130

lines 94–100why, one step back
94
95 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 end

Fixing cookie specsvisionmediabefore adoption48bea03

line 101why, one step back
101 end

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130

lines 102–109why, one step back
102
103 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 end

Fixing cookie specsvisionmediabefore adoption48bea03

line 110why, one step back
110 end

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130

lines 111–118why, one step back
111
112 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 back
119 end
120 end

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption704c933

lines 121–129why, one step back
121
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 end

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130

line 130why, one step back
130

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption704c933

lines 131–139why, one step back
131 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 end139

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130

lines 140–185why, one step back
140 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 end185

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption704c933

line 186why, one step back
186 it 'should work with a query string'

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130

line 187why, one step back
187 get('/user', function(){

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption046bee8

line 188why, one step back
188 return String(this.param('page') || 'First page')

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption99e3130

lines 189–190why, one step back
189 })
190 get('/user').body.should.eql 'First page'

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoptione125ae2

line 191why, one step back
191 get('/user?page=2').body.should.eql '2'

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption704c933

line 192why, one step back
192 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 back
193 end
194195 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 end

Merge branch 'pull'visionmediabefore adoptionf008af0

lines 201–204why, one step back
201 end
202 203 describe '#pass()'204 it 'should pass control to the next matching route'

Request#pass() accepts a pathname stringvisionmediabefore adoption300cfe7

line 205why, one step back
205 get('/user', function(){

Merge branch 'pull'visionmediabefore adoptionf008af0

lines 206–207why, one step back
206 this.pass()
207 })

Request#pass() accepts a pathname stringvisionmediabefore adoption300cfe7

line 208why, one step back
208 get('/user', function(){

Merge branch 'pull'visionmediabefore adoptionf008af0

lines 209–211why, one step back
209 this.pass()
210 return 'nodejs'211 })

Request#pass() accepts a pathname stringvisionmediabefore adoption300cfe7

line 212why, one step back
212 get('/user', function(){ return 'success'})

Merge branch 'pull'visionmediabefore adoptionf008af0

lines 213–214why, one step back
213 get('/user').body.should.eql 'success'
214 end

Request#pass() accepts a pathname stringvisionmediabefore adoption300cfe7

lines 215–228why, one step back
215
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 back
229 end
230end