   describe 'with 400 status code', ->
 
     before ->
-        err =
-          error:              'error_code'
-          error_description:  'description'
-          statusCode:         400
-
-        req = {}
-
-        json = sinon.spy()
-        status = sinon.stub().returns { json: json }
-
-
-        res =
-          status: status
-          set: sinon.spy (headers) -> res.headers = headers
-          render: sinon.spy()
-          redirect: sinon.spy()
-        res.status.json = sinon.spy()
-
-        next = sinon.spy()
-
-        error err, req, res, next
+      err =
+        error:              'error_code'
+        error_description:  'description'
+        statusCode:         400
+
+      req =
+        app:
+          get: ->
+            'production'
+        connectParams: {}
+
+      json = sinon.spy()
+      status = sinon.stub().returns { json: json }
+
+
+      res =
+        status: status
+        set: sinon.spy (headers) -> res.headers = headers
+        render: sinon.spy()
+        redirect: sinon.spy()
+      res.status.json = sinon.spy()
+
+      next = sinon.spy()
+
+      error err, req, res, next
 
     it 'should respond 400', ->
       res.status.should.have.been.calledWith 400

  describe 'with other status code', ->

    before ->
        err =
          message:    'I am a teapot'
          statusCode: 418

        send = sinon.spy()
        status = sinon.stub().returns { send: send }

        req = {}
        res = { status: status }
        next = sinon.spy()
        error err, req, res, next


    it 'should respond with error status code', ->

  describe 'with 302 status code', ->

    before ->
      err =
        error:              'error_code'
        error_description:  'description'
        redirect_uri:       'https://client.tld/callback'
        statusCode:         302

      req =
        app:
          get: ->
            'production'
        connectParams: {}

      res =
        render: sinon.spy()
        redirect: sinon.spy()

      next = sinon.spy()

      error err, req, res, next

    it 'should redirect', ->
      res.redirect.should.have.been.calledWith sinon.match(err.redirect_uri)
