           expect(resultHandler).not.toHaveBeenCalled()
 
       it "scans buffer contents if the buffer is modified", ->
-        editor = atom.project.openSync("a")
-        editor.setText("Elephant")
-        results = []
+        editor = null
+        results = []
+
+        waitsForPromise ->
+          atom.project.open('a').then (o) ->
+            editor = o
+            editor.setText("Elephant")
+
         waitsForPromise ->
           atom.project.scan /a|Elephant/, (result) -> results.push result
 


    describe "when a buffer is already open", ->
      it "replaces properly and saves when not modified", ->
        editor = atom.project.openSync('sample.js')
        expect(editor.isModified()).toBeFalsy()

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

          expect(resultForA.matches[0].matchText).toBe 'Elephant'

      it "ignores buffers outside the project", ->
        editor = null
        results = []

        waitsForPromise ->
          atom.project.open(temp.openSync().path).then (o) ->
            editor = o
            editor.setText("Elephant")

        waitsForPromise ->
          atom.project.scan /Elephant/, (result) -> results.push result

