   describe 'Unit Tests', ->
     describe '#receive', ->
       it 'calls all registered listeners', ->
+        # Need to use a real Message so that the CatchAllMessage constructor works
         testMessage = new TextMessage(@user, 'message123')
 
         listener =


      expect(listenerCallback).to.not.have.been.called

    it 'gracefully handles listener uncaughtExceptions', (done) ->
      testMessage = new TextMessage(@user, 'message123')
      theError = new Error()

      @robot.hear /^message123$/, (response) ->
        throw theError

      @robot.emit = (name, err, response) ->
        expect(name).to.equal('error')
        expect(err).to.equal(theError)
        expect(response.message).to.equal(testMessage)
        done()

      @robot.receive testMessage

    it 'calls non-TextListener objects', (done) ->
      testMessage = new EnterMessage @user


        done()
      @robot.receive testMessage

    it 'calls multiple matching listeners', ->
      testMessage = new TextMessage(@user, 'message123')

      listenersCalled = 0
      listenerCallback = (response) ->
        expect(response.message).to.equal(testMessage)
        listenersCalled++

      @robot.hear /^message123$/, listenerCallback
      @robot.hear /^message123$/, listenerCallback

      @robot.receive testMessage

      expect(listenersCalled).to.equal(2)

    it 'calls the catch-all listener if no listeners match', (done) ->
      testMessage = new TextMessage(@user, 'message123')
