コード例 #1
0
ファイル: table_test.go プロジェクト: GABONIA/cli
			table.Add([]string{"a", "b", "c"})
			table.Add([]string{"passed", "to", "print"})
			table.Print()

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"watashi", "no", "atama!"},
				[]string{"a", "b", "c"},
				[]string{"passed", "to", "print"},
			))
		})

		It("flushes the buffer of rows when you call print", func() {
			table.Add([]string{"a", "b", "c"})
			table.Add([]string{"passed", "to", "print"})
			table.Print()
			ui.ClearOutputs()

			table.Print()
			Expect(ui.Outputs).To(BeEmpty())
		})
	})

	Describe("aligning columns", func() {
		It("aligns rows to the header when the header is longest", func() {
			table.Add([]string{"a", "b", "c"})
			table.Print()

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"watashi   no   atama!"},
				[]string{"a         b    c"},
			))