 
     describe 'when creating a theme', ->
       beforeEach ->
-        atom.workspaceView.trigger("package-generator:generate-syntax-theme")
+        atom.commands.dispatch(getWorkspaceView(), "package-generator:generate-syntax-theme")
 
         waitsForPromise ->
           activationPromise
 
       describe "when the theme is created outside of the packages directory", ->
         it "calls `apm init` and `apm link`", ->
-          packageGeneratorView = atom.workspaceView.find(".package-generator").view()
-          expect(packageGeneratorView.hasParent()).toBeTruthy()
-          packageGeneratorView.miniEditor.setText(packagePath)
-          apmExecute = spyOn(packageGeneratorView, 'runCommand').andCallFake (command, args, exit) ->
-            process.nextTick -> exit()
-          packageGeneratorView.trigger "core:confirm"
+          packageGeneratorView = $(getWorkspaceView()).find(".package-generator").view()
+          expect(packageGeneratorView.hasParent()).toBeTruthy()
+          packageGeneratorView.miniEditor.setText(packagePath)
+          apmExecute = spyOn(packageGeneratorView, 'runCommand').andCallFake (command, args, exit) ->
+            process.nextTick -> exit()
+          atom.commands.dispatch(packageGeneratorView.element, "core:confirm")
 
           waitsFor ->
             atom.open.callCount is 1


    describe 'when creating a package', ->
      beforeEach ->
        atom.workspaceView.trigger("package-generator:generate-package")

        waitsForPromise ->
          activationPromise

            expect(apmExecute.argsForCall[1]).toBeUndefined()

    it "displays an error when the package path already exists", ->
      jasmine.attachToDOM(getWorkspaceView())
      fs.makeTreeSync(packagePath)
      atom.commands.dispatch(getWorkspaceView(), "package-generator:generate-package")

      waitsForPromise ->
        activationPromise

      runs ->
        packageGeneratorView = $(getWorkspaceView()).find(".package-generator").view()

        expect(packageGeneratorView.hasParent()).toBeTruthy()
        expect(packageGeneratorView.error).not.toBeVisible()
        packageGeneratorView.miniEditor.setText(packagePath)
        atom.commands.dispatch(packageGeneratorView.element, "core:confirm")
        expect(packageGeneratorView.hasParent()).toBeTruthy()
        expect(packageGeneratorView.error).toBeVisible()

    it "opens the package", ->
      atom.commands.dispatch(getWorkspaceView(), "package-generator:generate-package")

      waitsForPromise ->
        activationPromise

      runs ->
        packageGeneratorView = $(getWorkspaceView()).find(".package-generator").view()
        packageGeneratorView.miniEditor.setText(packagePath)
        apmExecute = spyOn(packageGeneratorView, 'runCommand').andCallFake (command, args, exit) ->
          process.nextTick -> exit()
        loadPackage = spyOn(atom.packages, 'loadPackage')
        atom.commands.dispatch(packageGeneratorView.element, "core:confirm")

      waitsFor ->
        atom.open.callCount is 1
