         spyOn(preview, 'showLoading')
 
         runs ->
-          preview.file.writeSync "Hey!"
-
-        waitsFor ->
+          fs.writeFileSync(preview.getPath(), "Hey!")
+
+        waitsFor "contents to update", ->
           preview.text().indexOf("Hey!") >= 0
 
         runs ->

          preview.onDidChangeTitle(titleChangedCallback)
          fs.renameSync(preview.getPath(), path.join(path.dirname(preview.getPath()), 'file2.md'))

        waitsFor ->
          preview.getTitle() is "file2.md Preview"

        runs ->

        preview.onDidChangeMarkdown(listener = jasmine.createSpy('didChangeMarkdownListener'))

        runs ->
          fs.writeFileSync(preview.getPath(), "Hey!")

        waitsFor "::onDidChangeMarkdown handler to be called", ->
          listener.callCount > 0
