}) Context("when logged in", func() { BeforeEach(func() { requirementsFactory.LoginSuccess = true }) It("tells the user what it's about to do", func() { runCommand() Expect(ui.Outputs).To(ContainSubstrings( []string{"Getting", "security groups", "my-user"}, )) }) It("handles api errors with an error message", func() { repo.FindAllReturns([]models.SecurityGroup{}, errors.New("YO YO YO, ERROR YO")) runCommand() Expect(ui.Outputs).To(ContainSubstrings( []string{"FAILED"}, )) }) Context("when there are no security groups", func() { It("Should tell the user that there are no security groups", func() { repo.FindAllReturns([]models.SecurityGroup{}, nil) runCommand() Expect(ui.Outputs).To(ContainSubstrings([]string{"No security groups"})) }) })