command_line_reporter 3.2.1 → 3.3.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.
- 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
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'command_line_reporter'
|
3
2
|
|
4
3
|
describe CommandLineReporter do
|
5
4
|
let :use_class do
|
@@ -8,20 +7,20 @@ describe CommandLineReporter do
|
|
8
7
|
end
|
9
8
|
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
before :each do
|
14
|
-
@timestamp_regex = /\d{4}-\d{2}-\d{2} - (\d| )\d:\d{2}:\d{2}[AP]M/
|
15
|
-
end
|
10
|
+
let(:timestamp_regex) { /\d{4}-\d{2}-\d{2} - (\d| )\d:\d{2}:\d{2}[AP]M/ }
|
16
11
|
|
17
|
-
|
18
|
-
|
12
|
+
let :controls do
|
13
|
+
{
|
19
14
|
:clear => "\e[0m",
|
20
15
|
:bold => "\e[1m",
|
21
16
|
:red => "\e[31m",
|
22
17
|
}
|
23
18
|
end
|
24
19
|
|
20
|
+
let(:linechar) { "\u2501" == 'u2501' ? '-' : "\u2501" }
|
21
|
+
|
22
|
+
subject { use_class.new }
|
23
|
+
|
25
24
|
describe '#formatter=' do
|
26
25
|
it 'only allows allowed formatters' do
|
27
26
|
expect {
|
@@ -31,12 +30,12 @@ describe CommandLineReporter do
|
|
31
30
|
|
32
31
|
it 'specifies the progress formatter' do
|
33
32
|
subject.formatter = 'progress'
|
34
|
-
subject.formatter.class.
|
33
|
+
expect(subject.formatter.class).to eq(CommandLineReporter::ProgressFormatter)
|
35
34
|
end
|
36
35
|
|
37
36
|
it 'specifies the nested formatter' do
|
38
37
|
subject.formatter = 'nested'
|
39
|
-
subject.formatter.class.
|
38
|
+
expect(subject.formatter.class).to eq(CommandLineReporter::NestedFormatter)
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
@@ -46,7 +45,7 @@ describe CommandLineReporter do
|
|
46
45
|
subject.report { }
|
47
46
|
}
|
48
47
|
|
49
|
-
subject.formatter.class.
|
48
|
+
expect(subject.formatter.class).to eq(CommandLineReporter::NestedFormatter)
|
50
49
|
end
|
51
50
|
|
52
51
|
it 'uses the progress formatter' do
|
@@ -55,13 +54,13 @@ describe CommandLineReporter do
|
|
55
54
|
subject.report { }
|
56
55
|
}
|
57
56
|
|
58
|
-
subject.formatter.class.
|
57
|
+
expect(subject.formatter.class).to eq(CommandLineReporter::ProgressFormatter)
|
59
58
|
end
|
60
59
|
|
61
60
|
it 'does not mask other application errors when a formatter is not set' do
|
62
61
|
capture_stdout {
|
63
62
|
subject.report {
|
64
|
-
|
63
|
+
expect {self.some_method_that_does_not_exist}.to raise_error(NoMethodError)
|
65
64
|
}
|
66
65
|
}
|
67
66
|
end
|
@@ -78,9 +77,9 @@ describe CommandLineReporter do
|
|
78
77
|
|
79
78
|
it 'accepts a title' do
|
80
79
|
expect {
|
81
|
-
subject.
|
80
|
+
allow(subject).to receive(:puts)
|
82
81
|
subject.header(:title => 'test')
|
83
|
-
}.to_not raise_error
|
82
|
+
}.to_not raise_error
|
84
83
|
end
|
85
84
|
|
86
85
|
it 'does not allow a title > width' do
|
@@ -91,9 +90,9 @@ describe CommandLineReporter do
|
|
91
90
|
|
92
91
|
it 'accepts width' do
|
93
92
|
expect {
|
94
|
-
subject.
|
93
|
+
allow(subject).to receive(:puts)
|
95
94
|
subject.header(:width => 100)
|
96
|
-
}.to_not raise_error
|
95
|
+
}.to_not raise_error
|
97
96
|
end
|
98
97
|
|
99
98
|
it 'ensure width is a number' do
|
@@ -104,9 +103,9 @@ describe CommandLineReporter do
|
|
104
103
|
|
105
104
|
it 'accepts align' do
|
106
105
|
expect {
|
107
|
-
subject.
|
106
|
+
allow(subject).to receive(:puts)
|
108
107
|
subject.header(:align => 'center')
|
109
|
-
}.to_not raise_error
|
108
|
+
}.to_not raise_error
|
110
109
|
end
|
111
110
|
|
112
111
|
it 'ensure align is a valid value' do
|
@@ -117,30 +116,30 @@ describe CommandLineReporter do
|
|
117
116
|
|
118
117
|
it 'accepts spacing' do
|
119
118
|
expect {
|
120
|
-
subject.
|
119
|
+
allow(subject).to receive(:puts)
|
121
120
|
subject.header(:spacing => 2)
|
122
|
-
}.to_not raise_error
|
121
|
+
}.to_not raise_error
|
123
122
|
end
|
124
123
|
|
125
124
|
it 'accepts timestamp' do
|
126
125
|
expect {
|
127
|
-
subject.
|
126
|
+
allow(subject).to receive(:puts)
|
128
127
|
subject.header(:timestamp => true)
|
129
|
-
}.to_not raise_error
|
128
|
+
}.to_not raise_error
|
130
129
|
end
|
131
130
|
|
132
131
|
it 'accepts color' do
|
133
132
|
expect {
|
134
|
-
subject.
|
133
|
+
allow(subject).to receive(:puts)
|
135
134
|
subject.header(:color => 'red')
|
136
|
-
}.to_not raise_error
|
135
|
+
}.to_not raise_error
|
137
136
|
end
|
138
137
|
|
139
138
|
it 'accepts bold' do
|
140
139
|
expect {
|
141
|
-
subject.
|
140
|
+
allow(subject).to receive(:puts)
|
142
141
|
subject.header(:bold => true)
|
143
|
-
}.to_not raise_error
|
142
|
+
}.to_not raise_error
|
144
143
|
end
|
145
144
|
end
|
146
145
|
|
@@ -150,121 +149,121 @@ describe CommandLineReporter do
|
|
150
149
|
end
|
151
150
|
|
152
151
|
it 'left aligns title by default' do
|
153
|
-
subject.
|
154
|
-
subject.
|
152
|
+
expect(subject).to receive(:puts).with(@title)
|
153
|
+
expect(subject).to receive(:puts).with("\n")
|
155
154
|
subject.header(:title => @title) { }
|
156
155
|
end
|
157
156
|
|
158
157
|
it 'left aligns title' do
|
159
|
-
subject.
|
160
|
-
subject.
|
158
|
+
expect(subject).to receive(:puts).with(@title)
|
159
|
+
expect(subject).to receive(:puts).with("\n")
|
161
160
|
subject.header(:title => @title, :align => 'left') { }
|
162
161
|
end
|
163
162
|
|
164
163
|
it 'right aligns title using default width' do
|
165
|
-
subject.
|
166
|
-
subject.
|
164
|
+
expect(subject).to receive(:puts).with(' ' * 90 + @title)
|
165
|
+
expect(subject).to receive(:puts).with("\n")
|
167
166
|
subject.header(:title => @title, :align => 'right')
|
168
167
|
end
|
169
168
|
|
170
169
|
it 'right aligns title using specified width' do
|
171
|
-
subject.
|
172
|
-
subject.
|
170
|
+
expect(subject).to receive(:puts).with(' ' * 40 + @title)
|
171
|
+
expect(subject).to receive(:puts).with("\n")
|
173
172
|
subject.header(:title => @title, :align => 'right', :width => 50)
|
174
173
|
end
|
175
174
|
|
176
175
|
it 'center aligns title using default width' do
|
177
|
-
subject.
|
178
|
-
subject.
|
176
|
+
expect(subject).to receive(:puts).with(' ' * 45 + @title)
|
177
|
+
expect(subject).to receive(:puts).with("\n")
|
179
178
|
subject.header(:title => @title, :align => 'center')
|
180
179
|
end
|
181
180
|
|
182
181
|
it 'center aligns title using specified width' do
|
183
|
-
subject.
|
184
|
-
subject.
|
182
|
+
expect(subject).to receive(:puts).with(' ' * 35 + @title)
|
183
|
+
expect(subject).to receive(:puts).with("\n")
|
185
184
|
subject.header(:title => @title, :align => 'center', :width => 80)
|
186
185
|
end
|
187
186
|
end
|
188
187
|
|
189
188
|
context 'spacing' do
|
190
189
|
it 'defaults to a single line of spacing between report' do
|
191
|
-
subject.
|
192
|
-
subject.
|
190
|
+
expect(subject).to receive(:puts).with('title')
|
191
|
+
expect(subject).to receive(:puts).with("\n")
|
193
192
|
subject.header(:title => 'title')
|
194
193
|
end
|
195
194
|
|
196
195
|
it 'uses the defined spacing between report' do
|
197
|
-
subject.
|
198
|
-
subject.
|
196
|
+
expect(subject).to receive(:puts).with('title')
|
197
|
+
expect(subject).to receive(:puts).with("\n" * 3)
|
199
198
|
subject.header(:title => 'title', :spacing => 3)
|
200
199
|
end
|
201
200
|
end
|
202
201
|
|
203
202
|
context 'timestamp subheading' do
|
204
203
|
it 'is added with default alignment' do
|
205
|
-
subject.
|
206
|
-
subject.
|
207
|
-
subject.
|
204
|
+
expect(subject).to receive(:puts).with('title')
|
205
|
+
expect(subject).to receive(:puts).with(/^#{timestamp_regex}/)
|
206
|
+
expect(subject).to receive(:puts).with("\n")
|
208
207
|
subject.header(:title => 'title', :timestamp => true)
|
209
208
|
end
|
210
209
|
|
211
210
|
it 'added with right alignment' do
|
212
|
-
subject.
|
213
|
-
subject.
|
214
|
-
subject.
|
211
|
+
expect(subject).to receive(:puts).with(/^ *title$/)
|
212
|
+
expect(subject).to receive(:puts).with(/^ *#{timestamp_regex}$/)
|
213
|
+
expect(subject).to receive(:puts).with("\n")
|
215
214
|
subject.header(:title => 'title', :align => 'right', :timestamp => true, :width => 80)
|
216
215
|
end
|
217
216
|
|
218
217
|
it 'added with center alignment' do
|
219
|
-
subject.
|
220
|
-
subject.
|
221
|
-
subject.
|
218
|
+
expect(subject).to receive(:puts).with(/^ *title *$/)
|
219
|
+
expect(subject).to receive(:puts).with(/^ *#{timestamp_regex} *$/)
|
220
|
+
expect(subject).to receive(:puts).with("\n")
|
222
221
|
subject.header(:title => 'title', :align => 'center', :timestamp => true, :width => 80)
|
223
222
|
end
|
224
223
|
end
|
225
224
|
|
226
225
|
context 'horizontal rule' do
|
227
226
|
it 'uses dashes by default' do
|
228
|
-
subject.
|
229
|
-
subject.
|
230
|
-
subject.
|
227
|
+
expect(subject).to receive(:puts)
|
228
|
+
expect(subject).to receive(:puts).with(linechar * 100)
|
229
|
+
expect(subject).to receive(:puts)
|
231
230
|
subject.header(:rule => true)
|
232
231
|
end
|
233
232
|
|
234
233
|
it 'uses = as the rule character' do
|
235
|
-
subject.
|
236
|
-
subject.
|
237
|
-
subject.
|
234
|
+
expect(subject).to receive(:puts)
|
235
|
+
expect(subject).to receive(:puts).with('=' * 100)
|
236
|
+
expect(subject).to receive(:puts)
|
238
237
|
subject.header(:rule => '=')
|
239
238
|
end
|
240
239
|
end
|
241
240
|
|
242
241
|
context 'color' do
|
243
242
|
it 'single red line' do
|
244
|
-
subject.
|
245
|
-
subject.
|
243
|
+
expect(subject).to receive(:puts).with(controls[:red] + 'Report' + controls[:clear])
|
244
|
+
expect(subject).to receive(:puts)
|
246
245
|
subject.header(:color => 'red')
|
247
246
|
end
|
248
247
|
|
249
248
|
it 'multimple red lines' do
|
250
|
-
subject.
|
251
|
-
subject.
|
252
|
-
subject.
|
249
|
+
expect(subject).to receive(:puts).with(controls[:red] + 'Report' + controls[:clear])
|
250
|
+
expect(subject).to receive(:puts).with(controls[:red] + linechar * 100 + controls[:clear])
|
251
|
+
expect(subject).to receive(:puts)
|
253
252
|
subject.header(:color => 'red', :rule => true)
|
254
253
|
end
|
255
254
|
end
|
256
255
|
|
257
256
|
context 'bold' do
|
258
257
|
it 'single line' do
|
259
|
-
subject.
|
260
|
-
subject.
|
258
|
+
expect(subject).to receive(:puts).with(controls[:bold] + 'Report' + controls[:clear])
|
259
|
+
expect(subject).to receive(:puts)
|
261
260
|
subject.header(:bold => true)
|
262
261
|
end
|
263
262
|
|
264
263
|
it 'multimple lines' do
|
265
|
-
subject.
|
266
|
-
subject.
|
267
|
-
subject.
|
264
|
+
expect(subject).to receive(:puts).with(controls[:bold] + 'Report' + controls[:clear])
|
265
|
+
expect(subject).to receive(:puts).with(controls[:bold] + linechar * 100 + controls[:clear])
|
266
|
+
expect(subject).to receive(:puts)
|
268
267
|
subject.header(:bold => true, :rule => true)
|
269
268
|
end
|
270
269
|
end
|
@@ -280,43 +279,43 @@ describe CommandLineReporter do
|
|
280
279
|
|
281
280
|
it 'accepts char' do
|
282
281
|
expect {
|
283
|
-
subject.
|
282
|
+
expect(subject).to receive(:puts)
|
284
283
|
subject.horizontal_rule(:char => '*')
|
285
|
-
}.to_not raise_error
|
284
|
+
}.to_not raise_error
|
286
285
|
end
|
287
286
|
|
288
287
|
it 'accepts width' do
|
289
288
|
expect {
|
290
|
-
subject.
|
289
|
+
expect(subject).to receive(:puts)
|
291
290
|
subject.horizontal_rule(:width => 10)
|
292
|
-
}.to_not raise_error
|
291
|
+
}.to_not raise_error
|
293
292
|
end
|
294
293
|
end
|
295
294
|
|
296
295
|
context 'drawing' do
|
297
296
|
it 'writes a 100 yard dash by default' do
|
298
|
-
subject.
|
297
|
+
expect(subject).to receive(:puts).with(linechar * 100)
|
299
298
|
subject.horizontal_rule
|
300
299
|
end
|
301
300
|
|
302
301
|
it 'writes a 100 yard asterisk' do
|
303
|
-
subject.
|
302
|
+
expect(subject).to receive(:puts).with('*' * 100)
|
304
303
|
subject.horizontal_rule(:char => '*')
|
305
304
|
end
|
306
305
|
|
307
306
|
it 'writes a 50 yard equals' do
|
308
|
-
subject.
|
307
|
+
expect(subject).to receive(:puts).with('=' * 50)
|
309
308
|
subject.horizontal_rule(:char => '=', :width => 50)
|
310
309
|
end
|
311
310
|
end
|
312
311
|
|
313
312
|
it 'outputs color' do
|
314
|
-
subject.
|
313
|
+
expect(subject).to receive(:puts).with(controls[:red] + linechar * 100 + controls[:clear])
|
315
314
|
subject.horizontal_rule(:color => 'red')
|
316
315
|
end
|
317
316
|
|
318
317
|
it 'outputs bold' do
|
319
|
-
subject.
|
318
|
+
expect(subject).to receive(:puts).with(controls[:bold] + linechar * 100 + controls[:clear])
|
320
319
|
subject.horizontal_rule(:bold => true)
|
321
320
|
end
|
322
321
|
end
|
@@ -329,7 +328,7 @@ describe CommandLineReporter do
|
|
329
328
|
end
|
330
329
|
|
331
330
|
it 'prints carriage returns for the number of lines' do
|
332
|
-
subject.
|
331
|
+
expect(subject).to receive(:puts).with("\n" * 3)
|
333
332
|
subject.vertical_spacing(3)
|
334
333
|
end
|
335
334
|
end
|
@@ -344,23 +343,23 @@ describe CommandLineReporter do
|
|
344
343
|
|
345
344
|
it 'accepts align' do
|
346
345
|
expect {
|
347
|
-
subject.
|
346
|
+
expect(subject).to receive(:puts)
|
348
347
|
subject.datetime(:align => 'left')
|
349
|
-
}.to_not raise_error
|
348
|
+
}.to_not raise_error
|
350
349
|
end
|
351
350
|
|
352
351
|
it 'accepts width' do
|
353
352
|
expect {
|
354
|
-
subject.
|
353
|
+
expect(subject).to receive(:puts)
|
355
354
|
subject.datetime(:width => 70)
|
356
|
-
}.to_not raise_error
|
355
|
+
}.to_not raise_error
|
357
356
|
end
|
358
357
|
|
359
358
|
it 'accepts format' do
|
360
359
|
expect {
|
361
|
-
subject.
|
360
|
+
expect(subject).to receive(:puts)
|
362
361
|
subject.datetime(:format => '%m/%d/%Y')
|
363
|
-
}.to_not raise_error
|
362
|
+
}.to_not raise_error
|
364
363
|
end
|
365
364
|
|
366
365
|
it 'does not allow invalid width' do
|
@@ -384,33 +383,33 @@ describe CommandLineReporter do
|
|
384
383
|
|
385
384
|
context 'display' do
|
386
385
|
it 'a default format - left aligned' do
|
387
|
-
subject.
|
386
|
+
expect(subject).to receive(:puts).with(/^#{timestamp_regex} *$/)
|
388
387
|
subject.datetime
|
389
388
|
end
|
390
389
|
|
391
390
|
it 'a default format - right aligned' do
|
392
|
-
subject.
|
391
|
+
expect(subject).to receive(:puts).with(/^ *#{timestamp_regex}$/)
|
393
392
|
subject.datetime(:align => 'right')
|
394
393
|
end
|
395
394
|
|
396
395
|
it 'a default format - center aligned' do
|
397
|
-
subject.
|
396
|
+
expect(subject).to receive(:puts).with(/^ *#{timestamp_regex} *$/)
|
398
397
|
subject.datetime(:align => 'center')
|
399
398
|
end
|
400
399
|
|
401
400
|
it 'a modified format' do
|
402
|
-
subject.
|
401
|
+
expect(subject).to receive(:puts).with(/^\d{2}\/\d{2}\/\d{2} *$/)
|
403
402
|
subject.datetime(:format => '%y/%m/%d')
|
404
403
|
end
|
405
404
|
end
|
406
405
|
|
407
406
|
it 'outputs color' do
|
408
|
-
subject.
|
407
|
+
expect(subject).to receive(:puts).with(/^\e\[31m#{timestamp_regex}\e\[0m/)
|
409
408
|
subject.datetime(:color => 'red')
|
410
409
|
end
|
411
410
|
|
412
411
|
it 'outputs bold' do
|
413
|
-
subject.
|
412
|
+
expect(subject).to receive(:puts).with(/^\e\[1m#{timestamp_regex}\e\[0m/)
|
414
413
|
subject.datetime(:bold => true)
|
415
414
|
end
|
416
415
|
end
|
@@ -419,7 +418,7 @@ describe CommandLineReporter do
|
|
419
418
|
context 'argument validation' do
|
420
419
|
it 'accepts align' do
|
421
420
|
expect {
|
422
|
-
subject.
|
421
|
+
allow(subject).to receive(:puts)
|
423
422
|
subject.aligned('test', :align => 'left')
|
424
423
|
}.to_not raise_error
|
425
424
|
end
|
@@ -432,7 +431,7 @@ describe CommandLineReporter do
|
|
432
431
|
|
433
432
|
it 'accepts width' do
|
434
433
|
expect {
|
435
|
-
subject.
|
434
|
+
allow(subject).to receive(:puts)
|
436
435
|
subject.aligned('test', :width => 40)
|
437
436
|
}.to_not raise_error
|
438
437
|
end
|
@@ -445,12 +444,12 @@ describe CommandLineReporter do
|
|
445
444
|
end
|
446
445
|
|
447
446
|
it 'outputs color' do
|
448
|
-
subject.
|
447
|
+
expect(subject).to receive(:puts).with(controls[:red] + 'x' * 10 + controls[:clear])
|
449
448
|
subject.aligned('x' * 10, :color => 'red')
|
450
449
|
end
|
451
450
|
|
452
451
|
it 'outputs bold' do
|
453
|
-
subject.
|
452
|
+
expect(subject).to receive(:puts).with(controls[:bold] + 'x' * 10 + controls[:clear])
|
454
453
|
subject.aligned('x' * 10, :bold => true)
|
455
454
|
end
|
456
455
|
|
@@ -460,16 +459,16 @@ describe CommandLineReporter do
|
|
460
459
|
context 'argument validation' do
|
461
460
|
it 'accepts title' do
|
462
461
|
expect {
|
463
|
-
subject.
|
462
|
+
allow(subject).to receive(:puts)
|
464
463
|
subject.footer(:title => 'test')
|
465
464
|
}.to_not raise_error
|
466
465
|
end
|
467
466
|
|
468
467
|
it 'accepts align' do
|
469
468
|
expect {
|
470
|
-
subject.
|
469
|
+
allow(subject).to receive(:puts)
|
471
470
|
subject.footer(:align => 'right')
|
472
|
-
}.to_not raise_error
|
471
|
+
}.to_not raise_error
|
473
472
|
end
|
474
473
|
|
475
474
|
it 'does not accept invalid align' do
|
@@ -480,7 +479,7 @@ describe CommandLineReporter do
|
|
480
479
|
|
481
480
|
it 'accepts width' do
|
482
481
|
expect {
|
483
|
-
subject.
|
482
|
+
allow(subject).to receive(:puts)
|
484
483
|
subject.footer(:width => 50)
|
485
484
|
}.to_not raise_error
|
486
485
|
end
|
@@ -499,7 +498,7 @@ describe CommandLineReporter do
|
|
499
498
|
|
500
499
|
it 'accepts spacing' do
|
501
500
|
expect {
|
502
|
-
subject.
|
501
|
+
allow(subject).to receive(:puts)
|
503
502
|
subject.footer(:spacing => 3)
|
504
503
|
}.to_not raise_error
|
505
504
|
end
|
@@ -511,114 +510,114 @@ describe CommandLineReporter do
|
|
511
510
|
end
|
512
511
|
|
513
512
|
it 'left aligns the title by default' do
|
514
|
-
subject.
|
515
|
-
subject.
|
513
|
+
expect(subject).to receive(:puts).with("\n")
|
514
|
+
expect(subject).to receive(:puts).with(@title)
|
516
515
|
subject.footer(:title => @title)
|
517
516
|
end
|
518
517
|
|
519
518
|
it 'left aligns the title' do
|
520
|
-
subject.
|
521
|
-
subject.
|
519
|
+
expect(subject).to receive(:puts).with("\n")
|
520
|
+
expect(subject).to receive(:puts).with(@title)
|
522
521
|
subject.footer(:title => @title, :align => 'left')
|
523
522
|
end
|
524
523
|
|
525
524
|
it 'right aligns the title' do
|
526
|
-
subject.
|
527
|
-
subject.
|
525
|
+
expect(subject).to receive(:puts).with("\n")
|
526
|
+
expect(subject).to receive(:puts).with(' ' * 90 + @title)
|
528
527
|
subject.footer(:title => @title, :align => 'right')
|
529
528
|
end
|
530
529
|
|
531
530
|
it 'right aligns the title using width' do
|
532
|
-
subject.
|
533
|
-
subject.
|
531
|
+
expect(subject).to receive(:puts).with("\n")
|
532
|
+
expect(subject).to receive(:puts).with(' ' * 40 + @title)
|
534
533
|
subject.footer(:title => @title, :align => 'right', :width => 50)
|
535
534
|
end
|
536
535
|
|
537
536
|
it 'center aligns the title' do
|
538
|
-
subject.
|
539
|
-
subject.
|
537
|
+
expect(subject).to receive(:puts).with("\n")
|
538
|
+
expect(subject).to receive(:puts).with(' ' * 45 + @title)
|
540
539
|
subject.footer(:title => @title, :align => 'center')
|
541
540
|
end
|
542
541
|
|
543
542
|
it 'center aligns the title using width' do
|
544
|
-
subject.
|
545
|
-
subject.
|
543
|
+
expect(subject).to receive(:puts).with("\n")
|
544
|
+
expect(subject).to receive(:puts).with(' ' * 35 + @title)
|
546
545
|
subject.footer(:title => @title, :align => 'center', :width => 80)
|
547
546
|
end
|
548
547
|
end
|
549
548
|
|
550
549
|
context 'spacing' do
|
551
550
|
it 'defaults to a single line of spacing between report' do
|
552
|
-
subject.
|
553
|
-
subject.
|
551
|
+
expect(subject).to receive(:puts).with("\n")
|
552
|
+
expect(subject).to receive(:puts).with('title')
|
554
553
|
subject.footer(:title => 'title')
|
555
554
|
end
|
556
555
|
|
557
556
|
it 'uses the defined spacing between report' do
|
558
|
-
subject.
|
559
|
-
subject.
|
557
|
+
expect(subject).to receive(:puts).with("\n" * 3)
|
558
|
+
expect(subject).to receive(:puts).with('title')
|
560
559
|
subject.footer(:title => 'title', :spacing => 3)
|
561
560
|
end
|
562
561
|
end
|
563
562
|
|
564
563
|
context 'timestamp subheading' do
|
565
564
|
it 'is added with default alignment' do
|
566
|
-
subject.
|
567
|
-
subject.
|
568
|
-
subject.
|
565
|
+
expect(subject).to receive(:puts).with("\n")
|
566
|
+
expect(subject).to receive(:puts).with('title')
|
567
|
+
expect(subject).to receive(:puts).with(/^#{timestamp_regex}/)
|
569
568
|
subject.footer(:title => 'title', :timestamp => true)
|
570
569
|
end
|
571
570
|
|
572
571
|
it 'added with right alignment' do
|
573
|
-
subject.
|
574
|
-
subject.
|
575
|
-
subject.
|
572
|
+
expect(subject).to receive(:puts).with("\n")
|
573
|
+
expect(subject).to receive(:puts).with(/^ *title$/)
|
574
|
+
expect(subject).to receive(:puts).with(/^ *#{timestamp_regex}$/)
|
576
575
|
subject.footer(:title => 'title', :align => 'right', :timestamp => true, :width => 80)
|
577
576
|
end
|
578
577
|
|
579
578
|
it 'added with center alignment' do
|
580
|
-
subject.
|
581
|
-
subject.
|
582
|
-
subject.
|
579
|
+
expect(subject).to receive(:puts).with("\n")
|
580
|
+
expect(subject).to receive(:puts).with(/^ *title *$/)
|
581
|
+
expect(subject).to receive(:puts).with(/^ *#{timestamp_regex} *$/)
|
583
582
|
subject.footer(:title => 'title', :align => 'center', :timestamp => true, :width => 80)
|
584
583
|
end
|
585
584
|
end
|
586
585
|
|
587
586
|
context 'horizontal rule' do
|
588
587
|
it 'uses dashes by default' do
|
589
|
-
subject.
|
590
|
-
subject.
|
591
|
-
subject.
|
588
|
+
expect(subject).to receive(:puts)
|
589
|
+
expect(subject).to receive(:puts).with(linechar * 100)
|
590
|
+
expect(subject).to receive(:puts)
|
592
591
|
subject.footer(:rule => true)
|
593
592
|
end
|
594
593
|
|
595
594
|
it 'uses = as the rule character' do
|
596
|
-
subject.
|
597
|
-
subject.
|
598
|
-
subject.
|
595
|
+
expect(subject).to receive(:puts)
|
596
|
+
expect(subject).to receive(:puts).with('=' * 100)
|
597
|
+
expect(subject).to receive(:puts)
|
599
598
|
subject.footer(:rule => '=')
|
600
599
|
end
|
601
600
|
end
|
602
601
|
|
603
602
|
it 'outputs red' do
|
604
|
-
subject.
|
605
|
-
subject.
|
606
|
-
subject.
|
603
|
+
expect(subject).to receive(:puts).with("\n")
|
604
|
+
expect(subject).to receive(:puts).with(controls[:red] + 'title' + controls[:clear])
|
605
|
+
expect(subject).to receive(:puts).with(/^\e\[31m#{timestamp_regex}\e\[0m/)
|
607
606
|
subject.footer(:title => 'title', :timestamp => true, :color => 'red')
|
608
607
|
end
|
609
608
|
|
610
609
|
it 'outputs bold' do
|
611
|
-
subject.
|
612
|
-
subject.
|
613
|
-
subject.
|
610
|
+
expect(subject).to receive(:puts).with("\n")
|
611
|
+
expect(subject).to receive(:puts).with(controls[:bold] + 'title' + controls[:clear])
|
612
|
+
expect(subject).to receive(:puts).with(/^\e\[1m#{timestamp_regex}\e\[0m/)
|
614
613
|
subject.footer(:title => 'title', :timestamp => true, :bold => true)
|
615
614
|
end
|
616
615
|
end
|
617
616
|
|
618
617
|
describe '#table' do
|
619
618
|
it 'instantiates the table class' do
|
620
|
-
subject.
|
621
|
-
subject.
|
619
|
+
allow(subject).to receive(:puts)
|
620
|
+
expect(subject).to receive(:table).once
|
622
621
|
subject.table { }
|
623
622
|
end
|
624
623
|
|
@@ -636,7 +635,7 @@ describe CommandLineReporter do
|
|
636
635
|
|
637
636
|
it 'rejects invalid options' do
|
638
637
|
expect {
|
639
|
-
subject.
|
638
|
+
allow(subject).to receive(:puts)
|
640
639
|
subject.table(:asdf => '100') { }
|
641
640
|
}.to raise_error ArgumentError
|
642
641
|
end
|
@@ -644,8 +643,8 @@ describe CommandLineReporter do
|
|
644
643
|
|
645
644
|
describe '#row' do
|
646
645
|
it 'instantiates a row class' do
|
647
|
-
subject.
|
648
|
-
subject.
|
646
|
+
expect(subject).to receive(:row).once
|
647
|
+
allow(subject).to receive(:puts)
|
649
648
|
|
650
649
|
subject.table do
|
651
650
|
subject.row do
|
@@ -656,8 +655,8 @@ describe CommandLineReporter do
|
|
656
655
|
|
657
656
|
describe '#column' do
|
658
657
|
it 'instantiates multiple columns' do
|
659
|
-
subject.
|
660
|
-
subject.
|
658
|
+
expect(subject).to receive(:column).exactly(3).times
|
659
|
+
allow(subject).to receive(:puts)
|
661
660
|
|
662
661
|
subject.table do
|
663
662
|
subject.row do
|
@@ -669,8 +668,8 @@ describe CommandLineReporter do
|
|
669
668
|
end
|
670
669
|
|
671
670
|
it 'accepts valid options' do
|
672
|
-
subject.
|
673
|
-
subject.
|
671
|
+
expect(subject).to receive(:column).once
|
672
|
+
allow(subject).to receive(:puts)
|
674
673
|
|
675
674
|
subject.table do
|
676
675
|
subject.row do
|
@@ -680,7 +679,7 @@ describe CommandLineReporter do
|
|
680
679
|
end
|
681
680
|
|
682
681
|
it 'rejects invalid options' do
|
683
|
-
subject.
|
682
|
+
allow(subject).to receive(:puts)
|
684
683
|
expect {
|
685
684
|
subject.table do
|
686
685
|
subject.row do
|
@@ -690,4 +689,5 @@ describe CommandLineReporter do
|
|
690
689
|
}.to raise_error ArgumentError
|
691
690
|
end
|
692
691
|
end
|
692
|
+
|
693
693
|
end
|