github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+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'")) 20 Eventually(session.Out).Should(Say("Did you mean?")) 21 Eventually(session.Out.Contents()).Should(ContainSubstring("login")) 22 Eventually(session.Out.Contents()).Should(ContainSubstring("logs")) 23 Eventually(session).Should(Exit(1)) 24 }) 25 }) 26 27 Context("when a command is provided that is not even close", func() { 28 It("gives suggestions", func() { 29 command := exec.Command("cf", "zzz") 30 session, err := Start(command, GinkgoWriter, GinkgoWriter) 31 Expect(err).NotTo(HaveOccurred()) 32 33 Eventually(session.Out).Should(Say("'zzz' is not a registered command. See 'cf help'")) 34 Consistently(session.Out).ShouldNot(Say("Did you mean?")) 35 Eventually(session).Should(Exit(1)) 36 }) 37 }) 38 })