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
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe CommandLineReporter::NestedFormatter do
|
|
4
|
-
subject { CommandLineReporter::NestedFormatter.instance }
|
|
5
|
-
|
|
6
|
-
let(:controls) do
|
|
7
|
-
{
|
|
8
|
-
clear: "\e[0m",
|
|
9
|
-
bold: "\e[1m",
|
|
10
|
-
red: "\e[31m"
|
|
11
|
-
}
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe '#method default values' do
|
|
15
|
-
describe '#message_string' do
|
|
16
|
-
subject { super().message_string }
|
|
17
|
-
it { should == 'working' }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe '#complete_string' do
|
|
21
|
-
subject { super().complete_string }
|
|
22
|
-
it { should == 'complete' }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe '#indent_size' do
|
|
26
|
-
subject { super().indent_size }
|
|
27
|
-
it { should eq 2 }
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe '#format' do
|
|
32
|
-
context 'argument validation' do
|
|
33
|
-
before :each do
|
|
34
|
-
@indent_size = subject.indent_size
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Restore the singleton to its original state to ensure clean tests
|
|
38
|
-
after :each do
|
|
39
|
-
subject.indent_size = @indent_size
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'raises exception when there is an invalid argument' do
|
|
43
|
-
expect do
|
|
44
|
-
subject.format({ asdf: true }, -> {})
|
|
45
|
-
end.to raise_exception ArgumentError
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it 'raises an exception when a block is not given' do
|
|
49
|
-
expect do
|
|
50
|
-
subject.format(message: 'test')
|
|
51
|
-
end.to raise_exception Exception
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it 'accepts valid arguments' do
|
|
55
|
-
expect(subject).to receive(:puts).with('test')
|
|
56
|
-
expect(subject).to receive(:puts).with('complete')
|
|
57
|
-
|
|
58
|
-
expect do
|
|
59
|
-
subject.format({ message: 'test' }, -> {}) do
|
|
60
|
-
end
|
|
61
|
-
end.not_to raise_exception
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
context 'not nested' do
|
|
66
|
-
before :each do
|
|
67
|
-
@complete_string = subject.complete_string
|
|
68
|
-
@indent_size = subject.indent_size
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# Restore the singleton to its original state to ensure clean tests
|
|
72
|
-
after :each do
|
|
73
|
-
subject.complete_string = @complete_string
|
|
74
|
-
subject.indent_size = @indent_size
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it 'performs a wrapped report' do
|
|
78
|
-
expect(subject).to receive(:puts).with('working')
|
|
79
|
-
expect(subject).to receive(:puts).with('complete')
|
|
80
|
-
|
|
81
|
-
subject.format({}, -> {})
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it 'performs a wrapped report with color' do
|
|
85
|
-
expect(subject).to receive(:puts).with("#{controls[:red]}working#{controls[:clear]}")
|
|
86
|
-
expect(subject).to receive(:puts).with("#{controls[:red]}complete#{controls[:clear]}")
|
|
87
|
-
|
|
88
|
-
subject.format({ color: 'red' }, -> {})
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it 'performs a wrapped report with color' do
|
|
92
|
-
expect(subject).to receive(:puts).with("#{controls[:bold]}working#{controls[:clear]}")
|
|
93
|
-
expect(subject).to receive(:puts).with("#{controls[:bold]}complete#{controls[:clear]}")
|
|
94
|
-
|
|
95
|
-
subject.format({ bold: true }, -> {})
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it 'performs a wrapped report overriding the message' do
|
|
99
|
-
expect(subject).to receive(:puts).with('test')
|
|
100
|
-
expect(subject).to receive(:puts).with('complete')
|
|
101
|
-
|
|
102
|
-
subject.format({ message: 'test' }, -> {})
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it 'performs an inline report' do
|
|
106
|
-
expect(subject).to receive(:print).with('test...')
|
|
107
|
-
expect(subject).to receive(:puts).with('complete')
|
|
108
|
-
expect(subject).to receive(:print).with('test2...')
|
|
109
|
-
expect(subject).to receive(:puts).with('complete')
|
|
110
|
-
|
|
111
|
-
subject.format({ message: 'test', type: 'inline' }, -> {})
|
|
112
|
-
subject.format({ message: 'test2', type: 'inline' }, -> {})
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
it 'overrides the default for all invocations of a wrapped report' do
|
|
116
|
-
subject.complete_string = 'done'
|
|
117
|
-
expect(subject).to receive(:puts).with('test')
|
|
118
|
-
expect(subject).to receive(:puts).with('done')
|
|
119
|
-
expect(subject).to receive(:puts).with('test2')
|
|
120
|
-
expect(subject).to receive(:puts).with('done')
|
|
121
|
-
|
|
122
|
-
subject.format({ message: 'test' }, -> {})
|
|
123
|
-
subject.format({ message: 'test2' }, -> {})
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it 'overrides the default complete string for a wrapped report' do
|
|
127
|
-
expect(subject).to receive(:puts).with('test')
|
|
128
|
-
expect(subject).to receive(:puts).with('done')
|
|
129
|
-
expect(subject).to receive(:puts).with('test2')
|
|
130
|
-
expect(subject).to receive(:puts).with('finally')
|
|
131
|
-
|
|
132
|
-
subject.format({ message: 'test', complete: 'done' }, -> {})
|
|
133
|
-
subject.format({ message: 'test2', complete: 'finally' }, -> {})
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
it 'overrides the default complete string for an inline report' do
|
|
137
|
-
expect(subject).to receive(:print).with('test...')
|
|
138
|
-
expect(subject).to receive(:puts).with('done')
|
|
139
|
-
expect(subject).to receive(:print).with('test2...')
|
|
140
|
-
expect(subject).to receive(:puts).with('finally')
|
|
141
|
-
|
|
142
|
-
subject.format({ message: 'test', type: 'inline', complete: 'done' }, -> {})
|
|
143
|
-
subject.format({ message: 'test2', type: 'inline', complete: 'finally' }, -> {})
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it 'performs another wrapped report to ensure defaul behavior' do
|
|
147
|
-
expect(subject).to receive(:puts).with('test')
|
|
148
|
-
expect(subject).to receive(:puts).with('complete')
|
|
149
|
-
expect(subject).to receive(:puts).with('test2')
|
|
150
|
-
expect(subject).to receive(:puts).with('complete')
|
|
151
|
-
|
|
152
|
-
subject.format({ message: 'test' }, -> {})
|
|
153
|
-
subject.format({ message: 'test2' }, -> {})
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
context 'nested commands' do
|
|
158
|
-
before :each do
|
|
159
|
-
@indent_size = subject.indent_size
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
# Restore the singleton to its original state to ensure clean tests
|
|
163
|
-
after :each do
|
|
164
|
-
subject.indent_size = @indent_size
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
it 'indents the nested wrapped messages' do
|
|
168
|
-
expect(subject).to receive(:puts).with('test')
|
|
169
|
-
expect(subject).to receive(:puts).with(' test2')
|
|
170
|
-
expect(subject).to receive(:puts).with(' complete')
|
|
171
|
-
expect(subject).to receive(:puts).with('complete')
|
|
172
|
-
|
|
173
|
-
subject.format({ message: 'test' }, lambda do
|
|
174
|
-
subject.format({ message: 'test2' }, -> {})
|
|
175
|
-
end)
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
it 'indents the nested wrapped messages and outputs color' do
|
|
179
|
-
expect(subject).to receive(:puts).with("#{controls[:red]}test#{controls[:clear]}")
|
|
180
|
-
expect(subject).to receive(:puts).with("#{controls[:red]} test2#{controls[:clear]}")
|
|
181
|
-
expect(subject).to receive(:puts).with("#{controls[:red]} complete#{controls[:clear]}")
|
|
182
|
-
expect(subject).to receive(:puts).with("#{controls[:red]}complete#{controls[:clear]}")
|
|
183
|
-
|
|
184
|
-
subject.format({ message: 'test', color: 'red' }, lambda do
|
|
185
|
-
subject.format({ message: 'test2', color: 'red' }, -> {})
|
|
186
|
-
end)
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
it 'indents the nested wrapped messages and outputs bold' do
|
|
190
|
-
expect(subject).to receive(:puts).with("#{controls[:bold]}test#{controls[:clear]}")
|
|
191
|
-
expect(subject).to receive(:puts).with("#{controls[:bold]} test2#{controls[:clear]}")
|
|
192
|
-
expect(subject).to receive(:puts).with("#{controls[:bold]} complete#{controls[:clear]}")
|
|
193
|
-
expect(subject).to receive(:puts).with("#{controls[:bold]}complete#{controls[:clear]}")
|
|
194
|
-
|
|
195
|
-
subject.format({ message: 'test', bold: true }, lambda do
|
|
196
|
-
subject.format({ message: 'test2', bold: true }, -> {})
|
|
197
|
-
end)
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
it 'indents the multiple nested wrapped messages' do
|
|
201
|
-
expect(subject).to receive(:puts).with('test')
|
|
202
|
-
expect(subject).to receive(:puts).with(' test2')
|
|
203
|
-
expect(subject).to receive(:puts).with(' test3')
|
|
204
|
-
expect(subject).to receive(:puts).with(' complete')
|
|
205
|
-
expect(subject).to receive(:puts).with(' complete')
|
|
206
|
-
expect(subject).to receive(:puts).with('complete')
|
|
207
|
-
|
|
208
|
-
subject.format({ message: 'test' }, lambda do
|
|
209
|
-
subject.format({ message: 'test2' }, lambda do
|
|
210
|
-
subject.format({ message: 'test3' }, -> {})
|
|
211
|
-
end)
|
|
212
|
-
end)
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
it 'indents the nested wrapped and inline messages' do
|
|
216
|
-
expect(subject).to receive(:puts).with('test')
|
|
217
|
-
expect(subject).to receive(:print).with(' test2...')
|
|
218
|
-
expect(subject).to receive(:puts).with('complete')
|
|
219
|
-
expect(subject).to receive(:puts).with('complete')
|
|
220
|
-
|
|
221
|
-
subject.format({ message: 'test' }, lambda do
|
|
222
|
-
subject.format({ message: 'test2', type: 'inline' }, -> {})
|
|
223
|
-
end)
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
it 'indents the multiple nested wrapped messages' do
|
|
227
|
-
expect(subject).to receive(:puts).with('test')
|
|
228
|
-
expect(subject).to receive(:puts).with(' test2')
|
|
229
|
-
expect(subject).to receive(:print).with(' test3...')
|
|
230
|
-
expect(subject).to receive(:puts).with('complete')
|
|
231
|
-
expect(subject).to receive(:puts).with(' complete')
|
|
232
|
-
expect(subject).to receive(:puts).with('complete')
|
|
233
|
-
|
|
234
|
-
subject.format({ message: 'test' }, lambda do
|
|
235
|
-
subject.format({ message: 'test2' }, lambda do
|
|
236
|
-
subject.format({ message: 'test3', type: 'inline' }, -> {})
|
|
237
|
-
end)
|
|
238
|
-
end)
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
it 'overrides the indent spacing of all messages' do
|
|
242
|
-
expect(subject).to receive(:puts).with('test')
|
|
243
|
-
expect(subject).to receive(:puts).with(' test2')
|
|
244
|
-
expect(subject).to receive(:print).with(' test3...')
|
|
245
|
-
expect(subject).to receive(:puts).with('complete')
|
|
246
|
-
expect(subject).to receive(:puts).with(' complete')
|
|
247
|
-
expect(subject).to receive(:puts).with('complete')
|
|
248
|
-
|
|
249
|
-
subject.indent_size = 4
|
|
250
|
-
|
|
251
|
-
subject.format({ message: 'test' }, lambda do
|
|
252
|
-
subject.format({ message: 'test2' }, lambda do
|
|
253
|
-
subject.format({ message: 'test3', type: 'inline' }, -> {})
|
|
254
|
-
end)
|
|
255
|
-
end)
|
|
256
|
-
end
|
|
257
|
-
|
|
258
|
-
it 'overrides the indent spacing of specific message' do
|
|
259
|
-
expect(subject).to receive(:puts).with('test')
|
|
260
|
-
expect(subject).to receive(:puts).with(' test2')
|
|
261
|
-
expect(subject).to receive(:print).with(' test3...')
|
|
262
|
-
expect(subject).to receive(:puts).with('complete')
|
|
263
|
-
expect(subject).to receive(:puts).with(' complete')
|
|
264
|
-
expect(subject).to receive(:puts).with('complete')
|
|
265
|
-
|
|
266
|
-
subject.indent_size = 4
|
|
267
|
-
|
|
268
|
-
subject.format({ message: 'test' }, lambda do
|
|
269
|
-
subject.format({ message: 'test2', indent_size: 6 }, lambda do
|
|
270
|
-
subject.format({ message: 'test3', type: 'inline', indent_size: 3 }, -> {})
|
|
271
|
-
end)
|
|
272
|
-
end)
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
it 'performs the sums specified in the block' do
|
|
276
|
-
x, y, z = 0, 0, 0
|
|
277
|
-
|
|
278
|
-
expect(subject).to receive(:puts).with('sum x and 10')
|
|
279
|
-
expect(subject).to receive(:puts).with(' y is the difference of 20 and x')
|
|
280
|
-
expect(subject).to receive(:puts).with(' z = x + y')
|
|
281
|
-
expect(subject).to receive(:puts).with(' complete')
|
|
282
|
-
expect(subject).to receive(:puts).with(' complete')
|
|
283
|
-
expect(subject).to receive(:puts).with('complete')
|
|
284
|
-
|
|
285
|
-
subject.format({ message: 'sum x and 10' }, lambda do
|
|
286
|
-
x += 10
|
|
287
|
-
subject.format({ message: 'y is the difference of 20 and x' }, lambda do
|
|
288
|
-
y = 20 - x
|
|
289
|
-
subject.format({ message: 'z = x + y' }, lambda do
|
|
290
|
-
z = x + y
|
|
291
|
-
end)
|
|
292
|
-
end)
|
|
293
|
-
end)
|
|
294
|
-
|
|
295
|
-
expect(x).to eq(10)
|
|
296
|
-
expect(y).to eq(10)
|
|
297
|
-
expect(z).to eq(20)
|
|
298
|
-
end
|
|
299
|
-
end
|
|
300
|
-
end
|
|
301
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe OptionsValidator do
|
|
4
|
-
subject { Class.new.extend(OptionsValidator) }
|
|
5
|
-
|
|
6
|
-
it 'accepts single key options' do
|
|
7
|
-
expect do
|
|
8
|
-
subject.validate_options({ valid: true }, :valid)
|
|
9
|
-
end.to_not raise_error Exception
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'rejects invalid option hashes' do
|
|
13
|
-
expect do
|
|
14
|
-
subject.validate_options({ wrong: true }, :valid)
|
|
15
|
-
end.to raise_error ArgumentError
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'accepts multi-key options' do
|
|
19
|
-
expect do
|
|
20
|
-
valid = %i[valid another]
|
|
21
|
-
subject.validate_options({ valid: true, another: true }, *valid)
|
|
22
|
-
end.to_not raise_error Exception
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe CommandLineReporter::ProgressFormatter do
|
|
4
|
-
subject { CommandLineReporter::ProgressFormatter.instance }
|
|
5
|
-
|
|
6
|
-
describe '#method default values' do
|
|
7
|
-
describe '#indicator' do
|
|
8
|
-
subject { super().indicator }
|
|
9
|
-
it { should == '.' }
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
let :controls do
|
|
14
|
-
{
|
|
15
|
-
clear: "\e[0m",
|
|
16
|
-
bold: "\e[1m",
|
|
17
|
-
red: "\e[31m"
|
|
18
|
-
}
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
describe '#format' do
|
|
22
|
-
it 'displays dots for the indicator' do
|
|
23
|
-
expect(subject).to receive(:print).exactly(10).times.with('.')
|
|
24
|
-
expect(subject).to receive(:puts).exactly(1).times
|
|
25
|
-
|
|
26
|
-
subject.format({}, -> { 10.times { subject.progress } })
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it 'displays colored red dots for the indicator' do
|
|
30
|
-
expect(subject).to receive(:print).exactly(10).times.with("#{controls[:red]}.#{controls[:clear]}")
|
|
31
|
-
expect(subject).to receive(:puts).exactly(1).times
|
|
32
|
-
|
|
33
|
-
subject.format({ color: 'red' }, -> { 10.times { subject.progress } })
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'displays BOLD dots for the indicator' do
|
|
37
|
-
expect(subject).to receive(:print).exactly(10).times.with("#{controls[:bold]}.#{controls[:clear]}")
|
|
38
|
-
expect(subject).to receive(:puts).exactly(1).times
|
|
39
|
-
|
|
40
|
-
subject.format({ bold: true }, -> { 10.times { subject.progress } })
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'uses the defined indicator' do
|
|
44
|
-
subject.indicator = '+'
|
|
45
|
-
expect(subject).to receive(:print).exactly(10).times.with('+')
|
|
46
|
-
expect(subject).to receive(:puts)
|
|
47
|
-
|
|
48
|
-
subject.format({}, -> { 10.times { subject.progress } })
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it 'allows override of the indicator' do
|
|
52
|
-
expect(subject).to receive(:print).exactly(10).times.with('=')
|
|
53
|
-
expect(subject).to receive(:puts)
|
|
54
|
-
|
|
55
|
-
subject.format({ indicator: '=' }, -> { 10.times { subject.progress } })
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
describe '#progress' do
|
|
60
|
-
it 'allows override of the indicator' do
|
|
61
|
-
expect(subject).to receive(:print).exactly(10).times.with('+')
|
|
62
|
-
expect(subject).to receive(:puts)
|
|
63
|
-
|
|
64
|
-
subject.format({}, -> { 10.times { subject.progress('+') } })
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it 'allows any indicator' do
|
|
68
|
-
expect(subject).to receive(:print).exactly(10).times
|
|
69
|
-
expect(subject).to receive(:puts)
|
|
70
|
-
|
|
71
|
-
subject.format({}, -> { 10.times { |i| subject.progress("#{i}") } })
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
data/spec/row_spec.rb
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe CommandLineReporter::Row do
|
|
4
|
-
let(:cols) { Array.new(10) { |v| CommandLineReporter::Column.new("test#{v}") } }
|
|
5
|
-
|
|
6
|
-
describe '#initialize' do
|
|
7
|
-
subject { CommandLineReporter::Row }
|
|
8
|
-
|
|
9
|
-
it 'accepts header' do
|
|
10
|
-
expect(subject.new(header: true).header).to be true
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'accepts color' do
|
|
14
|
-
expect(subject.new(color: 'red').color).to eq('red')
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'accepts bold' do
|
|
18
|
-
expect(subject.new(bold: true).bold).to be true
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'output encoding should be ascii' do
|
|
22
|
-
expect(subject.new(encoding: :ascii).encoding).to eq(:ascii)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'output encoding should be unicode' do
|
|
26
|
-
expect(subject.new.encoding).to eq(:unicode)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
describe '#add' do
|
|
31
|
-
subject { CommandLineReporter::Row }
|
|
32
|
-
|
|
33
|
-
it 'columns' do
|
|
34
|
-
row = CommandLineReporter::Row.new
|
|
35
|
-
row.add(cols[0])
|
|
36
|
-
expect(row.columns.size).to eq(1)
|
|
37
|
-
expect(row.columns[0]).to eq(cols[0])
|
|
38
|
-
row.add(cols[1])
|
|
39
|
-
expect(row.columns).to eq(cols[0, 2])
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'defaults colors on columns' do
|
|
43
|
-
row = subject.new(color: 'red')
|
|
44
|
-
row.add(cols[0])
|
|
45
|
-
expect(row.columns[0].color).to eq('red')
|
|
46
|
-
row.add(cols[1])
|
|
47
|
-
expect(row.columns[1].color).to eq('red')
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'allows columns to override the row color' do
|
|
51
|
-
col = CommandLineReporter::Column.new('test', color: 'blue')
|
|
52
|
-
row = subject.new(color: 'red')
|
|
53
|
-
row.add(col)
|
|
54
|
-
expect(row.columns[0].color).to eq('blue')
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it 'supercedes bold on columns' do
|
|
58
|
-
row = subject.new(bold: true)
|
|
59
|
-
row.add(cols[0])
|
|
60
|
-
expect(row.columns[0].bold).to be true
|
|
61
|
-
row.add(cols[1])
|
|
62
|
-
expect(row.columns[1].bold).to be true
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
describe '#output' do
|
|
67
|
-
let :cols do
|
|
68
|
-
[
|
|
69
|
-
CommandLineReporter::Column.new('asdf'),
|
|
70
|
-
CommandLineReporter::Column.new('qwer', align: 'center'),
|
|
71
|
-
CommandLineReporter::Column.new('zxcv', align: 'right'),
|
|
72
|
-
CommandLineReporter::Column.new('x' * 25, align: 'left', width: 10),
|
|
73
|
-
CommandLineReporter::Column.new('x' * 25, align: 'center', width: 10),
|
|
74
|
-
CommandLineReporter::Column.new('x' * 35, align: 'left', width: 10)
|
|
75
|
-
]
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
let(:one_space) { ' ' }
|
|
79
|
-
let(:three_spaces) { ' {3,3}' }
|
|
80
|
-
let(:six_spaces) { ' {6,6}' }
|
|
81
|
-
let(:nine_spaces) { ' {9,9}' }
|
|
82
|
-
let(:five_xs) { 'x{5,5}' }
|
|
83
|
-
let(:ten_xs) { 'x{10,10}' }
|
|
84
|
-
|
|
85
|
-
context 'no border' do
|
|
86
|
-
context 'no wrap' do
|
|
87
|
-
it 'outputs a single column' do
|
|
88
|
-
subject.add(cols[0])
|
|
89
|
-
expect(subject).to receive(:puts).with(/^asdf#{@six_pieces}/)
|
|
90
|
-
subject.output
|
|
91
|
-
end
|
|
92
|
-
it 'outputs three columns' do
|
|
93
|
-
subject.add(cols[0])
|
|
94
|
-
subject.add(cols[1])
|
|
95
|
-
subject.add(cols[2])
|
|
96
|
-
expect(subject).to receive(:puts).with(/^asdf#{six_spaces}#{one_space}#{three_spaces}qwer#{three_spaces}#{one_space}#{six_spaces}zxcv $/)
|
|
97
|
-
subject.output
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
context 'with wrapping' do
|
|
102
|
-
it 'outputs a single column' do
|
|
103
|
-
subject.add(cols[3])
|
|
104
|
-
expect(subject).to receive(:puts).with(/^#{ten_xs}#{one_space}$/)
|
|
105
|
-
expect(subject).to receive(:puts).with(/^#{ten_xs}#{one_space}$/)
|
|
106
|
-
expect(subject).to receive(:puts).with(/^#{five_xs}#{six_spaces}$/)
|
|
107
|
-
subject.output
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it 'outputs multiple columns of the same size' do
|
|
111
|
-
subject.add(cols[3])
|
|
112
|
-
subject.add(cols[4])
|
|
113
|
-
expect(subject).to receive(:puts).with(/^#{ten_xs}#{one_space}#{ten_xs}#{one_space}$/)
|
|
114
|
-
expect(subject).to receive(:puts).with(/^#{ten_xs}#{one_space}#{ten_xs}#{one_space}$/)
|
|
115
|
-
expect(subject).to receive(:puts).with(/^#{five_xs}#{nine_spaces}#{five_xs}#{three_spaces}$/)
|
|
116
|
-
subject.output
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it 'outputs multiple columns with different sizes' do
|
|
120
|
-
subject.add(cols[5])
|
|
121
|
-
subject.add(cols[3])
|
|
122
|
-
expect(subject).to receive(:puts).with(/^#{ten_xs}#{one_space}#{ten_xs}#{one_space}$/)
|
|
123
|
-
expect(subject).to receive(:puts).with(/^#{ten_xs}#{one_space}#{ten_xs}#{one_space}$/)
|
|
124
|
-
expect(subject).to receive(:puts).with(/^#{ten_xs}#{one_space}#{five_xs}#{six_spaces}$/)
|
|
125
|
-
expect(subject).to receive(:puts).with(/^#{five_xs} {5,17}$/)
|
|
126
|
-
subject.output
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
end
|
data/spec/spec_helper.rb
DELETED