command_line_reporter 4.0.3 → 5.0.0
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.
- checksums.yaml +4 -4
- data/lib/command_line_reporter/column.rb +12 -8
- data/lib/command_line_reporter/formatter/nested.rb +5 -2
- data/lib/command_line_reporter/formatter/progress.rb +2 -2
- data/lib/command_line_reporter/row.rb +4 -2
- data/lib/command_line_reporter/table.rb +28 -25
- data/lib/command_line_reporter/version.rb +1 -1
- data/lib/command_line_reporter.rb +12 -5
- metadata +15 -50
- data/spec/column_spec.rb +0 -521
- data/spec/command_line_reporter_spec.rb +0 -693
- data/spec/nested_formatter_spec.rb +0 -301
- data/spec/options_validator_spec.rb +0 -24
- data/spec/progress_formatter_spec.rb +0 -74
- data/spec/row_spec.rb +0 -131
- data/spec/spec_helper.rb +0 -6
- data/spec/support/helpers/stdout.rb +0 -8
- data/spec/support/matchers/argument.rb +0 -5
- data/spec/table_spec.rb +0 -171
data/spec/table_spec.rb
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe CommandLineReporter::Table do
|
|
4
|
-
subject { CommandLineReporter::Table }
|
|
5
|
-
let(:row_subject) { CommandLineReporter::Row }
|
|
6
|
-
let(:col_subject) { CommandLineReporter::Column }
|
|
7
|
-
|
|
8
|
-
context 'creation' do
|
|
9
|
-
it 'defaults options hash' do
|
|
10
|
-
expect do
|
|
11
|
-
subject.new
|
|
12
|
-
end.to_not raise_error Exception
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'defaults the border' do
|
|
16
|
-
t = subject.new
|
|
17
|
-
expect(t.border).to be false
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'accepts the border' do
|
|
21
|
-
t = subject.new(border: true)
|
|
22
|
-
expect(t.border).to eq(true)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'output encoding should be ascii' do
|
|
26
|
-
t = subject.new(encoding: :ascii)
|
|
27
|
-
expect(t.encoding).to eq(:ascii)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'output encoding should be unicode' do
|
|
31
|
-
t = subject.new
|
|
32
|
-
expect(t.encoding).to eq(:unicode)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
context 'rows' do
|
|
37
|
-
it 'allows addition' do
|
|
38
|
-
cols = [col_subject.new('test1'), col_subject.new('test2')]
|
|
39
|
-
row = row_subject.new
|
|
40
|
-
cols.each { |c| row.add(c) }
|
|
41
|
-
expect do
|
|
42
|
-
subject.new.add(row)
|
|
43
|
-
end.to_not raise_error Exception
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
context 'inherits' do
|
|
47
|
-
before :each do
|
|
48
|
-
@table = subject.new
|
|
49
|
-
row = row_subject.new(color: 'red')
|
|
50
|
-
(
|
|
51
|
-
@cols1 = [
|
|
52
|
-
col_subject.new('asdf', width: 5),
|
|
53
|
-
col_subject.new('qwer', align: 'right', color: 'purple'),
|
|
54
|
-
col_subject.new('tutu', color: 'green'),
|
|
55
|
-
col_subject.new('uiui', bold: true)
|
|
56
|
-
]
|
|
57
|
-
).each { |c| row.add(c) }
|
|
58
|
-
@table.add(row)
|
|
59
|
-
row = row_subject.new
|
|
60
|
-
(
|
|
61
|
-
@cols2 = [
|
|
62
|
-
col_subject.new('test'),
|
|
63
|
-
col_subject.new('test'),
|
|
64
|
-
col_subject.new('test', color: 'blue'),
|
|
65
|
-
col_subject.new('test')
|
|
66
|
-
]
|
|
67
|
-
).each { |c| row.add(c) }
|
|
68
|
-
@table.add(row)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
context 'positional attributes' do
|
|
72
|
-
it 'should inherit alignment' do
|
|
73
|
-
4.times do |i|
|
|
74
|
-
expect(@table.rows[1].columns[i].align).to eq(@table.rows[0].columns[i].align)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it 'should inherit width' do
|
|
79
|
-
4.times do |i|
|
|
80
|
-
expect(@table.rows[1].columns[i].width).to eq(@table.rows[0].columns[i].width)
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it 'should inherit size' do
|
|
85
|
-
4.times do |i|
|
|
86
|
-
expect(@table.rows[1].columns[i].size).to eq(@table.rows[0].columns[i].size)
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
it 'should inherit padding' do
|
|
91
|
-
4.times do |i|
|
|
92
|
-
expect(@table.rows[1].columns[i].padding).to eq(@table.rows[0].columns[i].padding)
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
context 'no header row' do
|
|
98
|
-
it 'color' do
|
|
99
|
-
expect(@table.rows[1].columns[0].color).to eq('red')
|
|
100
|
-
expect(@table.rows[1].columns[1].color).to eq('purple')
|
|
101
|
-
expect(@table.rows[1].columns[2].color).to eq('blue')
|
|
102
|
-
expect(@table.rows[1].columns[3].color).to eq('red')
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it 'bold' do
|
|
106
|
-
expect(@table.rows[1].columns[0].bold).to be false
|
|
107
|
-
expect(@table.rows[1].columns[1].bold).to be false
|
|
108
|
-
expect(@table.rows[1].columns[2].bold).to be false
|
|
109
|
-
expect(@table.rows[1].columns[3].bold).to be true
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
context 'with header row' do
|
|
114
|
-
before :each do
|
|
115
|
-
@table = subject.new
|
|
116
|
-
row = row_subject.new(header: true)
|
|
117
|
-
@cols1.each { |c| row.add(c) }
|
|
118
|
-
@table.add(row)
|
|
119
|
-
row = row_subject.new
|
|
120
|
-
@cols2.each { |c| row.add(c) }
|
|
121
|
-
@table.add(row)
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
it 'color' do
|
|
125
|
-
expect(@table.rows[1].columns[0].color).to eq('red')
|
|
126
|
-
expect(@table.rows[1].columns[1].color).to eq('purple')
|
|
127
|
-
expect(@table.rows[1].columns[2].color).to eq('blue')
|
|
128
|
-
expect(@table.rows[1].columns[3].color).to eq('red')
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
it 'bold' do
|
|
132
|
-
expect(@table.rows[1].columns[0].bold).to be false
|
|
133
|
-
expect(@table.rows[1].columns[0].bold).to be false
|
|
134
|
-
expect(@table.rows[1].columns[1].bold).to be false
|
|
135
|
-
expect(@table.rows[1].columns[2].bold).to be false
|
|
136
|
-
expect(@table.rows[1].columns[3].bold).to be true
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
describe '#auto_adjust_widths' do
|
|
143
|
-
it 'sets the widths of each column in each row to the maximum required width for that column' do
|
|
144
|
-
table = subject.new.tap do |t|
|
|
145
|
-
t.add(
|
|
146
|
-
row_subject.new.tap do |r|
|
|
147
|
-
r.add col_subject.new('medium length')
|
|
148
|
-
r.add col_subject.new('i am pretty long') # longest column
|
|
149
|
-
r.add col_subject.new('short', padding: 100)
|
|
150
|
-
end
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
t.add(
|
|
154
|
-
row_subject.new.tap do |r|
|
|
155
|
-
r.add col_subject.new('longer than medium length') # longest column
|
|
156
|
-
r.add col_subject.new('shorter')
|
|
157
|
-
r.add col_subject.new('longer than short') # longest column (inherits padding)
|
|
158
|
-
end
|
|
159
|
-
)
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
table.auto_adjust_widths
|
|
163
|
-
|
|
164
|
-
table.rows.each do |row|
|
|
165
|
-
expect(row.columns[0].width).to eq(col_subject.new('longer than medium length').required_width)
|
|
166
|
-
expect(row.columns[1].width).to eq(col_subject.new('i am pretty long').required_width)
|
|
167
|
-
expect(row.columns[2].width).to eq(col_subject.new('longer than short', padding: 100).required_width)
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
end
|