 
       describe "when the theme is created inside of the packages directory", ->
         it "calls `apm init`", ->
-          packageGeneratorView = atom.workspaceView.find(".package-generator").view()
+          packageGeneratorView = $(getWorkspaceView()).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"
+          atom.commands.dispatch(packageGeneratorView.element, "core:confirm")
 
           waitsFor ->
             atom.open.callCount is 1


    describe 'when creating a theme', ->
      beforeEach ->
        atom.workspaceView.trigger("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"

          waitsFor ->
            atom.open.callCount is 1


      describe "when the package is created inside the packages directory", ->
        it "calls `apm init`", ->
          packageGeneratorView = $(getWorkspaceView()).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()
          atom.commands.dispatch(packageGeneratorView.element, "core:confirm")

          waitsFor ->
            atom.open.callCount
