It("requests the set_roles_by_username flag", func() { cmd.Requirements(factory, flagContext) Expect(flagRepo.FindByNameCallCount()).To(Equal(1)) Expect(flagRepo.FindByNameArgsForCall(0)).To(Equal("unset_roles_by_username")) }) Context("when the set_roles_by_username flag exists and is enabled", func() { BeforeEach(func() { flagRepo.FindByNameReturns(models.FeatureFlag{Enabled: true}, nil) }) It("returns a UserRequirement", func() { actualRequirements, err := cmd.Requirements(factory, flagContext) Expect(err).NotTo(HaveOccurred()) Expect(factory.NewUserRequirementCallCount()).To(Equal(1)) actualUsername, actualWantGUID := factory.NewUserRequirementArgsForCall(0) Expect(actualUsername).To(Equal("the-user-name")) Expect(actualWantGUID).To(BeFalse()) Expect(actualRequirements).To(ContainElement(userRequirement)) }) }) Context("when the set_roles_by_username flag exists and is disabled", func() { BeforeEach(func() { flagRepo.FindByNameReturns(models.FeatureFlag{Enabled: false}, nil) }) It("returns a UserRequirement", func() { actualRequirements, err := cmd.Requirements(factory, flagContext)