Permalink
Browse files

Added tests for regexp rules

  • Loading branch information...
tarruda committed Aug 30, 2012
1 parent 036b5d3 commit b359e9074230933dbba3ca484eb6ffb69333ee09
Showing with 22 additions and 0 deletions.
  1. +22 −0 test/router.coffee
View
@@ -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.