 
     it 'will untabify before an editor saves a buffer', ->
       atom.config.set('tabs-to-spaces.onSave', 'untabify')
-      buffer.setText('\t\tfoo\n\t\tbar\n\n')
+      editor.setText('\t\tfoo\n\t\tbar\n\n')
       editor.save()
       expect(editor.getText()).toBe '        foo\n        bar\n\n'
 
     it 'will tabify before an editor saves a buffer', ->
       atom.config.set('tabs-to-spaces.onSave', 'tabify')
-      buffer.setText('        foo\n        bar\n\n')
+      editor.setText('        foo\n        bar\n\n')
       editor.save()
       expect(editor.getText()).toBe '\t\tfoo\n\t\tbar\n\n'
 

      expect(editor.getText()).toBe ''

    it 'does change tabs at the end of a string', ->
      buffer.setText('foobarbaz\t')
      TabsToSpaces.untabifyAll(editor)
      expect(editor.getText()).toBe 'foobarbaz   '

    it 'does change tabs in the middle of a string', ->
      buffer.setText('foo\tbar\tbaz')
      TabsToSpaces.untabifyAll(editor)
      expect(editor.getText()).toBe 'foo   bar   baz'

    it 'changes one tab to the correct number of spaces', ->
      editor.setTabLength(2)
      buffer.setText('\tfoo')
      TabsToSpaces.untabifyAll(editor)
      expect(editor.getText()).toBe '  foo'

    it 'changes two tabs to the correct number of spaces', ->
      editor.setTabLength(2)
      buffer.setText('\t\tfoo')
      TabsToSpaces.untabifyAll(editor)
      expect(editor.getText()).toBe '    foo'

    it 'changes multiple lines of leading tabs to spaces', ->
      editor.setTabLength(2)
      buffer.setText('\t\tfoo\n\t\tbar\n\n')
      TabsToSpaces.untabifyAll(editor)
      expect(editor.getText()).toBe '    foo\n    bar\n\n'

    it 'changes mixed spaces and tabs to uniform whitespace', ->
      editor.setTabLength(2)
      buffer.setText(' \t foo\n')
      TabsToSpaces.untabifyAll(editor)
      expect(editor.getText()).toBe '    foo\n'


    atom.config.set('editor.tabLength', 4)

    waitsForPromise ->
      atom.workspace.open(filePath).then (e) ->
        editor = e

    waitsForPromise ->
      atom.packages.activatePackage('tabs-to-spaces')
