Added splat specs
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent 9ece51e · Browse files · 1 file·+57 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+57 added−0 removed
- tests:+57 added−0 removed
Provenance
- Commit
cd24b58- Tree
f298c0a- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
9ece51e
1 file changed+57 added−0 removed
modified:spec/spec.routing.js+57 added
166 unmodified lines167 get('/report.').body.should.eql 'Not Found'168 end169 end170 171+ describe 'with a single splat'172+ it 'should match a single segment'173+ get('/public/*', function(file){174+ return file175+ })176+ get('/public/app.js').body.should.eql 'app.js'177+ end178+ 179+ it 'should not match when there is nothing to capture'180+ get('/public/*', function(file){181+ return file182+ })183+ get('/public/').status.should.eql 404184+ get('/public').status.should.eql 404185+ end186+ 187+ it 'should match a multiple segments'188+ get('/public/*', function(file){189+ return file190+ })191+ get('/public/javascripts/app.js').body.should.eql 'javascripts/app.js'192+ end193+ end194+ 195+ describe 'with several splats'196+ it 'should greedily match'197+ get('/public/*.*', function(path, ext){198+ return 'path: ' + path + ' ext: ' + ext199+ })200+ get('/public/app.js').body.should.eql 'path: app ext: js'201+ end202+ 203+ it 'should not match when there is nothing to capture'204+ get('/public/*.*', function(file){205+ return file206+ })207+ get('/public/foo.').status.should.eql 404208+ get('/public/foo').status.should.eql 404209+ get('/public/').status.should.eql 404210+ get('/public').status.should.eql 404211+ end212+ 213+ it 'should greedily match several segments'214+ get('/public/*.*', function(path, ext){215+ return 'path: ' + path + ' ext: ' + ext216+ })217+ get('/public/javascripts/app.js').body.should.eql 'path: javascripts/app ext: js'218+ end219+ 220+ it 'should greedily match several segments'221+ get('/public/*/*.*', function(dir, path, ext){222+ return 'dir: ' + dir + ' path: ' + path + ' ext: ' + ext223+ })224+ get('/public/javascripts/app.js').body.should.eql 'dir: javascripts path: app ext: js'225+ end226+ end227+ 228 describe 'with an unmatchable request path'229 describe 'with "helpful 404" enabled'230 it 'should show the help html'231 enable('helpful 404')63 unmodified lines