     atom.config.set('editor.tabLength', 4)
 
     waitsForPromise ->
-      atom.workspace.open(filePath).then (e) -> editor = e
-
-    runs ->
-      buffer = editor.getBuffer()
+      atom.workspace.open(filePath).then (e) ->
+        editor = e
 
     waitsForPromise ->
       atom.packages.activatePackage('tabs-to-spaces')

        spyOn(atom.config, 'getUserConfigPath').andReturn(filePath)
        spyOn(editor, 'getPath').andReturn(filePath)

        buffer.setText('    foo\n    bar\n\n')
        editor.save()
        expect(editor.getText()).toBe '    foo\n    bar\n\n'


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

