     waitsForPromise ->
       atom.workspace.destroyActivePaneItem()
       atom.workspace.open('test.txt').then ->
+        editor = atom.workspace.getActiveTextEditor()
         messageRegistry?.dispose()
         messageRegistry = new MessageRegistry()
+        messageRegistry.debouncedUpdate = ->
+        spyOn(messageRegistry, 'debouncedUpdate').andCallThrough()
     waitsForPromise ->
       atom.packages.activatePackage('linter')
 

      registryMessages = null
      linterRegistry.onDidUpdateMessages (linterInfo) ->
        messageRegistry.set(linterInfo)
        messageRegistry.updatePublic()

      messageRegistry.onDidUpdateMessages ({messages}) ->
        ++timesTriggered

          return linterRegistry.lint({onChange: false, editorLinter})
        ).then ->
          expect(timesTriggered).toBe(2)
          expect(registryMessages[0]).toBe(message)

  describe '::deleteByBuffer', ->
    it 'removes messages for that buffer', ->
      wasUpdated = 0
      {linterRegistry, editorLinter} = getLinterRegistry()
      buffer = editorLinter.editor.getBuffer()
      linterRegistry.onDidUpdateMessages (linterInfo) ->
        messageRegistry.set(linterInfo)
        expect(messageRegistry.debouncedUpdate).toHaveBeenCalled()
        messageRegistry.update()
      messageRegistry.onDidUpdateMessages ({messages}) ->
        wasUpdated = 1
        expect(objectSize(messages)).toBe(1)
        messageRegistry.deleteByBuffer(buffer)
      waitsForPromise ->
        linterRegistry.lint({onChange: false, editorLinter}).then ->
          expect(wasUpdated).toBe(1)
