Пример #1
0
	"github.com/cloudfoundry/cli/flags"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("ShowUsage", func() {
	var fc flags.FlagContext

	Context("when given a flag with a longname", func() {
		BeforeEach(func() {
			fc = flags.New()
			fc.NewIntFlag("flag-a", "", "")
		})

		It("prints the longname with two hyphens", func() {
			outputs := fc.ShowUsage(0)
			Expect(outputs).To(ContainSubstring("--flag-a\n"))
		})
	})

	Context("when given a flag with a longname and usage", func() {
		BeforeEach(func() {
			fc = flags.New()
			fc.NewIntFlag("flag-a", "", "Usage for flag-a")
		})

		It("prints the longname with two hyphens followed by the usage", func() {
			outputs := fc.ShowUsage(0)
			Expect(outputs).To(ContainSubstring("--flag-a      Usage for flag-a\n"))
		})
	})