Skip to content
Myr

spec.request.js

This file

Path

spec/spec.request.js

247 lines · 8.2 KiB · JavaScript

Last changed by

Removed utils.mixin() use Object#mergeDeep()visionmediabefore adoption33277c3

History of this file

Take it

The walk stopped after 200 commits: lines older than 22e338f point at it.

Add support to StaticFile so that it works with non-textual files.ciaranjbefore adoption22e338f

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

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

Add support to StaticFile so that it works with non-textual files.ciaranjbefore adoption22e338f

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

Add support to StaticFile so that it works with non-textual files.ciaranjbefore adoption22e338f

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

Added Request#isXHR. Closes #229visionmediabefore adoption884d333

lines 42–58why, one step back
42 describe '#isXHR'
43 it 'should return false unless X-Requested-With is "XMLHttpRequest"'44 get('/', function(){ return this.isXHR ? 'yay' : 'nope' })45 get('/').body.should.eql 'nope'46 end47 48 it 'should return true when X-Requested-With is "XMLHttpRequest"'49 get('/', function(){ return this.isXHR ? 'yay' : 'nope' })50 get('/', { headers: { 'x-requested-with': 'XMLHttpRequest' }}).body.should.eql 'yay'51 end52 53 it 'should be case insensitive'54 get('/', function(){ return this.isXHR ? 'yay' : 'nope' })55 get('/', { headers: { 'x-requested-with': 'xmlhttprequest' }}).body.should.eql 'yay'56 end57 end58

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

lines 59–69why, one step back
59 describe '#accepts()'
60 describe 'when the Accept header is present'61 it 'should return true if the mime type is acceptable'62 get('/user', function(){ return this.accepts('jpeg').toString() })63 get('/user', { headers: { accept: 'image/jpeg' }}).body.should.eql 'true'64 end65 66 it 'should return false if the mime type is not present'67 get('/user', function(){ return this.accepts('html').toString() })68 get('/user', { headers: { accept: 'image/jpeg' }}).body.should.eql 'false'69 end

Add support to StaticFile so that it works with non-textual files.ciaranjbefore adoption22e338f

lines 70–71why, one step back
70 end
71

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

lines 72–74why, one step back
72 describe 'when the Accept header is not present'
73 it 'should return true'74 get('/user', function(){ return this.accepts('jpeg').toString() })

Removed utils.mixin() use Object#mergeDeep()visionmediabefore adoption33277c3

line 75why, one step back
75 get('/user', { headers: { accept: '' }}).body.should.eql 'true'

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

line 76why, one step back
76 end

Add support to StaticFile so that it works with non-textual files.ciaranjbefore adoption22e338f

line 77why, one step back
77 end

Merge branch 'integration'visionmediabefore adoption406a7f4

lines 78–100why, one step back
78
79 describe 'should allow multiple arguments'80 it 'should return true if any mime type is present'81 get('/user', function(){ return this.accepts('jpeg', 'png').toString() })82 get('/user', { headers: { accept: 'image/gif,image/png' }}).body.should.eql 'true'83 end84 85 it 'should return false if none of the mime types are present'86 get('/user', function(){ return this.accepts('jpeg', 'png').toString() })87 get('/user', { headers: { accept: 'text/plain,text/html' }}).body.should.eql 'false'88 end89 end90 91 describe 'when a media type range was sent'92 it 'should return true if the group media type matches'93 get('/user', function(){ return this.accepts('html').toString() })94 get('/user', { headers: { accept: 'text/plain,text/*' }}).body.should.eql 'true'95 end96 it 'should return false if the group media type does not match'97 get('/user', function(){ return this.accepts('ogg').toString() })98 get('/user', { headers: { accept: 'text/plain,text/*' }}).body.should.eql 'false'99 end100 end

Add support to StaticFile so that it works with non-textual files.ciaranjbefore adoption22e338f

lines 101–102why, one step back
101 end
102

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

lines 103–109why, one step back
103 describe '#halt()'
104 describe 'when given no arguments'105 it 'should respond with 404 Not Found'106 get('/user', function(){ this.halt() })107 get('/user').status.should.eql 404108 get('/user').body.should.include('Not Found')109 end

Add support to StaticFile so that it works with non-textual files.ciaranjbefore adoption22e338f

line 110why, one step back
110 end

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

lines 111–117why, one step back
111
112 describe 'when given a status code'113 it 'should respond with that status and its associated default body'114   get('/user', function(){ this.halt(400) })115   get('/user').status.should.eql 400116   get('/user').body.should.include('Bad Request')117 end

Add support to StaticFile so that it works with non-textual files.ciaranjbefore adoption22e338f

line 118why, one step back
118 end

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

lines 119–126why, one step back
119
120 describe 'when given a status code and body'121 it 'should respond with the status and its body'122 get('/user', function(){ this.halt(400, 'Oh noes!') })123 get('/user').status.should.eql 400124 get('/user').body.should.include('Oh noes!')125 end126 end

Add support to StaticFile so that it works with non-textual files.ciaranjbefore adoption22e338f

line 127why, one step back
127 end

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

lines 128–135why, one step back
128
129 describe '#contentType()'130 it 'should set Content-Type header with mime type passed'131 get('/style.css', function(){132 this.contentType('css')133 return 'body { background: white; }'134 })135 get('/style.css').headers['content-type'].should.eql 'text/css'

Add support to StaticFile so that it works with non-textual files.ciaranjbefore adoption22e338f

lines 136–137why, one step back
136 end
137 end

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

lines 138–146why, one step back
138
139 describe '#attachment()'140 it 'should set Content-Disposition to attachment'141 get('/report', function(){142 this.attachment()143 return 'foo'144 })145 get('/report').headers['content-disposition'].should.eql 'attachment'146 end

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

line 147why, one step back
147

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

lines 148–156why, one step back
148 it 'should set attachment filename'
149 get('/report', function(){150 this.attachment('report.pdf')151 return 'foo'152 })153 get('/report').headers['content-disposition'].should.eql 'attachment; filename="report.pdf"'154 end155 end156

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

lines 157–202why, one step back
157 describe '#param()'
158 it 'should return a route placeholder value'159 get('/user/:id', function(){160 return 'user ' + this.param('id')161 })162 get('/user/12').body.should.eql 'user 12'163 end164165 it 'should return several route placeholder values'166 get('/user/:id/:operation', function(){167 return this.param('operation') + 'ing user ' + this.param('id') 168 })169 get('/user/12/edit').body.should.eql 'editing user 12'170 end171172 it 'should allow optional placeholders'173 get('/user/:id?', function(){174 return this.param('id') ? 'user ' + this.param('id') : 'users'175 })176 get('/user/12').body.should.eql 'user 12'177 get('/user').body.should.eql 'users'178 end179180 it 'should allow placeholders as part of a segment'181 get('/report.:format', function(){182 return 'report as ' + this.param('format')183 })184 get('/report.csv').body.should.eql 'report as csv'185 get('/report.pdf').body.should.eql 'report as pdf'186 end187188 it 'should allow optional placeholders in middle segments'189 get('/user/:id?/edit', function(){190 return this.param('id') ? 'editing ' + this.param('id') : 'editing your account'191 })192 get('/user/12/edit').body.should.eql 'editing 12'193 get('/user/edit').body.should.eql 'editing your account'194 end195196 it 'should work with several routes'197 get('/user/:id', function(){ return this.param('id') })198 get('/product/:name', function(){ return this.param('name') })199 get('/user/12').body.should.eql '12'200 get('/product/ipod').body.should.eql 'ipod'201 end202

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

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

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

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

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

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

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

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

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

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

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

line 209why, one step back
209 get('/user?foo[]=bar&page=5').body.should.eql '5'

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

lines 210–217why, one step back
210 end
211212 it 'should work with splats'213 get('/:path/*.*', function(path, file, ext){214 return [path, file, ext].join(', ')215 })216 get('/public/app.js').body.should.eql 'public, app, js'217 end

Merge branch 'pull'visionmediabefore adoptionf008af0

lines 218–221why, one step back
218 end
219 220 describe '#pass()'221 it 'should pass control to the next matching route'

Request#pass() accepts a pathname stringvisionmediabefore adoption300cfe7

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

Merge branch 'pull'visionmediabefore adoptionf008af0

lines 223–224why, one step back
223 this.pass()
224 })

Request#pass() accepts a pathname stringvisionmediabefore adoption300cfe7

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

Merge branch 'pull'visionmediabefore adoptionf008af0

lines 226–228why, one step back
226 this.pass()
227 return 'nodejs'228 })

Request#pass() accepts a pathname stringvisionmediabefore adoption300cfe7

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

Merge branch 'pull'visionmediabefore adoptionf008af0

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

Request#pass() accepts a pathname stringvisionmediabefore adoption300cfe7

lines 232–245why, one step back
232
233 describe 'given a string'234 it 'should pass to the given route'235 get('/user', function(){236 this.pass('/user/1')237 })238 get('/user/:id', function(){239 return 'Supa doopa usa'240 })241 get('/user').body.should.eql 'Supa doopa usa'242 end243 end244 end245

Add support to StaticFile so that it works with non-textual files.ciaranjbefore adoption22e338f

lines 246–247why, one step back
246 end
247end