Skip to content

Commit

Permalink
Added tests for regexp rules
Browse files Browse the repository at this point in the history
  • Loading branch information
tarruda committed Aug 30, 2012
1 parent 036b5d3 commit b359e90
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/router.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,25 @@ describe 'Conditional middlewares', ->
.end (res) ->
res.statusCode.should.eql(401)
done()


describe 'RegExp rule', ->
router = createRouter()
app = connect()
app.use(router.route)

router.get /^\/regexPath\/([0-9])$/i, (req, res) ->
res.write(req.params[0])
res.end()

it 'should ignore case', (done) ->
app.request()
.get('/REGEXPATH/5')
.end (res) ->
res.body.should.eql('5')
done()

it 'should not route when path doesnt match the pattern', (done) ->
app.request()
.get('/REGEXPATH/56')
.expect(404, done)

0 comments on commit b359e90

Please sign in to comment.