     it "forces the package's name to be lowercase with dashes", ->
       packageName = "CamelCaseIsForTheBirds"
       packagePath = path.join(path.dirname(packagePath), packageName)
-      atom.workspaceView.trigger("package-generator:generate-package")
-
-      waitsForPromise ->
-        activationPromise
-
-      runs ->
-        packageGeneratorView = atom.workspaceView.find(".package-generator").view()
+      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')
-        packageGeneratorView.trigger "core:confirm"
+        atom.commands.dispatch(packageGeneratorView.element, "core:confirm")
 
         expect(apmExecute).toHaveBeenCalled()
         expect(apmExecute.mostRecentCall.args[0]).toBe atom.packages.getApmPath()


      describe "when the package is created inside the packages directory", ->
        it "calls `apm init`", ->
          packageGeneratorView = atom.workspaceView.find(".package-generator").view()
          spyOn(packageGeneratorView, 'isStoredInDotAtom').andReturn true
          expect(packageGeneratorView.hasParent()).toBeTruthy()
          packageGeneratorView.miniEditor.setText(packagePath)
          apmExecute = spyOn(packageGeneratorView, 'runCommand').andCallFake (command, args, exit) ->
            process.nextTick -> exit()
          packageGeneratorView.trigger "core:confirm"

          waitsFor ->
            atom.open.callCount


    describe 'when creating a theme', ->
      beforeEach ->
        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 = $(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
