示例#1
0
		It("requires an spacelication name", func() {
			err := cmd.SSHAllowed([]string{"space-ssh-allowed"}, fakeSpaceFactory, nil)

			Expect(err).To(MatchError("Invalid usage\n" + cmd.SSHAllowedUsage))
		})

		It("validates the command name", func() {
			err := cmd.SSHAllowed([]string{"bogus", "space"}, fakeSpaceFactory, nil)

			Expect(err).To(MatchError("Invalid usage\n" + cmd.SSHAllowedUsage))
		})
	})

	It("returns the value", func() {
		mySpace.AllowSSH = true
		fakeSpaceFactory.GetReturns(mySpace, nil)
		writer := bytes.NewBuffer(nil)

		err := cmd.SSHAllowed([]string{"space-ssh-allowed", "myspace"}, fakeSpaceFactory, writer)
		Expect(err).NotTo(HaveOccurred())

		Expect(fakeSpaceFactory.GetCallCount()).To(Equal(1))
		Expect(fakeSpaceFactory.GetArgsForCall(0)).To(Equal("myspace"))
		Expect(writer.String()).To(Equal("true"))
	})

	Context("when retrieving the Space fails", func() {
		BeforeEach(func() {
			fakeSpaceFactory.GetReturns(space.Space{}, errors.New("get failed"))
		})