       SettingsHelper.setCredentials 'foo@bar.baz', '0123456789abcdef0123456789abcdef'
 
       atom.workspaceView.trigger 'spark-ide:select-core'
+      selectCoreView = sparkIde.selectCoreView
 
       expect(atom.workspaceView.find('#spark-ide-select-core-view')).toExist()
       expect(selectCoreView.find('div.loading').css('display')).toEqual('block')

  activationPromise = null
  selectCoreView = null
  originalProfile = null

  beforeEach ->
    atom.workspaceView = new WorkspaceView
    activationPromise = atom.packages.activatePackage('spark-ide').then ({mainModule}) ->
      selectCoreView = mainModule.selectCoreView

    originalProfile = SettingsHelper.getProfile()
    # For tests not to mess up our profile, we have to switch to test one...

        SettingsHelper.clearCredentials()
        atom.workspaceView.trigger 'core:close'

    fit 'tests choosing core', ->
      SettingsHelper.setCredentials 'foo@bar.baz', '0123456789abcdef0123456789abcdef'
      atom.workspaceView.trigger 'spark-ide:select-core'
      selectCoreView = sparkIde.selectCoreView

      waitsFor ->
        !selectCoreView.listDevicesPromise

      runs ->
        spyOn SettingsHelper, 'setCurrentCore'
        spyOn atom.workspaceView, 'trigger'
        devices = selectCoreView.find('ol.list-group li')
        devices.eq(0).addClass 'selected'
        selectCoreView.trigger 'core:confirm'

        expect(SettingsHelper.setCurrentCore).toHaveBeenCalled()
        expect(SettingsHelper.setCurrentCore).toHaveBeenCalledWith('51ff6e065067545724680187', 'Online Core')
        expect(atom.workspaceView.trigger).toHaveBeenCalled()
        expect(atom.workspaceView.trigger).toHaveBeenCalledWith('spark-ide:update-core-status')
        expect(atom.workspaceView.trigger).toHaveBeenCalledWith('spark-ide:update-menu')

        jasmine.unspy atom.workspaceView, 'trigger'
        jasmine.unspy SettingsHelper, 'setCurrentCore'
        SettingsHelper.clearCredentials()
