       describe 'which rejects', ->
 
         responseFake = null
-        errorFake = null
 
         beforeEach (done) ->
           responseFake = {}
-          errorFake = {}
+          errorFake = new Error 'The error message'
           rpcRequestMiddlewareStub.returns new Promise (resolve, reject) -> reject errorFake
           rpcHandlerStub.yields null, responseFake
           endpoint.initialize

      expect(ioStub.sockets.on.calledWith 'connection', sinon.match.func).to.be.ok


  describe 'receiving a eventric:joinRoom socket event', ->
    socketStub = null

    beforeEach ->



        it 'should emit a eventric:rpcResponse event with an error', ->
          expect(
            socketStub.emit.calledWith(
              'eventric:rpcResponse', {
                rpcId: rpcRequestFake.rpcId,
                error: {message: 'The error message', name: 'Error'},
                data: null
              }
            )
          ).to.be.ok


  describe '#publish', ->
