 
     it 'should allow to stop the Backbone.History', ->
       router.startHistory()
-      spy = sinon.spy(Backbone.history, 'stop')
+      spy = sinon.spy Backbone.history, 'stop'
       expect(router.stopHistory).to.be.a 'function'
       router.stopHistory()
       expect(Backbone.History.started).to.be false

      for prop in ['constructor', 'initialize', 'redirectTo', 'dispose']
        expect(-> router.match '', "null##{prop}").to.throwError()

    it 'should pass the route to the matchRoute handler', ->
      router.match 'passing-the-route', 'null#null'
      router.route '/passing-the-route'
      expect(route).to.be.a Route

    it 'should provide controller name and action', ->
      router.match 'controller/action', 'controller#action'
      router.route '/controller/action'
      expect(route.controller).to.be 'controller'
      expect(route.action).to.be 'action'

    it 'should accept a regular expression as pattern', ->
      router.match /^(\w+)\/(\w+)\/(\w+)$/, 'null#null'
      router.route '/raw/regular/expression'
      expect(params).to.be.an 'object'
      expect(params[0]).to.be 'raw'
      expect(params[1]).to.be 'regular'
      expect(params[2]).to.be 'expression'

    it 'should accept a empty regular expression as catch-all', ->
      router.match '', 'null#null'
      router.match /(?:)/, 'null#null'
      router.route "#{Math.random()}"
      expect(params).to.be.an 'object'

    it 'should extract named parameters', ->
      router.match 'params/:one/:p_two_123/three', 'null#null'
      router.route '/params/123-foo/456-bar/three'
      expect(params).to.be.an 'object'
      expect(params.one).to.be '123-foo'
      expect(params.p_two_123).to.be '456-bar'

    it 'should extract non-ascii named parameters', ->
      router.match 'params/:one/:two/:three/:four', 'null#null'
      router.route "/params/o_O/*.*/ü~ö~ä/#{encodeURIComponent('éêè')}"
      expect(params).to.be.an 'object'
      expect(params.one).to.be 'o_O'
      expect(params.two).to.be '*.*'
      expect(params.three).to.be 'ü~ö~ä'
      expect(params.four).to.be encodeURIComponent('éêè')

    it 'should match splat parameters', ->
      router.match 'params/:one/*two', 'null#null'
      router.route '/params/123-foo/456-bar/789-qux'
      expect(params).to.be.an 'object'
      expect(params.one).to.be '123-foo'
      expect(params.two).to.be '456-bar/789-qux'

    it 'should match splat parameters at the beginning', ->
      router.match 'params/*one/:two', 'null#null'
      router.route '/params/123-foo/456-bar/789-qux'
      expect(params).to.be.an 'object'
      expect(params.one).to.be '123-foo/456-bar'
      expect(params.two).to.be '789-qux'

    it 'should match splat parameters before a named parameter', ->
      router.match 'params/*one:two', 'null#null'
      router.route '/params/123-foo/456-bar/789-qux'
      expect(params).to.be.an 'object'
      expect(params.one).to.be '123-foo/456-bar/'
      expect(params.two).to.be '789-qux'

    it 'should impose constraints', ->
      spy = sinon.spy()


      expect(routed).to.be true
      expect(spy.callCount).to.be 1
      expect(passedParams).to.be.an 'object'
      expect(passedParams.one).to.be '1'
      expect(passedParams.two).to.be undefined

      mediator.unsubscribe 'matchRoute', spy

