}) Context("when refreshing the token succeeds", func() { BeforeEach(func() { authRepo.RefreshAuthTokenReturns("auth-token", nil) }) It("tries to get the ssh-code", func() { Expect(runCLIerr).NotTo(HaveOccurred()) Expect(authRepo.AuthorizeCallCount()).To(Equal(1)) Expect(authRepo.AuthorizeArgsForCall(0)).To(Equal("auth-token")) }) Context("when getting the ssh-code succeeds", func() { BeforeEach(func() { authRepo.AuthorizeReturns("some-code", nil) }) It("displays the token", func() { Expect(runCLIerr).NotTo(HaveOccurred()) Expect(ui.Outputs()).To(ContainSubstrings( []string{"some-code"}, )) }) }) Context("when getting the ssh-code fails", func() { BeforeEach(func() { authRepo.AuthorizeReturns("", errors.New("auth-err")) })