command_line_reporter 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -12
- data/lib/{column.rb → command_line_reporter/column.rb} +8 -3
- data/lib/{nested_formatter.rb → command_line_reporter/formatter/nested.rb} +0 -1
- data/lib/{progress_formatter.rb → command_line_reporter/formatter/progress.rb} +0 -1
- data/lib/{options_validator.rb → command_line_reporter/options_validator.rb} +0 -0
- data/lib/{row.rb → command_line_reporter/row.rb} +4 -5
- data/lib/command_line_reporter/table.rb +130 -0
- data/lib/{version.rb → command_line_reporter/version.rb} +1 -1
- data/lib/command_line_reporter.rb +9 -2
- data/spec/column_spec.rb +193 -202
- data/spec/command_line_reporter_spec.rb +146 -146
- data/spec/nested_formatter_spec.rb +101 -91
- data/spec/options_validator_spec.rb +0 -1
- data/spec/progress_formatter_spec.rb +20 -18
- data/spec/row_spec.rb +56 -52
- data/spec/spec_helper.rb +4 -2
- data/spec/table_spec.rb +54 -16
- metadata +54 -57
- data/examples/capture.rb +0 -32
- data/examples/nested.rb +0 -38
- data/examples/progress.rb +0 -68
- data/examples/quiet.rb +0 -40
- data/examples/simple.rb +0 -23
- data/examples/table.rb +0 -71
- data/examples/variable.rb +0 -30
- data/lib/table.rb +0 -96
data/spec/column_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'column'
|
3
2
|
|
4
3
|
describe CommandLineReporter::Column do
|
5
4
|
describe '#initialize' do
|
@@ -16,11 +15,11 @@ describe CommandLineReporter::Column do
|
|
16
15
|
end
|
17
16
|
|
18
17
|
it 'defaults the width' do
|
19
|
-
CommandLineReporter::Column.new('test').width.
|
18
|
+
expect(CommandLineReporter::Column.new('test').width).to eq(10)
|
20
19
|
end
|
21
20
|
|
22
21
|
it 'accepts the width' do
|
23
|
-
CommandLineReporter::Column.new('test', :width => 50).width.
|
22
|
+
expect(CommandLineReporter::Column.new('test', :width => 50).width).to eq(50)
|
24
23
|
end
|
25
24
|
|
26
25
|
it 'requires valid width' do
|
@@ -30,23 +29,23 @@ describe CommandLineReporter::Column do
|
|
30
29
|
end
|
31
30
|
|
32
31
|
it 'accepts text' do
|
33
|
-
CommandLineReporter::Column.new('asdf').text.
|
32
|
+
expect(CommandLineReporter::Column.new('asdf').text).to eq('asdf')
|
34
33
|
end
|
35
34
|
|
36
35
|
it 'accepts color' do
|
37
|
-
CommandLineReporter::Column.new('asdf', :color => 'red').color.
|
36
|
+
expect(CommandLineReporter::Column.new('asdf', :color => 'red').color).to eq('red')
|
38
37
|
end
|
39
38
|
|
40
39
|
it 'accepts bold' do
|
41
|
-
CommandLineReporter::Column.new('asdf', :bold => true).bold.
|
40
|
+
expect(CommandLineReporter::Column.new('asdf', :bold => true).bold).to be_true
|
42
41
|
end
|
43
42
|
|
44
43
|
it 'defaults the padding' do
|
45
|
-
CommandLineReporter::Column.new('test').padding.
|
44
|
+
expect(CommandLineReporter::Column.new('test').padding).to eq(0)
|
46
45
|
end
|
47
46
|
|
48
47
|
it 'accepts the padding' do
|
49
|
-
CommandLineReporter::Column.new('test', :padding => 5).padding.
|
48
|
+
expect(CommandLineReporter::Column.new('test', :padding => 5).padding).to eq(5)
|
50
49
|
end
|
51
50
|
|
52
51
|
it 'requires valid width' do
|
@@ -56,9 +55,25 @@ describe CommandLineReporter::Column do
|
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
58
|
+
describe '#size' do
|
59
|
+
it 'is the width less twice the padding' do
|
60
|
+
expect(CommandLineReporter::Column.new('test').size).to eq(10)
|
61
|
+
expect(CommandLineReporter::Column.new('test', :width => 5).size).to eq(5)
|
62
|
+
expect(CommandLineReporter::Column.new('test', :width => 5, :padding => 1).size).to eq(3)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#required_width' do
|
67
|
+
it 'is the length of the text plus twice the padding' do
|
68
|
+
expect(CommandLineReporter::Column.new('test').required_width).to eq(4)
|
69
|
+
expect(CommandLineReporter::Column.new('test', :padding => 1).required_width).to eq(6)
|
70
|
+
expect(CommandLineReporter::Column.new('test', :padding => 5).required_width).to eq(14)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
59
74
|
describe '#screen_rows' do
|
60
|
-
|
61
|
-
|
75
|
+
let :controls do
|
76
|
+
{
|
62
77
|
:clear => "\e[0m",
|
63
78
|
:bold => "\e[1m",
|
64
79
|
:red => "\e[31m",
|
@@ -74,143 +89,131 @@ describe CommandLineReporter::Column do
|
|
74
89
|
|
75
90
|
it 'handles empty text' do
|
76
91
|
c = CommandLineReporter::Column.new
|
77
|
-
c.screen_rows[0].
|
92
|
+
expect(c.screen_rows[0]).to eq(' ' * 10)
|
78
93
|
end
|
79
94
|
|
80
95
|
context 'left justifies' do
|
81
|
-
|
82
|
-
|
83
|
-
@filler = ' ' * 10
|
84
|
-
end
|
96
|
+
let(:text) { 'x' * 10 }
|
97
|
+
let(:filler) { ' ' * 10 }
|
85
98
|
|
86
99
|
it 'plain text' do
|
87
|
-
c = CommandLineReporter::Column.new(
|
88
|
-
c.screen_rows[0].
|
100
|
+
c = CommandLineReporter::Column.new(text, :width => 20)
|
101
|
+
expect(c.screen_rows[0]).to eq(text + filler)
|
89
102
|
end
|
90
103
|
|
91
104
|
it 'outputs red' do
|
92
|
-
c = CommandLineReporter::Column.new(
|
93
|
-
c.screen_rows[0].
|
105
|
+
c = CommandLineReporter::Column.new(text, :align => 'left', :width => 20, :color => 'red')
|
106
|
+
expect(c.screen_rows[0]).to eq(controls[:red] + text + filler + controls[:clear])
|
94
107
|
end
|
95
108
|
|
96
109
|
it 'outputs bold' do
|
97
|
-
c = CommandLineReporter::Column.new(
|
98
|
-
c.screen_rows[0].
|
110
|
+
c = CommandLineReporter::Column.new(text, :align => 'left', :width => 20, :bold => true)
|
111
|
+
expect(c.screen_rows[0]).to eq(controls[:bold] + text + filler + controls[:clear])
|
99
112
|
end
|
100
113
|
end
|
101
114
|
|
102
115
|
context 'right justifies' do
|
103
|
-
|
104
|
-
|
105
|
-
@filler = ' ' * 10
|
106
|
-
end
|
116
|
+
let(:text) { 'x' * 10 }
|
117
|
+
let(:filler) { ' ' * 10 }
|
107
118
|
|
108
119
|
it 'plain text' do
|
109
|
-
c = CommandLineReporter::Column.new(
|
110
|
-
c.screen_rows[0].
|
120
|
+
c = CommandLineReporter::Column.new(text, :align => 'right', :width => 20)
|
121
|
+
expect(c.screen_rows[0]).to eq(filler + text)
|
111
122
|
end
|
112
123
|
|
113
124
|
it 'outputs red' do
|
114
|
-
c = CommandLineReporter::Column.new(
|
115
|
-
c.screen_rows[0].
|
125
|
+
c = CommandLineReporter::Column.new(text, :align => 'right', :width => 20, :color => 'red')
|
126
|
+
expect(c.screen_rows[0]).to eq(controls[:red] + filler + text + controls[:clear])
|
116
127
|
end
|
117
128
|
|
118
129
|
it 'outputs bold' do
|
119
|
-
c = CommandLineReporter::Column.new(
|
120
|
-
c.screen_rows[0].
|
130
|
+
c = CommandLineReporter::Column.new(text, :align => 'right', :width => 20, :bold => true)
|
131
|
+
expect(c.screen_rows[0]).to eq(controls[:bold] + filler + text + controls[:clear])
|
121
132
|
end
|
122
133
|
end
|
123
134
|
|
124
135
|
context 'center justifies' do
|
125
|
-
|
126
|
-
|
127
|
-
@filler = ' ' * 5
|
128
|
-
end
|
136
|
+
let(:text) { 'x' * 10 }
|
137
|
+
let(:filler) { ' ' * 5 }
|
129
138
|
|
130
139
|
it 'plain text' do
|
131
|
-
c = CommandLineReporter::Column.new(
|
132
|
-
c.screen_rows[0].
|
140
|
+
c = CommandLineReporter::Column.new(text, :align => 'center', :width => 20)
|
141
|
+
expect(c.screen_rows[0]).to eq(filler + text + filler)
|
133
142
|
end
|
134
143
|
|
135
144
|
it 'outputs red' do
|
136
|
-
c = CommandLineReporter::Column.new(
|
137
|
-
c.screen_rows[0].
|
145
|
+
c = CommandLineReporter::Column.new(text, :align => 'center', :width => 20, :color => 'red')
|
146
|
+
expect(c.screen_rows[0]).to eq(controls[:red] + filler + text + filler + controls[:clear])
|
138
147
|
end
|
139
148
|
|
140
149
|
it 'outputs bold' do
|
141
|
-
c = CommandLineReporter::Column.new(
|
142
|
-
c.screen_rows[0].
|
150
|
+
c = CommandLineReporter::Column.new(text, :align => 'center', :width => 20, :bold => true)
|
151
|
+
expect(c.screen_rows[0]).to eq(controls[:bold] + filler + text + filler + controls[:clear])
|
143
152
|
end
|
144
153
|
end
|
145
154
|
end
|
146
155
|
|
147
156
|
context 'accounts for padding' do
|
148
157
|
context 'left justifies' do
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
@filler = ' ' * 10
|
153
|
-
end
|
158
|
+
let(:text) { 'x' * 10 }
|
159
|
+
let(:padding) { ' ' * 5 }
|
160
|
+
let(:filler) { ' ' * 10 }
|
154
161
|
|
155
162
|
it 'plain text' do
|
156
|
-
c = CommandLineReporter::Column.new(
|
157
|
-
c.screen_rows[0].
|
163
|
+
c = CommandLineReporter::Column.new(text, :padding => 5, :width => 30)
|
164
|
+
expect(c.screen_rows[0]).to eq(padding + text + filler + padding)
|
158
165
|
end
|
159
166
|
|
160
167
|
it 'outputs red' do
|
161
|
-
c = CommandLineReporter::Column.new(
|
162
|
-
c.screen_rows[0].
|
168
|
+
c = CommandLineReporter::Column.new(text, :padding => 5, :width => 30, :color => 'red')
|
169
|
+
expect(c.screen_rows[0]).to eq(padding + controls[:red] + text + filler + controls[:clear] + padding)
|
163
170
|
end
|
164
171
|
|
165
172
|
it 'outputs bold' do
|
166
|
-
c = CommandLineReporter::Column.new(
|
167
|
-
c.screen_rows[0].
|
173
|
+
c = CommandLineReporter::Column.new(text, :padding => 5, :width => 30, :bold => true)
|
174
|
+
expect(c.screen_rows[0]).to eq(padding + controls[:bold] + text + filler + controls[:clear] + padding)
|
168
175
|
end
|
169
176
|
end
|
170
177
|
|
171
178
|
context 'right justifies' do
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
@filler = ' ' * 10
|
176
|
-
end
|
179
|
+
let(:text) { 'x' * 10 }
|
180
|
+
let(:padding) { ' ' * 5 }
|
181
|
+
let(:filler) { ' ' * 10 }
|
177
182
|
|
178
183
|
it 'plain text' do
|
179
|
-
c = CommandLineReporter::Column.new(
|
180
|
-
c.screen_rows[0].
|
184
|
+
c = CommandLineReporter::Column.new(text, :align => 'right', :padding => 5, :width => 30)
|
185
|
+
expect(c.screen_rows[0]).to eq(padding + filler + text + padding)
|
181
186
|
end
|
182
187
|
|
183
188
|
it 'outputs red' do
|
184
|
-
c = CommandLineReporter::Column.new(
|
185
|
-
c.screen_rows[0].
|
189
|
+
c = CommandLineReporter::Column.new(text, :align => 'right', :padding => 5, :width => 30, :color => 'red')
|
190
|
+
expect(c.screen_rows[0]).to eq(padding + controls[:red] + filler + text + controls[:clear] + padding)
|
186
191
|
end
|
187
192
|
|
188
193
|
it 'outputs bold' do
|
189
|
-
c = CommandLineReporter::Column.new(
|
190
|
-
c.screen_rows[0].
|
194
|
+
c = CommandLineReporter::Column.new(text, :align => 'right', :padding => 5, :width => 30, :bold => true)
|
195
|
+
expect(c.screen_rows[0]).to eq(padding + controls[:bold] + filler + text + controls[:clear] + padding)
|
191
196
|
end
|
192
197
|
end
|
193
198
|
|
194
199
|
context 'right justifies' do
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
@filler = ' ' * 5
|
199
|
-
end
|
200
|
+
let(:text) { 'x' * 10 }
|
201
|
+
let(:padding) { ' ' * 5 }
|
202
|
+
let(:filler) { ' ' * 5 }
|
200
203
|
|
201
204
|
it 'plain text' do
|
202
|
-
c = CommandLineReporter::Column.new(
|
203
|
-
c.screen_rows[0].
|
205
|
+
c = CommandLineReporter::Column.new(text, :align => 'center', :padding => 5, :width => 30)
|
206
|
+
expect(c.screen_rows[0]).to eq(padding + filler + text + filler + padding)
|
204
207
|
end
|
205
208
|
|
206
209
|
it 'outputs red' do
|
207
|
-
c = CommandLineReporter::Column.new(
|
208
|
-
c.screen_rows[0].
|
210
|
+
c = CommandLineReporter::Column.new(text, :align => 'center', :padding => 5, :width => 30, :color => 'red')
|
211
|
+
expect(c.screen_rows[0]).to eq(padding + controls[:red] + filler + text + filler + controls[:clear] + padding)
|
209
212
|
end
|
210
213
|
|
211
214
|
it 'outputs bold' do
|
212
|
-
c = CommandLineReporter::Column.new(
|
213
|
-
c.screen_rows[0].
|
215
|
+
c = CommandLineReporter::Column.new(text, :align => 'center', :padding => 5, :width => 30, :bold => true)
|
216
|
+
expect(c.screen_rows[0]).to eq(padding + controls[:bold] + filler + text + filler + controls[:clear] + padding)
|
214
217
|
end
|
215
218
|
end
|
216
219
|
end
|
@@ -219,204 +222,192 @@ describe CommandLineReporter::Column do
|
|
219
222
|
context 'with wrapping' do
|
220
223
|
context 'no padding' do
|
221
224
|
context 'left justifies' do
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
@filler = ' ' * 5
|
227
|
-
end
|
225
|
+
let(:text) { 'x' * 25 }
|
226
|
+
let(:full_line) { 'x' * 10 }
|
227
|
+
let(:remainder) { 'x' * 5 }
|
228
|
+
let(:filler) { ' ' * 5 }
|
228
229
|
|
229
230
|
it 'plain text' do
|
230
|
-
c = CommandLineReporter::Column.new(
|
231
|
-
c.screen_rows.
|
231
|
+
c = CommandLineReporter::Column.new(text, :width => 10)
|
232
|
+
expect(c.screen_rows).to eq([full_line, full_line, remainder + filler])
|
232
233
|
end
|
233
234
|
|
234
235
|
it 'outputs red' do
|
235
|
-
c = CommandLineReporter::Column.new(
|
236
|
-
c.screen_rows.
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
]
|
236
|
+
c = CommandLineReporter::Column.new(text, :width => 10, :color => 'red')
|
237
|
+
expect(c.screen_rows).to eq([
|
238
|
+
controls[:red] + full_line + controls[:clear],
|
239
|
+
controls[:red] + full_line + controls[:clear],
|
240
|
+
controls[:red] + remainder + filler + controls[:clear],
|
241
|
+
])
|
241
242
|
end
|
242
243
|
|
243
244
|
it 'outputs bold' do
|
244
|
-
c = CommandLineReporter::Column.new(
|
245
|
-
c.screen_rows.
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
]
|
245
|
+
c = CommandLineReporter::Column.new(text, :width => 10, :bold => true)
|
246
|
+
expect(c.screen_rows).to eq([
|
247
|
+
controls[:bold] + full_line + controls[:clear],
|
248
|
+
controls[:bold] + full_line + controls[:clear],
|
249
|
+
controls[:bold] + remainder + filler + controls[:clear],
|
250
|
+
])
|
250
251
|
end
|
251
252
|
end
|
252
253
|
|
253
254
|
context 'right justifies' do
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
@filler = ' ' * 5
|
259
|
-
end
|
255
|
+
let(:text) { 'x' * 25 }
|
256
|
+
let(:full_line) { 'x' * 10 }
|
257
|
+
let(:remainder) { 'x' * 5 }
|
258
|
+
let(:filler) { ' ' * 5 }
|
260
259
|
|
261
260
|
it 'plain text' do
|
262
|
-
c = CommandLineReporter::Column.new(
|
263
|
-
c.screen_rows.
|
261
|
+
c = CommandLineReporter::Column.new(text, :align => 'right', :width => 10)
|
262
|
+
expect(c.screen_rows).to eq([full_line, full_line, filler + remainder])
|
264
263
|
end
|
265
264
|
|
266
265
|
it 'outputs red' do
|
267
|
-
c = CommandLineReporter::Column.new(
|
268
|
-
c.screen_rows.
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
]
|
266
|
+
c = CommandLineReporter::Column.new(text, :align => 'right', :width => 10, :color => 'red')
|
267
|
+
expect(c.screen_rows).to eq([
|
268
|
+
controls[:red] + full_line + controls[:clear],
|
269
|
+
controls[:red] + full_line + controls[:clear],
|
270
|
+
controls[:red] + filler + remainder + controls[:clear],
|
271
|
+
])
|
273
272
|
end
|
274
273
|
|
275
274
|
it 'outputs bold' do
|
276
|
-
c = CommandLineReporter::Column.new(
|
277
|
-
c.screen_rows.
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
]
|
275
|
+
c = CommandLineReporter::Column.new(text, :align => 'right', :width => 10, :bold => true)
|
276
|
+
expect(c.screen_rows).to eq([
|
277
|
+
controls[:bold] + full_line + controls[:clear],
|
278
|
+
controls[:bold] + full_line + controls[:clear],
|
279
|
+
controls[:bold] + filler + remainder + controls[:clear],
|
280
|
+
])
|
282
281
|
end
|
283
282
|
end
|
284
283
|
|
285
284
|
context 'center justifies' do
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
@right_filler = ' ' * 2
|
292
|
-
end
|
285
|
+
let(:text) { 'x' * 25 }
|
286
|
+
let(:full_line) { 'x' * 10 }
|
287
|
+
let(:remainder) { 'x' * 5 }
|
288
|
+
let(:left_filler) { ' ' * 3 }
|
289
|
+
let(:right_filler) { ' ' * 2 }
|
293
290
|
|
294
291
|
it 'plain text' do
|
295
|
-
c = CommandLineReporter::Column.new(
|
296
|
-
c.screen_rows.
|
292
|
+
c = CommandLineReporter::Column.new(text, :align => 'center', :width => 10)
|
293
|
+
expect(c.screen_rows).to eq([full_line, full_line, ' ' * 3 + remainder + right_filler])
|
297
294
|
end
|
298
295
|
|
299
296
|
it 'outputs red' do
|
300
|
-
c = CommandLineReporter::Column.new(
|
301
|
-
c.screen_rows.
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
]
|
297
|
+
c = CommandLineReporter::Column.new(text, :align => 'center', :width => 10, :color => 'red')
|
298
|
+
expect(c.screen_rows).to eq([
|
299
|
+
controls[:red] + full_line + controls[:clear],
|
300
|
+
controls[:red] + full_line + controls[:clear],
|
301
|
+
controls[:red] + left_filler + remainder + right_filler + controls[:clear],
|
302
|
+
])
|
306
303
|
end
|
307
304
|
|
308
305
|
it 'outputs bold' do
|
309
|
-
c = CommandLineReporter::Column.new(
|
310
|
-
c.screen_rows.
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
]
|
306
|
+
c = CommandLineReporter::Column.new(text, :align => 'center', :width => 10, :bold => true)
|
307
|
+
expect(c.screen_rows).to eq([
|
308
|
+
controls[:bold] + full_line + controls[:clear],
|
309
|
+
controls[:bold] + full_line + controls[:clear],
|
310
|
+
controls[:bold] + left_filler + remainder + right_filler + controls[:clear],
|
311
|
+
])
|
315
312
|
end
|
316
313
|
end
|
317
314
|
end
|
318
315
|
|
319
316
|
context 'account for padding' do
|
320
317
|
context 'left justifies' do
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
@filler = ' ' * 7
|
327
|
-
end
|
318
|
+
let(:text) { 'x' * 25 }
|
319
|
+
let(:full_line) { 'x' * 16 }
|
320
|
+
let(:remainder) { 'x' * 9 }
|
321
|
+
let(:padding) { ' ' * 2 }
|
322
|
+
let(:filler) { ' ' * 7 }
|
328
323
|
|
329
324
|
it 'plain text' do
|
330
|
-
c = CommandLineReporter::Column.new(
|
331
|
-
c.screen_rows.
|
332
|
-
|
333
|
-
|
334
|
-
]
|
325
|
+
c = CommandLineReporter::Column.new(text, :padding => 2, :width => 20)
|
326
|
+
expect(c.screen_rows).to eq([
|
327
|
+
padding + full_line + padding,
|
328
|
+
padding + remainder + filler + padding,
|
329
|
+
])
|
335
330
|
end
|
336
331
|
|
337
332
|
it 'outputs red' do
|
338
|
-
c = CommandLineReporter::Column.new(
|
339
|
-
c.screen_rows.
|
340
|
-
|
341
|
-
|
342
|
-
]
|
333
|
+
c = CommandLineReporter::Column.new(text, :padding => 2, :width => 20, :color => 'red')
|
334
|
+
expect(c.screen_rows).to eq([
|
335
|
+
padding + controls[:red] + full_line + controls[:clear] + padding,
|
336
|
+
padding + controls[:red] + remainder + filler + controls[:clear] + padding,
|
337
|
+
])
|
343
338
|
end
|
344
339
|
|
345
340
|
it 'outputs bold' do
|
346
|
-
c = CommandLineReporter::Column.new(
|
347
|
-
c.screen_rows.
|
348
|
-
|
349
|
-
|
350
|
-
]
|
341
|
+
c = CommandLineReporter::Column.new(text, :padding => 2, :width => 20, :bold => true)
|
342
|
+
expect(c.screen_rows).to eq([
|
343
|
+
padding + controls[:bold] + full_line + controls[:clear] + padding,
|
344
|
+
padding + controls[:bold] + remainder + filler + controls[:clear] + padding,
|
345
|
+
])
|
351
346
|
end
|
352
347
|
end
|
353
348
|
|
354
349
|
context 'right justifies' do
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
@filler = ' ' * 7
|
361
|
-
end
|
350
|
+
let(:text) { 'x' * 25 }
|
351
|
+
let(:full_line) { 'x' * 16 }
|
352
|
+
let(:remainder) { 'x' * 9 }
|
353
|
+
let(:padding) { ' ' * 2 }
|
354
|
+
let(:filler) { ' ' * 7 }
|
362
355
|
|
363
356
|
it 'plain text' do
|
364
|
-
c = CommandLineReporter::Column.new(
|
365
|
-
c.screen_rows.
|
366
|
-
|
367
|
-
|
368
|
-
]
|
357
|
+
c = CommandLineReporter::Column.new(text, :padding => 2, :align => 'right', :width => 20)
|
358
|
+
expect(c.screen_rows).to eq([
|
359
|
+
padding + full_line + padding,
|
360
|
+
padding + filler + remainder + padding,
|
361
|
+
])
|
369
362
|
end
|
370
363
|
|
371
364
|
it 'outputs red' do
|
372
|
-
c = CommandLineReporter::Column.new(
|
373
|
-
c.screen_rows.
|
374
|
-
|
375
|
-
|
376
|
-
]
|
365
|
+
c = CommandLineReporter::Column.new(text, :align => 'right', :padding => 2, :width => 20, :color => 'red')
|
366
|
+
expect(c.screen_rows).to eq([
|
367
|
+
padding + controls[:red] + full_line + controls[:clear] + padding,
|
368
|
+
padding + controls[:red] + filler + remainder + controls[:clear] + padding,
|
369
|
+
])
|
377
370
|
end
|
378
371
|
|
379
372
|
it 'outputs bold' do
|
380
|
-
c = CommandLineReporter::Column.new(
|
381
|
-
c.screen_rows.
|
382
|
-
|
383
|
-
|
384
|
-
]
|
373
|
+
c = CommandLineReporter::Column.new(text, :align => 'right', :padding => 2, :width => 20, :bold => true)
|
374
|
+
expect(c.screen_rows).to eq([
|
375
|
+
padding + controls[:bold] + full_line + controls[:clear] + padding,
|
376
|
+
padding + controls[:bold] + filler + remainder + controls[:clear] + padding,
|
377
|
+
])
|
385
378
|
end
|
386
379
|
end
|
387
380
|
|
388
381
|
context 'center justifies' do
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
@right_filler = ' ' * 3
|
396
|
-
end
|
382
|
+
let(:text) { 'x' * 25 }
|
383
|
+
let(:full_line) { 'x' * 16 }
|
384
|
+
let(:remainder) { 'x' * 9 }
|
385
|
+
let(:padding) { ' ' * 2 }
|
386
|
+
let(:left_filler) { ' ' * 4 }
|
387
|
+
let(:right_filler) { ' ' * 3 }
|
397
388
|
|
398
389
|
it 'plain text' do
|
399
|
-
c = CommandLineReporter::Column.new(
|
400
|
-
c.screen_rows.
|
401
|
-
|
402
|
-
|
403
|
-
]
|
390
|
+
c = CommandLineReporter::Column.new(text, :padding => 2, :align => 'center', :width => 20)
|
391
|
+
expect(c.screen_rows).to eq([
|
392
|
+
padding + full_line + padding,
|
393
|
+
padding + left_filler + remainder + right_filler + padding,
|
394
|
+
])
|
404
395
|
end
|
405
396
|
|
406
397
|
it 'outputs red' do
|
407
|
-
c = CommandLineReporter::Column.new(
|
408
|
-
c.screen_rows.
|
409
|
-
|
410
|
-
|
411
|
-
]
|
398
|
+
c = CommandLineReporter::Column.new(text, :padding => 2, :align => 'center', :width => 20, :color => 'red')
|
399
|
+
expect(c.screen_rows).to eq([
|
400
|
+
padding + controls[:red] + full_line + controls[:clear] + padding,
|
401
|
+
padding + controls[:red] + left_filler + remainder + right_filler + controls[:clear] + padding,
|
402
|
+
])
|
412
403
|
end
|
413
404
|
|
414
405
|
it 'outputs bold' do
|
415
|
-
c = CommandLineReporter::Column.new(
|
416
|
-
c.screen_rows.
|
417
|
-
|
418
|
-
|
419
|
-
]
|
406
|
+
c = CommandLineReporter::Column.new(text, :padding => 2, :align => 'center', :width => 20, :bold => true)
|
407
|
+
expect(c.screen_rows).to eq([
|
408
|
+
padding + controls[:bold] + full_line + controls[:clear] + padding,
|
409
|
+
padding + controls[:bold] + left_filler + remainder + right_filler + controls[:clear] + padding,
|
410
|
+
])
|
420
411
|
end
|
421
412
|
end
|
422
413
|
end
|