Example #1
0
			org.Name = "the-org-name"
			organizationRequirement.GetOrganizationReturns(org)
		})

		JustBeforeEach(func() {
			err = cmd.Execute(flagContext)
		})

		Context("when the space is not found", func() {
			BeforeEach(func() {
				spaceRepo.FindByNameInOrgReturns(models.Space{}, errors.New("space-repo-error"))
			})

			It("doesn't call CC", func() {
				Expect(userRepo.UnsetSpaceRoleByGUIDCallCount()).To(BeZero())
				Expect(userRepo.UnsetSpaceRoleByUsernameCallCount()).To(BeZero())
			})

			It("return an error", func() {
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(Equal("space-repo-error"))
			})
		})

		Context("when the space is found", func() {
			BeforeEach(func() {
				space := models.Space{}
				space.GUID = "the-space-guid"
				space.Name = "the-space-name"
				space.Organization = org.OrganizationFields
				spaceRepo.FindByNameInOrgReturns(space, nil)