 
     describe "when associated with an unsaved buffer", ->
       it "displays 'untitled' instead of the buffer's path, but still displays the buffer position", ->
-        atom.workspaceView.openSync()
-        StatusBar.activate()
-        statusBar = atom.workspaceView.find('.status-bar').view()
-        expect(StatusBar.fileInfo.currentPath.text()).toBe 'untitled'
-        expect(StatusBar.cursorPosition.text()).toBe '1,1'
+        waitsForPromise ->
+          atom.workspace.open()
+
+        runs ->
+          StatusBar.activate()
+          statusBar = atom.workspaceView.find('.status-bar').view()
+          expect(StatusBar.fileInfo.currentPath.text()).toBe 'untitled'
+          expect(StatusBar.cursorPosition.text()).toBe '1,1'
 
   describe ".deactivate()", ->
     it "removes the StatusBarView", ->

  describe "when the buffer changes", ->
    it "updates the buffer modified indicator for the new buffer", ->
      expect(StatusBar.fileInfo.bufferModified.text()).toBe ''
      atom.workspaceView.openSync('sample.txt')
      editor = atom.workspace.getActivePaneItem()
      editor.insertText("\n")
      advanceClock(buffer.stoppedChangingDelay)
      expect(StatusBar.fileInfo.bufferModified.text()).toBe '*'

    it "doesn't update the buffer modified indicator for the old buffer", ->
      oldBuffer = editor.getBuffer()
      expect(StatusBar.fileInfo.bufferModified.text()).toBe ''
      atom.workspaceView.openSync('sample.txt')
      oldBuffer.setText("new text")
      advanceClock(buffer.stoppedChangingDelay)
      expect(StatusBar.fileInfo.bufferModified.text()).toBe ''

  describe "when the associated editor's cursor position changes", ->
    it "updates the cursor position in the status bar", ->


    it "displays the current branch for files in repositories", ->
      atom.project.setPath(atom.project.resolve('git/master.git'))

      waitsForPromise ->
        atom.workspace.open('HEAD')

      runs ->
        expect(StatusBar.git.branchArea).toBeVisible()
        expect(StatusBar.git.branchLabel.text()).toBe 'master'

        atom.workspaceView.getActivePaneView().destroyItems()
        expect(StatusBar.git.branchArea).toBeVisible()
        expect(StatusBar.git.branchLabel.text()).toBe 'master'

      view = $$ -> @div id: 'view', tabindex: -1, 'View'
      atom.workspaceView.getActivePaneView().activateItem(view)
      expect(StatusBar.git.branchArea).not.toBeVisible()

    it "doesn't display the current branch for a file not in a repository", ->
      atom.project.setPath(os.tmpdir())

      waitsForPromise ->
        atom.workspace.open(path.join(os.tmpdir(), 'temp.txt'))

      runs ->
        expect(StatusBar.git.branchArea).toBeHidden()

    it "doesn't display the current branch for a file outside the current project", ->
      waitsForPromise ->
        atom.workspace.open(path.join(os.tmpdir(), 'atom-specs', 'not-in-project.txt'))

      runs ->
        expect(StatusBar.git.branchArea).toBeHidden()

  describe "git status label", ->
    [repo, filePath, originalPathText, newPath, ignorePath, ignoredPath, projectPath] = []
