github.com/rakutentech/cli@v6.12.5-0.20151006231303-24468b65536e+incompatible/cf/requirements/targeted_space_test.go (about) 1 package requirements_test 2 3 import ( 4 "github.com/cloudfoundry/cli/cf/configuration/core_config" 5 "github.com/cloudfoundry/cli/cf/models" 6 . "github.com/cloudfoundry/cli/cf/requirements" 7 testassert "github.com/cloudfoundry/cli/testhelpers/assert" 8 testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" 9 testterm "github.com/cloudfoundry/cli/testhelpers/terminal" 10 . "github.com/onsi/ginkgo" 11 . "github.com/onsi/gomega" 12 13 . "github.com/cloudfoundry/cli/testhelpers/matchers" 14 ) 15 16 var _ = Describe("TargetedSpaceRequirement", func() { 17 var ( 18 ui *testterm.FakeUI 19 config core_config.ReadWriter 20 ) 21 22 BeforeEach(func() { 23 ui = new(testterm.FakeUI) 24 config = testconfig.NewRepositoryWithDefaults() 25 }) 26 27 Context("when the user has targeted a space", func() { 28 It("succeeds", func() { 29 req := NewTargetedSpaceRequirement(ui, config) 30 Expect(req.Execute()).To(BeTrue()) 31 }) 32 }) 33 34 Context("when the user does not have a space targeted", func() { 35 It("fails", func() { 36 config.SetSpaceFields(models.SpaceFields{}) 37 38 testassert.AssertPanic(testterm.QuietPanic, func() { 39 NewTargetedSpaceRequirement(ui, config).Execute() 40 }) 41 42 Expect(ui.Outputs).To(ContainSubstrings( 43 []string{"FAILED"}, 44 []string{"No space targeted"}, 45 )) 46 }) 47 }) 48 })