     [filePath, modifiedHandler, doneFunc] = []
 
     beforeEach (done) ->
-      filePath = join(temp.dir, 'atom-tmp-file')
+      tempDir = temp.mkdirSync()
+      filePath = join(tempDir, 'atom-tmp-file')
       fs.writeFileSync(filePath, '')
       buffer = new TextBuffer({filePath, load: false})
       buffer.load().then ->

      [backupFilePath, saveAsBuffer] = []

      beforeEach ->
        filePath = join(temp.dir, 'temp.txt')
        saveAsBuffer = new TextBuffer()
        saveAsBuffer.setText 'Buffer contents'
        backupFilePath = filePath + '~'

      [changeHandler, originalPath, newPath, saveAsBuffer, doneFunc] = []
      beforeEach (done) ->
        changeHandler = null
        originalPath = join(tempDir, 'original.txt')
        newPath = join(tempDir, 'new.txt')
        fs.writeFileSync(originalPath, "")

        saveAsBuffer = new TextBuffer({filePath: originalPath, load: false})
