Example #1
0
					terminalUI.SayIncorrectUsage("")
					Expect(outputBuffer).To(test_helpers.Say("Incorrect Usage\n"))
				})
			})
			Context("when a message is passed", func() {
				It("outputs incorrect usage with the message", func() {
					terminalUI.SayIncorrectUsage("You did that thing wrong")
					Expect(outputBuffer).To(test_helpers.Say("Incorrect Usage: You did that thing wrong\n"))
				})
			})
		})

		Describe("SayNewLine", func() {
			It("says a newline", func() {
				terminalUI.SayNewLine()
				Expect(outputBuffer).To(test_helpers.SayNewLine())
			})
		})
	})

	Describe("Input Methods", func() {
		Describe("Prompt", func() {
			It("Prompts the user for input", func() {
				answerChan := make(chan string)
				go func() {
					defer GinkgoRecover()

					answerChan <- terminalUI.Prompt("Nickname")
					close(answerChan)
				}()
			Expect(outputBuffer).To(test_helpers.SayLine(colors.Bold("Distribution")))
			Expect(outputBuffer).To(test_helpers.SayLine("cell-1: " + colors.Green("•••") + colors.Yellow("••") + cursor.ClearToEndOfLine()))
			Expect(outputBuffer).To(test_helpers.SayLine("cell-2: " + colors.Green("••") + colors.Yellow("•") + cursor.ClearToEndOfLine()))
			Expect(outputBuffer).To(test_helpers.SayLine("cell-3: " + colors.Red("empty") + cursor.ClearToEndOfLine()))
		})

		Context("when the app examiner returns an error", func() {
			It("alerts the user fetching the cells returns an error", func() {
				fakeAppExaminer.ListCellsReturns(nil, errors.New("The list was lost"))

				test_helpers.ExecuteCommandWithArgs(visualizeCommand, []string{})

				Expect(outputBuffer).To(test_helpers.Say("Error visualizing: The list was lost"))
				Expect(outputBuffer).To(test_helpers.Say(cursor.ClearToEndOfLine()))
				Expect(outputBuffer).To(test_helpers.SayNewLine())

				// TODO: this should return non-zero, but it's shared with refresh view
				//   which should continue to retry in the event on an error and not exit
			})
		})

		Context("when a rate flag is provided", func() {
			var closeChan chan struct{}

			AfterEach(func() {
				go fakeExitHandler.Exit(exit_codes.Signal)
				Eventually(closeChan).Should(BeClosed())
			})

			It("dynamically displays the visualization", func() {