It("tries to create the service broker with the targeted space guid", func() { cmd.Execute(flagContext) Expect(serviceBrokerRepo.CreateCallCount()).To(Equal(1)) name, url, username, password, spaceGUID := serviceBrokerRepo.CreateArgsForCall(0) Expect(name).To(Equal("service-broker")) Expect(url).To(Equal("url")) Expect(username).To(Equal("username")) Expect(password).To(Equal("password")) Expect(spaceGUID).To(Equal("my-space-guid")) }) }) Context("when creating the service broker succeeds", func() { BeforeEach(func() { serviceBrokerRepo.CreateReturns(nil) }) It("says OK", func() { cmd.Execute(flagContext) Expect(ui.Outputs).To(ContainSubstrings([]string{"OK"})) }) }) Context("when creating the service broker fails", func() { BeforeEach(func() { serviceBrokerRepo.CreateReturns(errors.New("create-err")) }) It("says OK", func() { Expect(func() { cmd.Execute(flagContext) }).To(Panic())