BeforeEach(func() { fakeLogger = new(tracefakes.FakePrinter) }) Describe("Printing message to stdout with PrintCapturingNoOutput", func() { It("prints strings without using the TeePrinter", func() { bucket := gbytes.NewBuffer() printer := NewTeePrinter(os.Stdout) printer.SetOutputBucket(bucket) io_helpers.SimulateStdin("", func(reader io.Reader) { output := io_helpers.CaptureOutput(func() { ui := NewUI(reader, os.Stdout, printer, fakeLogger) ui.PrintCapturingNoOutput("Hello") }) Expect("Hello").To(Equal(strings.Join(output, ""))) Expect(bucket.Contents()).To(HaveLen(0)) }) }) }) Describe("Printing message to stdout with Say", func() { It("prints strings", func() { io_helpers.SimulateStdin("", func(reader io.Reader) { output := io_helpers.CaptureOutput(func() { ui := NewUI(reader, os.Stdout, NewTeePrinter(os.Stdout), fakeLogger) ui.Say("Hello") })
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" io_helpers "github.com/cloudfoundry/cli/testhelpers/io" . "github.com/cloudfoundry/cli/cf/terminal" . "github.com/cloudfoundry/cli/testhelpers/matchers" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("UI", func() { Describe("Printing message to stdout with Say", func() { It("prints strings", func() { io_helpers.SimulateStdin("", func(reader io.Reader) { output := io_helpers.CaptureOutput(func() { ui := NewUI(reader) ui.Say("Hello") }) Expect("Hello").To(Equal(strings.Join(output, ""))) }) }) It("prints formatted strings", func() { io_helpers.SimulateStdin("", func(reader io.Reader) { output := io_helpers.CaptureOutput(func() { ui := NewUI(reader) ui.Say("Hello %s", "World!") }) Expect("Hello World!").To(Equal(strings.Join(output, ""))) }) })