 
       runs ->
         expect(totalBytes).toBe fs.statSync(filePath).size
-
-  describe ".bufferForPathSync(path)", ->
-    describe "when opening a previously opened path", ->
-      it "does not create a new buffer", ->
-        buffer = atom.project.bufferForPathSync("a").retain()
-        expect(atom.project.bufferForPathSync("a")).toBe buffer
-
-        alternativeBuffer = atom.project.bufferForPathSync("b").retain().release()
-        expect(alternativeBuffer).not.toBe buffer
-        buffer.release()
-
-      it "creates a new buffer if the previous buffer was destroyed", ->
-        buffer = atom.project.bufferForPathSync("a").retain().release()
-        expect(atom.project.bufferForPathSync("a").retain().release()).not.toBe buffer
 
   describe ".bufferForPath(path)", ->
     [buffer] = []

      deserializedProject?.destroy()

    it "does not include unretained buffers in the serialized state", ->
      atom.project.bufferForPathSync('a')
      expect(atom.project.getBuffers().length).toBe 1

      deserializedProject = atom.project.testSerialization()
      expect(deserializedProject.getBuffers().length).toBe 0

    it "listens for destroyed events on deserialized buffers and removes them when they are destroyed", ->
      atom.project.openSync('a')
      expect(atom.project.getBuffers().length).toBe 1
      deserializedProject = atom.project.testSerialization()

      expect(deserializedProject.getBuffers().length).toBe 1
      deserializedProject.getBuffers()[0].destroy()
      expect(deserializedProject.getBuffers().length).toBe 0

  describe "when an editor is saved and the project has no path", ->
    it "sets the project's path to the saved file's parent directory", ->
      tempFile = temp.openSync().path
      atom.project.setPath(undefined)
      expect(atom.project.getPath()).toBeUndefined()
      editor = atom.project.openSync()
      editor.saveAs(tempFile)
      expect(atom.project.getPath()).toBe path.dirname(tempFile)

  describe ".openSync(path)", ->
    [absolutePath, newBufferHandler] = []
    beforeEach ->
      absolutePath = require.resolve('./fixtures/dir/a')
      newBufferHandler = jasmine.createSpy('newBufferHandler')
      atom.project.on 'buffer-created', newBufferHandler

    describe "when given an absolute path that hasn't been opened previously", ->
      it "returns a new edit session for the given path and emits 'buffer-created'", ->
        editor = atom.project.openSync(absolutePath)
        expect(editor.buffer.getPath()).toBe absolutePath
        expect(newBufferHandler).toHaveBeenCalledWith editor.buffer

    describe "when given a relative path that hasn't been opened previously", ->
      it "returns a new edit session for the given path (relative to the project root) and emits 'buffer-created'", ->
        editor = atom.project.openSync('a')
        expect(editor.buffer.getPath()).toBe absolutePath
        expect(newBufferHandler).toHaveBeenCalledWith editor.buffer

    describe "when passed the path to a buffer that has already been opened", ->
      it "returns a new edit session containing previously opened buffer", ->
        editor = atom.project.openSync(absolutePath)
        newBufferHandler.reset()
        expect(atom.project.openSync(absolutePath).buffer).toBe editor.buffer
        expect(atom.project.openSync('a').buffer).toBe editor.buffer
        expect(newBufferHandler).not.toHaveBeenCalled()

    describe "when not passed a path", ->
      it "returns a new edit session and emits 'buffer-created'", ->
        editor = atom.project.openSync()
        expect(editor.buffer.getPath()).toBeUndefined()
        expect(newBufferHandler).toHaveBeenCalledWith(editor.buffer)

  describe ".open(path)", ->
    [absolutePath, newBufferHandler] = []

    beforeEach ->
      absolutePath = require.resolve('./fixtures/dir/a')
      newBufferHandler = jasmine.createSpy('newBufferHandler')
      atom.project.on 'buffer-created', newBufferHandler

    describe "when given an absolute path that isn't currently open", ->
      it "returns a new edit session for the given path and emits 'buffer-created'", ->
        editor = null

          expect(editor.isModified()).toBeFalsy()

      it "does not replace when the path is not specified", ->
        editor = null
        results = []

        waitsForPromise ->
          atom.project.open('sample-with-comments.js').then (o) -> editor = o

        waitsForPromise ->
          atom.project.replace /items/gi, 'items', [commentFilePath], (result) ->
            results.push(result)
