 
+Promise = require 'bluebird'
 _ = require 'lodash'
 async = require 'async'
 expect = require('chai').expect

          ], done

  it 'should emit consistencyFailure on socket leave errors', (done) ->
    chatService = startService { state : 'memory' }
    chatService.addRoom roomName1, null, ->
      socket1 = clientConnect user1
      socket1.on 'loginConfirmed', (userName, { id }) ->

          chatService.state.getRoom roomName1
          .then (room) ->
            orig = room.leave
            room.__proto__.leave = ->
              Promise.reject new Error()
            setCustomCleanup (cb) ->
              room.__proto__.leave = orig
              chatService.close cb
            async.parallel [
              (cb) ->
