Module: KorCliTest
- Defined in:
- lib/kor/cli_test.rb
Instance Method Summary collapse
Instance Method Details
#test_e2e(t) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/kor/cli_test.rb', line 32 def test_e2e(t) actual = `#{<<-COMMAND}` cat << CSV | kor csv markdown foo,bar,baz 100,200,300 400,500,600 CSV COMMAND expect = <<-MARKDOWN | foo | bar | baz | | --- | --- | --- | | 100 | 200 | 300 | | 400 | 500 | 600 | MARKDOWN if actual != expect t.error("actual output not match to expect output.") end end |
#test_new(t) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/kor/cli_test.rb', line 4 def test_new(t) cli = Kor::Cli.new unless cli.kind_of?(Kor::Cli) t.error("expect instance of Kor::Cli got #{cli}") end end |
#test_run(t) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kor/cli_test.rb', line 11 def test_run(t) input_io = StringIO.new output_io = StringIO.new cli = Kor::Cli.new(["base"], input_io, output_io) ret, err = go { cli.run } unless SystemExit === err t.error("expect raise SystemExit got #{err.class}:#{err.to_s}") end input = StringIO.new("input") output = StringIO.new("output") cli = Kor::Cli.new(["base", "base"], input, output) cli.run if input.string != "input" t.error("expect base input plugin string \"input\" got #{input.string}") end if output.string != "output" t.error("expect base output plugin string \"output\" got #{output.string}") end end |