tty 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. data/.travis.yml +0 -1
  2. data/README.md +141 -23
  3. data/benchmarks/table.rb +5 -0
  4. data/lib/tty/logger.rb +71 -0
  5. data/lib/tty/support/equatable.rb +6 -2
  6. data/lib/tty/system/which.rb +41 -0
  7. data/lib/tty/system.rb +8 -0
  8. data/lib/tty/table/border/ascii.rb +15 -16
  9. data/lib/tty/table/border/null.rb +9 -4
  10. data/lib/tty/table/border/unicode.rb +15 -16
  11. data/lib/tty/table/border.rb +69 -9
  12. data/lib/tty/table/border_dsl.rb +247 -0
  13. data/lib/tty/table/border_options.rb +52 -0
  14. data/lib/tty/table/field.rb +101 -0
  15. data/lib/tty/table/header.rb +115 -0
  16. data/lib/tty/table/operation/alignment_set.rb +14 -10
  17. data/lib/tty/table/operation/truncation.rb +19 -13
  18. data/lib/tty/table/operation/wrapped.rb +20 -9
  19. data/lib/tty/table/operations.rb +69 -0
  20. data/lib/tty/table/renderer/basic.rb +35 -26
  21. data/lib/tty/table/renderer.rb +13 -1
  22. data/lib/tty/table/row.rb +174 -0
  23. data/lib/tty/table.rb +96 -21
  24. data/lib/tty/text/truncation.rb +1 -1
  25. data/lib/tty/vector.rb +8 -7
  26. data/lib/tty/version.rb +1 -1
  27. data/lib/tty.rb +21 -0
  28. data/spec/tty/logger/new_spec.rb +36 -0
  29. data/spec/tty/logger/valid_level_spec.rb +33 -0
  30. data/spec/tty/system/platform_spec.rb +8 -0
  31. data/spec/tty/system/which_spec.rb +41 -0
  32. data/spec/tty/table/access_spec.rb +12 -1
  33. data/spec/tty/table/add_row_spec.rb +28 -0
  34. data/spec/tty/table/border/new_spec.rb +9 -4
  35. data/spec/tty/table/border/null/rendering_spec.rb +39 -1
  36. data/spec/tty/table/border/options/from_spec.rb +39 -0
  37. data/spec/tty/table/border/options/new_spec.rb +15 -0
  38. data/spec/tty/table/border/style_spec.rb +70 -0
  39. data/spec/tty/table/border_spec.rb +107 -0
  40. data/spec/tty/table/each_with_index_spec.rb +30 -0
  41. data/spec/tty/table/field/equality_spec.rb +51 -0
  42. data/spec/tty/table/field/new_spec.rb +29 -0
  43. data/spec/tty/table/field/width_spec.rb +21 -0
  44. data/spec/tty/table/header/call_spec.rb +30 -0
  45. data/spec/tty/table/header/new_spec.rb +25 -0
  46. data/spec/tty/table/header/set_spec.rb +15 -0
  47. data/spec/tty/table/header/to_ary_spec.rb +14 -0
  48. data/spec/tty/table/header_spec.rb +14 -0
  49. data/spec/tty/table/operation/alignment_set/align_rows_spec.rb +8 -1
  50. data/spec/tty/table/operation/truncation/call_spec.rb +27 -0
  51. data/spec/tty/table/operation/wrapped/call_spec.rb +27 -0
  52. data/spec/tty/table/operations/new_spec.rb +32 -0
  53. data/spec/tty/table/options_spec.rb +17 -9
  54. data/spec/tty/table/renderer/basic/alignment_spec.rb +76 -29
  55. data/spec/tty/table/renderer/basic/separator_spec.rb +99 -0
  56. data/spec/tty/table/renderer_spec.rb +7 -1
  57. data/spec/tty/table/renders_with_spec.rb +35 -28
  58. data/spec/tty/table/rotate_spec.rb +1 -0
  59. data/spec/tty/table/row/access_spec.rb +25 -0
  60. data/spec/tty/table/row/call_spec.rb +41 -0
  61. data/spec/tty/table/row/data_spec.rb +26 -0
  62. data/spec/tty/table/row/equality_spec.rb +73 -0
  63. data/spec/tty/table/row/new_spec.rb +41 -0
  64. data/spec/tty/table/row/to_ary_spec.rb +14 -0
  65. data/spec/tty/text/truncation/truncate_spec.rb +6 -0
  66. metadata +72 -10
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe TTY::Table::Field, '#width' do
6
+ let(:object) { described_class }
7
+
8
+ subject { object.new value }
9
+
10
+ context 'with only value' do
11
+ let(:value) { 'foo' }
12
+
13
+ its(:width) { should == 3 }
14
+ end
15
+
16
+ context 'with hash value' do
17
+ let(:value) { "foo\nbaar" }
18
+
19
+ its(:width) { should == 8 }
20
+ end
21
+ end
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe TTY::Table::Header, '#call' do
6
+ let(:object) { described_class.new(attributes) }
7
+ let(:attributes) { [:id, :name, :age] }
8
+
9
+ subject { object.call(attribute) }
10
+
11
+ context 'with a known attribute' do
12
+ context 'when symbol' do
13
+ let(:attribute) { :age }
14
+
15
+ it { should == 2 }
16
+ end
17
+
18
+ context 'when integer' do
19
+ let(:attribute) { 1 }
20
+
21
+ it { should == :name }
22
+ end
23
+ end
24
+
25
+ context 'with an unknown attribute' do
26
+ let(:attribute) { :mine }
27
+
28
+ specify { expect { subject }.to raise_error(TTY::UnknownAttributeError, "the header 'mine' is unknown")}
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe TTY::Table::Header, '#new' do
6
+ let(:object) { described_class }
7
+
8
+ context 'with no arguments' do
9
+ subject { object.new }
10
+
11
+ it { should be_instance_of(object) }
12
+
13
+ it { should be_empty }
14
+ end
15
+
16
+ context 'with attributes' do
17
+ subject { object.new(attributes) }
18
+
19
+ let(:attributes) { ['id', 'name', 'age'] }
20
+
21
+ it { should be_instance_of(object) }
22
+
23
+ it { should == attributes }
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe TTY::Table::Header, '#set' do
6
+ let(:object) { described_class }
7
+ let(:attributes) { [:id, :name, :age] }
8
+
9
+ subject { object.new }
10
+
11
+ it 'sets the value' do
12
+ subject[0] = :id
13
+ expect(subject[0]).to eql(:id)
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe TTY::Table::Header, '#to_ary' do
6
+ let(:object) { described_class.new(attributes) }
7
+ let(:attributes) { [:id, :name, :age] }
8
+
9
+ subject { object.to_ary }
10
+
11
+ it { should be_instance_of(Array) }
12
+
13
+ it { should == attributes }
14
+ end
@@ -0,0 +1,14 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe TTY::Table, '#header' do
6
+
7
+ let(:header) { [:header1, :header2] }
8
+ let(:rows) { [['a1', 'a2'], ['b1', 'b2']] }
9
+ let(:object) { described_class }
10
+
11
+ subject { object.new header, rows }
12
+
13
+ its(:header) { should be_instance_of TTY::Table::Header }
14
+ end
@@ -2,9 +2,16 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
+ def to_field(value)
6
+ TTY::Table::Field.new(value)
7
+ end
8
+
5
9
  describe TTY::Table::Operation::AlignmentSet, '#align_rows' do
6
10
  let(:object) { described_class.new alignments }
7
- let(:rows) { [['a1', 'a2'], ['b1', 'b2']] }
11
+ let(:rows) {
12
+ [[to_field('a1'), to_field('a2')],
13
+ [to_field('b1'), to_field('b2')]]
14
+ }
8
15
 
9
16
  subject { object.align_rows rows, :column_widths => widths }
10
17
 
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe TTY::Table::Operation::Truncation, '#call' do
6
+ let(:object) { described_class.new }
7
+ let(:text) { '太丸ゴシック体' }
8
+ let(:row) { [TTY::Table::Field.new(text), TTY::Table::Field.new(text)] }
9
+
10
+ context 'without column width' do
11
+ it "truncates string" do
12
+ object.call(row)
13
+ expect(row[0]).to eql(text)
14
+ expect(row[1]).to eql(text)
15
+ end
16
+ end
17
+
18
+ context 'with column width ' do
19
+ let(:column_widths) { [3, 6] }
20
+
21
+ it "truncates string" do
22
+ object.call(row, :column_widths => column_widths)
23
+ expect(row[0]).to eql('太丸…')
24
+ expect(row[1]).to eql('太丸ゴシッ…')
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe TTY::Table::Operation::Wrapped, '#call' do
6
+ let(:object) { described_class.new }
7
+ let(:text) { 'ラドクリフ、マラソン五輪代表に1万m出場にも含み' }
8
+ let(:row) { [TTY::Table::Field.new(text), TTY::Table::Field.new(text)] }
9
+
10
+ context 'without column width' do
11
+ it "doesn't wrap string" do
12
+ object.call(row)
13
+ expect(row[0]).to eql(text)
14
+ expect(row[1]).to eql(text)
15
+ end
16
+ end
17
+
18
+ context 'with column width' do
19
+ let(:column_widths) { [12, 14] }
20
+
21
+ it "truncates string" do
22
+ object.call(row, :column_widths => column_widths)
23
+ expect(row[0]).to eql("ラドクリフ、マラソン五輪\n代表に1万m出場にも含み")
24
+ expect(row[1]).to eql("ラドクリフ、マラソン五輪代表\nに1万m出場にも含み")
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe TTY::Table::Operations, '#new' do
6
+ let(:object) { described_class }
7
+ let(:row) { [1,2,3] }
8
+ let(:table) { TTY::Table.new :rows => [row] }
9
+ let(:callable) {
10
+ Class.new do
11
+ def call(row, options)
12
+ row.map! { |r| r + 1}
13
+ end
14
+ end
15
+ }
16
+ let(:instance) { callable.new }
17
+
18
+ subject { object.new table }
19
+
20
+ before {
21
+ subject.add_operation(:alignment, instance)
22
+ }
23
+
24
+ it 'stores away operations' do
25
+ expect(subject.operations[:alignment]).to include(instance)
26
+ end
27
+
28
+ it 'runs selected operations' do
29
+ subject.run_operations(:alignment, row)
30
+ expect(row).to eql([2,3,4])
31
+ end
32
+ end
@@ -6,22 +6,30 @@ describe TTY::Table, 'options' do
6
6
  let(:rows) { [['a1', 'a2'], ['b1', 'b2']] }
7
7
  let(:widths) { nil }
8
8
  let(:aligns) { [] }
9
- let(:object) {
10
- described_class.new rows,
9
+ let(:object) { described_class }
10
+ let(:options) {
11
+ {
11
12
  :column_widths => widths,
12
13
  :column_aligns => aligns,
13
14
  :renderer => :basic
15
+ }
14
16
  }
15
17
 
16
- subject { object.to_s; object.renderer }
18
+ subject { object.new rows, options }
17
19
 
18
- its(:column_widths) { should == [2,2] }
20
+ its(:header) { should be_nil }
19
21
 
20
- its(:alignments) { should be_kind_of TTY::Table::Operation::AlignmentSet }
22
+ its(:rows) { should == rows }
21
23
 
22
- it 'is empty' do
23
- subject.alignments.to_a.should be_empty
24
- end
24
+ its(:border) { should be_kind_of TTY::Table::BorderOptions }
25
+
26
+ its(:orientation) { should be_kind_of TTY::Table::Orientation::Horizontal }
27
+
28
+ its(:column_widths) { should be_empty }
29
+
30
+ its(:column_aligns) { should eql(aligns) }
31
+
32
+ it { subject.column_aligns.to_a.should be_empty }
25
33
 
26
34
  context '#column_widths' do
27
35
  let(:widths) { [10, 10] }
@@ -39,7 +47,7 @@ describe TTY::Table, 'options' do
39
47
  let(:aligns) { [:center, :center] }
40
48
 
41
49
  it 'unwraps original array' do
42
- subject.alignments.to_a.should == aligns
50
+ subject.column_aligns.to_a.should == aligns
43
51
  end
44
52
  end
45
53
  end
@@ -2,39 +2,86 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe TTY::Table::Renderer::Basic, 'alignment' do
5
+ describe TTY::Table, 'alignment' do
6
6
  let(:header) { ['h1', 'h2', 'h3'] }
7
- let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] }
8
-
9
- it 'aligns left by default' do
10
- header = ['h1', 'h2']
11
- rows = [['aaaaa', 'a'], ['b', 'bbbbb']]
12
- table = TTY::Table.new header, rows, :renderer => :basic
13
- table.to_s.should == <<-EOS.normalize
14
- h1 h2
15
- aaaaa a
16
- b bbbbb
17
- EOS
7
+ let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] }
8
+ let(:options) { { :renderer => :basic, :column_aligns => column_aligns }}
9
+
10
+ subject(:table) { described_class.new header, rows, options }
11
+
12
+ context 'with default' do
13
+ let(:header) { ['h1', 'h2'] }
14
+ let(:rows) { [['aaaaa', 'a'], ['b', 'bbbbb']] }
15
+ let(:column_aligns) { nil }
16
+
17
+ it 'aligns left by default' do
18
+ table.to_s.should == <<-EOS.normalize
19
+ h1 h2
20
+ aaaaa a
21
+ b bbbbb
22
+ EOS
23
+ end
24
+ end
25
+
26
+ context 'with different headers' do
27
+ let(:header) { ['header1', 'head2', 'h3'] }
28
+ let(:column_aligns) { [:left, :center, :right] }
29
+
30
+ it 'aligns headers' do
31
+ table.to_s.should == <<-EOS.normalize
32
+ header1 head2 h3
33
+ a1 a2 a3
34
+ b1 b2 b3
35
+ EOS
36
+ end
18
37
  end
19
38
 
20
- it 'aligns table headers' do
21
- header = ['header1', 'head2', 'h3']
22
- table = TTY::Table.new header, rows, :render => :basic,
23
- :column_aligns => [:left, :center, :right]
24
- table.to_s.should == <<-EOS.normalize
25
- header1 head2 h3
26
- a1 a2 a3
27
- b1 b2 b3
28
- EOS
39
+ context 'with different aligns' do
40
+ let(:header) { nil }
41
+ let(:rows) { [['aaaaa', 'a'], ['b', 'bbbbb']] }
42
+ let(:column_aligns) { [:left, :right] }
43
+
44
+ it 'aligns table rows' do
45
+ table.to_s.should == <<-EOS.normalize
46
+ aaaaa a
47
+ b bbbbb
48
+ EOS
49
+ end
50
+ end
51
+
52
+ context 'with individual field aligns' do
53
+ let(:header) { ['header1', 'header2', 'header3'] }
54
+ let(:column_aligns) { [:left, :center, :right] }
55
+
56
+ it "takes individual fields over global aligns" do
57
+ options = {:header => header, :column_aligns => column_aligns, :renderer => :basic}
58
+ table = described_class.new options do |t|
59
+ t << ['a1', 'a2', 'a3']
60
+ t << ['b1', {:value => 'b2', :align => :right}, 'b3']
61
+ t << ['c1', 'c2', {:value => 'c3', :align => :center}]
62
+ end
63
+ table.to_s.should == <<-EOS.normalize
64
+ header1 header2 header3
65
+ a1 a2 a3
66
+ b1 b2 b3
67
+ c1 c2 c3
68
+ EOS
69
+ end
29
70
  end
30
71
 
31
- it 'aligns table rows' do
32
- rows = [['aaaaa', 'a'], ['b', 'bbbbb']]
33
- table = TTY::Table.new rows, :renderer => :basic,
34
- :column_aligns => [:left, :right]
35
- table.to_s.should == <<-EOS.normalize
36
- aaaaa a
37
- b bbbbb
38
- EOS
72
+ context 'with aligned header' do
73
+ let(:rows) { [['aaaaa1', 'a2', 'aaa3'], ['b1', 'bbbb2', 'bb3']] }
74
+
75
+ it "aligns headres" do
76
+ header = ['h1', {:value => 'h2', :align => :right}, {:value => 'h3', :align => :center}]
77
+ options = {:header => header, :renderer => :basic, :rows => rows }
78
+ table = described_class.new options
79
+ table.to_s.should == <<-EOS.normalize
80
+ h1 h2 h3
81
+ aaaaa1 a2 aaa3
82
+ b1 bbbb2 bb3
83
+ EOS
84
+ end
85
+
39
86
  end
40
87
  end
@@ -0,0 +1,99 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe TTY::Table, 'with separator' do
6
+ let(:header) { ['h1', 'h2', 'h3'] }
7
+ let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] }
8
+
9
+ subject(:table) { described_class.new header, rows, :renderer => renderer }
10
+
11
+ context 'when default' do
12
+ let(:renderer) { :basic }
13
+
14
+ it "sets through hash" do
15
+ table.border :separator => :each_row
16
+ expect(table.border.separator).to eql(:each_row)
17
+ end
18
+
19
+ it "sets through attribute" do
20
+ table.border.separator= :each_row
21
+ expect(table.border.separator).to eql(:each_row)
22
+ end
23
+
24
+ it "sets through block" do
25
+ table.border do
26
+ separator :each_row
27
+ end
28
+ expect(table.border.separator).to eql(:each_row)
29
+ end
30
+
31
+ it "renders each row" do
32
+ table.border.separator= :each_row
33
+ table.to_s.should == <<-EOS.normalize
34
+ h1 h2 h3
35
+
36
+ a1 a2 a3
37
+
38
+ b1 b2 b3
39
+ EOS
40
+ end
41
+ end
42
+
43
+ context 'when ascii' do
44
+ let(:renderer) { :ascii }
45
+
46
+ it "renders each row" do
47
+ table.border.separator= :each_row
48
+ table.to_s.should == <<-EOS.normalize
49
+ +--+--+--+
50
+ |h1|h2|h3|
51
+ +--+--+--+
52
+ |a1|a2|a3|
53
+ +--+--+--+
54
+ |b1|b2|b3|
55
+ +--+--+--+
56
+ EOS
57
+ end
58
+
59
+ context 'with specific separator' do
60
+ let(:header) { ['h1', 'h2'] }
61
+ let(:rows) { [['a1', 'a2'], ['b1', 'b2'], ['c1', 'c2']] }
62
+
63
+ it 'custom separator' do
64
+ pending
65
+ table.border.separator= [2]
66
+ table.to_s.should == <<-EOS.normalize
67
+ +--+--+
68
+ |h1|h2|
69
+ +--+--+
70
+ |a1|a2|
71
+ |b1|b2|
72
+ +--+--+
73
+ |c1|c2|
74
+ +--+--+
75
+ EOS
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+
82
+ context 'when unicode' do
83
+ let(:renderer) { :unicode }
84
+
85
+ it "renders each row" do
86
+ table.border.separator= :each_row
87
+ table.to_s.should == <<-EOS.normalize
88
+ ┌──┬──┬──┐
89
+ │h1│h2│h3│
90
+ ├──┼──┼──┤
91
+ │a1│a2│a3│
92
+ ├──┼──┼──┤
93
+ │b1│b2│b3│
94
+ └──┴──┴──┘
95
+ EOS
96
+ end
97
+ end
98
+
99
+ end
@@ -4,6 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe TTY::Table, '#renderer' do
6
6
  let(:basic_renderer) { TTY::Table::Renderer::Basic }
7
+ let(:ascii_renderer) { TTY::Table::Renderer::ASCII }
7
8
  let(:unicode_renderer) { TTY::Table::Renderer::Unicode }
8
9
 
9
10
  before do
@@ -25,7 +26,12 @@ describe TTY::Table, '#renderer' do
25
26
  table.renderer.should be_kind_of(basic_renderer)
26
27
  end
27
28
 
28
- it 'allows to set instance renderer' do
29
+ it 'allows to set ascii instance renderer' do
30
+ table = TTY::Table.new :renderer => :ascii
31
+ expect(table.renderer).to be_kind_of(ascii_renderer)
32
+ end
33
+
34
+ it 'allows to set unicode instance renderer' do
29
35
  table = TTY::Table.new :renderer => :unicode
30
36
  table.renderer.should be_kind_of(unicode_renderer)
31
37
  end
@@ -7,32 +7,41 @@ describe TTY::Table, '#renders_with' do
7
7
  let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] }
8
8
  let(:table) { described_class.new header, rows }
9
9
 
10
+ context 'with invalid border class' do
11
+ it "doesn't inherit from TTY::Table::Border" do
12
+ expect { table.renders_with String }.to raise_error(TTY::TypeError)
13
+ end
14
+
15
+ it "doesn't implement def_border" do
16
+ klass = Class.new(TTY::Table::Border)
17
+ expect { table.renders_with klass }.to raise_error(TTY::NoImplementationError)
18
+ end
19
+ end
20
+
10
21
  context 'with complete border' do
11
- let(:border_class) {
22
+ before {
12
23
  class MyBorder < TTY::Table::Border
13
24
  def_border do
14
- {
15
- 'top' => '=',
16
- 'top_mid' => '*',
17
- 'top_left' => '*',
18
- 'top_right' => '*',
19
- 'bottom' => '=',
20
- 'bottom_mid' => '*',
21
- 'bottom_left' => '*',
22
- 'bottom_right' => '*',
23
- 'mid' => '=',
24
- 'mid_mid' => '*',
25
- 'mid_left' => '*',
26
- 'mid_right' => '*',
27
- 'left' => '$',
28
- 'right' => '$'
29
- }
25
+ top '='
26
+ top_mid '*'
27
+ top_left '*'
28
+ top_right '*'
29
+ bottom '='
30
+ bottom_mid '*'
31
+ bottom_left '*'
32
+ bottom_right '*'
33
+ mid '='
34
+ mid_mid '*'
35
+ mid_left '*'
36
+ mid_right '*'
37
+ left '$'
38
+ center '$'
39
+ right '$'
30
40
  end
31
41
  end
32
42
  }
33
43
 
34
44
  it 'displays custom border' do
35
- border_class
36
45
  table.renders_with MyBorder
37
46
  table.to_s.should == <<-EOS.normalize
38
47
  *==*==*==*
@@ -46,23 +55,21 @@ describe TTY::Table, '#renders_with' do
46
55
  end
47
56
 
48
57
  context 'with incomplete border' do
49
- let(:border_class) {
58
+ before {
50
59
  class MyBorder < TTY::Table::Border
51
60
  def_border do
52
- {
53
- 'bottom' => ' ',
54
- 'bottom_mid' => '*',
55
- 'bottom_left' => '*',
56
- 'bottom_right' => '*',
57
- 'left' => '$',
58
- 'right' => '$'
59
- }
61
+ bottom ' '
62
+ bottom_mid '*'
63
+ bottom_left '*'
64
+ bottom_right '*'
65
+ left '$'
66
+ center '$'
67
+ right '$'
60
68
  end
61
69
  end
62
70
  }
63
71
 
64
72
  it 'displays border' do
65
- border_class
66
73
  table.renders_with MyBorder
67
74
  table.to_s.should == <<-EOS.normalize
68
75
  $h1$h2$h3$
@@ -64,6 +64,7 @@ describe TTY::Table, '#rotate' do
64
64
  it 'rotates the rows and header back' do
65
65
  subject.orientation = :vertical
66
66
  subject.rotate
67
+ expect(subject.orientation).to be_a TTY::Table::Orientation::Vertical
67
68
  subject.orientation = :horizontal
68
69
  expect(subject.rotate.to_a).to eql rows
69
70
  expect(subject.header).to eql header
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe TTY::Table::Row, '#access' do
6
+ let(:object) { described_class.new [] }
7
+
8
+ before { object[attribute] = value}
9
+
10
+ subject { object[attribute] }
11
+
12
+ context 'when integer' do
13
+ let(:attribute) { 0 }
14
+ let(:value) { 1 }
15
+
16
+ it { should == 1 }
17
+ end
18
+
19
+ context 'when symbol' do
20
+ let(:attribute) { :id }
21
+ let(:value) { 1 }
22
+
23
+ it { should == 1 }
24
+ end
25
+ end