github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+incompatible/integration/isolated/suggest_command_test.go (about) 1 package isolated 2 3 import ( 4 "os/exec" 5 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8 . "github.com/onsi/gomega/gbytes" 9 . "github.com/onsi/gomega/gexec" 10 ) 11 12 var _ = Describe("Suggest Command", func() { 13 Context("when a command is provided that is almost a command", func() { 14 It("gives suggestions", func() { 15 command := exec.Command("cf", "logn") 16 session, err := Start(command, GinkgoWriter, GinkgoWriter) 17 Expect(err).NotTo(HaveOccurred()) 18 19 Eventually(session.Out).Should(Say("'logn' is not a registered command. See 'cf help -a'")) 20 Eventually(session.Out).Should(Say("Did you mean?")) 21 Eventually(session).Should(Exit(1)) 22 23 Eventually(session.Out.Contents()).Should(ContainSubstring("login")) 24 Eventually(session.Out.Contents()).Should(ContainSubstring("logs")) 25 }) 26 }) 27 28 Context("when a command is provided that is not even close", func() { 29 It("gives suggestions", func() { 30 command := exec.Command("cf", "zzz") 31 session, err := Start(command, GinkgoWriter, GinkgoWriter) 32 Expect(err).NotTo(HaveOccurred()) 33 34 Eventually(session.Out).Should(Say("'zzz' is not a registered command. See 'cf help -a'")) 35 Consistently(session.Out).ShouldNot(Say("Did you mean?")) 36 Eventually(session).Should(Exit(1)) 37 }) 38 }) 39 })