Exemplo n.º 1
0
		printer         print.Printer
		mockGamer       *mocks.Gamer
		commandSequence = func(args ...string) {
			stdin.WriteString(strings.Join(args, "\n"))
		}
	)

	BeforeEach(func() {
		mockGamer = &mocks.Gamer{}

		stdin = &bytes.Buffer{}
		stdinReader = bufio.NewReader(stdin)

		buffer = gbytes.NewBuffer()

		printer = print.NewPrinter(buffer)
	})

	AfterEach(func() {
		Expect(mockGamer.AssertExpectations(GinkgoT())).To(BeTrue())
	})

	Context("when providing valid input", func() {
		It("can quit the game", func() {
			commandSequence("q")

			main.Run(mockGamer, stdinReader, printer)

			Eventually(buffer).Should(gbytes.Say("Would you like to play"))
			Eventually(buffer).Should(gbytes.Say("byeee"))
		})
Exemplo n.º 2
0
func main() {
	stdin := bufio.NewReader(os.Stdin)
	printer := print.NewPrinter(os.Stdout)
	gamer := game.NewGamer(stdin, printer)
	Run(gamer, stdin, printer)
}