         atom.workspace.open('sample.js')
 
       runs ->
-        editorView = atom.workspaceView.getActiveView()
-        {editor} = editorView
+        editor = atom.workspace.getActiveTextEditor()
         editor.setText("// ftp://github.com\n")
 
         spyOn(shell, 'openExternal')
-        editorView.trigger('link:open')
+        atom.commands.dispatch(atom.views.getView(editor), 'link:open')
         expect(shell.openExternal).not.toHaveBeenCalled()
 
         editor.setCursorBufferPosition([0,5])
-        editorView.trigger('link:open')
+        atom.commands.dispatch(atom.views.getView(editor), 'link:open')
 
         expect(shell.openExternal).not.toHaveBeenCalled()

    waitsForPromise ->
      atom.packages.activatePackage('language-hyperlink')

    atom.workspaceView = new WorkspaceView
    atom.workspace = atom.workspaceView.model

    waitsForPromise ->
      activationPromise = atom.packages.activatePackage('link')
      atom.workspaceView.trigger('link:open')
      activationPromise

  describe "when the cursor is on a link", ->

        atom.workspace.open('sample.js')

      runs ->
        editor = atom.workspace.getActiveTextEditor()
        editor.setText("// \"http://github.com\"")

        spyOn(shell, 'openExternal')
        atom.commands.dispatch(atom.views.getView(editor), 'link:open')
        expect(shell.openExternal).not.toHaveBeenCalled()

        editor.setCursorBufferPosition([0,4])
        atom.commands.dispatch(atom.views.getView(editor), 'link:open')

        expect(shell.openExternal).toHaveBeenCalled()
        expect(shell.openExternal.argsForCall[0][0]).toBe 'http://github.com'

        shell.openExternal.reset()
        editor.setCursorBufferPosition([0,8])
        atom.commands.dispatch(atom.views.getView(editor), 'link:open')

        expect(shell.openExternal).toHaveBeenCalled()
        expect(shell.openExternal.argsForCall[0][0]).toBe 'http://github.com'

        shell.openExternal.reset()
        editor.setCursorBufferPosition([0,21])
        atom.commands.dispatch(atom.views.getView(editor), 'link:open')

        expect(shell.openExternal).toHaveBeenCalled()
        expect(shell.openExternal.argsForCall[0][0]).toBe 'http://github.com'
