Skip to content
Myr

Added route specs with literal regular expressions

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

authored by visionmedia · committed by visionmedia · parent 01cd307 · Browse files · 1 file+16 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+16 added−0 removed

  • tests:+16 added−0 removed

1 file+16 added−0 removed

modified:spec/spec.routing.js+16 added
91 unmodified lines
92 -{ get('/user') }.should.throw_error(/InvalidResponseBody: get "\/user" did not respond with a body string/)93 end94 end95 96 describe 'with regular expression'97 it 'should match'98 get(/^\/user\/(\d+)\/(\w+)/, function(id, operation){99 return [id, operation].join(', ')100 })101 get('/user/12/edit').body.should.eql '12, edit'102 get('/user/12').status.should.eql 404103 end104 end105 106 describe 'with a wild-card'107 it 'should still match'108 get('/user/:id', function(){ return 'yay' })109 get('/user/12').body.should.eql 'yay'
55 unmodified lines
165 get('/report.csv').body.should.eql 'csv'166 get('/report').body.should.eql 'none'167 end168 169 it 'should allow common regexp literals'170 get('/user/(\\d+)', function(id){ return id })171 get('/user/12').body.should.eql '12'172 get('/user/asdf').status.should.eql 404173 end174 175 end176 177 describe 'with partial wild-card'178 it 'should still match'
139 unmodified lines