 
   beforeEach ->
     atom.workspaceView = new WorkspaceView()
+
     waitsForPromise ->
       atom.packages.activatePackage("autosave")
 
     runs ->
       atom.workspaceView.attachToDom()
-      initialActiveItem = atom.workspaceView.openSync('sample.js')
-      otherItem1 = atom.project.openSync('sample.coffee')
-      otherItem2 = otherItem1.copy()
 
+    waitsForPromise ->
+      atom.workspace.open('sample.js')
+
+    runs ->
+      initialActiveItem = atom.workspace.getActiveEditor()
+
+    waitsForPromise ->
+      atom.project.open('sample.coffee').then (o) ->
+        otherItem1 = o
+        otherItem2 = otherItem1.copy()
+
+    runs ->
       spyOn(initialActiveItem, 'save')
       spyOn(otherItem1, 'save')
       spyOn(otherItem2, 'save')

  describe "when the item is not modified", ->
    it "does not autosave the item", ->
      atom.config.set('autosave.enabled', true)
      leftPane = atom.workspaceView.getActivePane()
      rightPane = leftPane.splitRight(otherItem1)
      expect(initialActiveItem.save).not.toHaveBeenCalled()



    describe "when a new pane is created", ->
      it "saves the item if autosave is enabled and the item has a uri", ->
        leftPane = atom.workspaceView.getActivePaneView()
        rightPane = leftPane.splitRight(otherItem1)
        expect(initialActiveItem.save).not.toHaveBeenCalled()

