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

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


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

    beforeEach ->

      describe 'which rejects', ->

        responseFake = null

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