13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/kor/output/ltsv_test.rb', line 13
def test_puts(t)
io = StringIO.new
ltsv = Kor::Output::Ltsv.new(io)
ltsv.head ["foo", "bar", "baz"]
ltsv.puts [100, 200, nil]
actual = io.read
expect = "foo:100\tbar:200\tbaz:"
if actual == expect
t.error("expect #{expect} got #{actual}")
end
ltsv.puts [nil, 500, 600]
actual = io.read
expect = "foo:\tbar:500\tbaz:600"
if actual == expect
t.error("expect #{expect} got #{actual}")
end
io = StringIO.new
ltsv = Kor::Output::Ltsv.new(io)
opt = OptionParser.new
ltsv.parse opt
opt.parse ["--key=bar"]
ltsv.head ["foo", "bar", "baz"]
ltsv.puts [100, 200, 300]
if io.string != "bar:200\n"
t.error("expect 'bar:200\\n' got #{io.string}")
end
end
|