JustBeforeEach(func() { runCommand("security-group-name") }) It("Describes what it is doing to the user", func() { Expect(ui.Outputs()).To(ContainSubstrings( []string{"Binding", "security-group-name", "as", "my-user"}, []string{"OK"}, []string{"TIP: Changes will not apply to existing running applications until they are restarted."}, )) }) It("binds the group to the running group set", func() { Expect(fakeSecurityGroupRepo.ReadArgsForCall(0)).To(Equal("security-group-name")) Expect(fakeRunningSecurityGroupRepo.BindToRunningSetArgsForCall(0)).To(Equal("being-a-guid")) }) Context("when binding the security group to the running set fails", func() { BeforeEach(func() { fakeRunningSecurityGroupRepo.BindToRunningSetReturns(errors.New("WOAH. I know kung fu")) }) It("fails and describes the failure to the user", func() { Expect(ui.Outputs()).To(ContainSubstrings( []string{"FAILED"}, []string{"WOAH. I know kung fu"}, )) }) })