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/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.should == 10
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.should == 50
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.should == 'asdf'
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.should == 'red'
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.should be_true
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.should == 0
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.should == 5
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
- before :all do
61
- @controls = {
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].should == ' ' * 10
92
+ expect(c.screen_rows[0]).to eq(' ' * 10)
78
93
  end
79
94
 
80
95
  context 'left justifies' do
81
- before :each do
82
- @text = 'x' * 10
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(@text, :width => 20)
88
- c.screen_rows[0].should == @text + @filler
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(@text, :align => 'left', :width => 20, :color => 'red')
93
- c.screen_rows[0].should == @controls[:red] + @text + @filler + @controls[:clear]
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(@text, :align => 'left', :width => 20, :bold => true)
98
- c.screen_rows[0].should == @controls[:bold] + @text + @filler + @controls[:clear]
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
- before :each do
104
- @text = 'x' * 10
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(@text, :align => 'right', :width => 20)
110
- c.screen_rows[0].should == @filler + @text
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(@text, :align => 'right', :width => 20, :color => 'red')
115
- c.screen_rows[0].should == @controls[:red] + @filler + @text + @controls[:clear]
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(@text, :align => 'right', :width => 20, :bold => true)
120
- c.screen_rows[0].should == @controls[:bold] + @filler + @text + @controls[:clear]
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
- before :each do
126
- @text = 'x' * 10
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(@text, :align => 'center', :width => 20)
132
- c.screen_rows[0].should == @filler + @text + @filler
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(@text, :align => 'center', :width => 20, :color => 'red')
137
- c.screen_rows[0].should == @controls[:red] + @filler + @text + @filler + @controls[:clear]
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(@text, :align => 'center', :width => 20, :bold => true)
142
- c.screen_rows[0].should == @controls[:bold] + @filler + @text + @filler + @controls[:clear]
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
- before :each do
150
- @text = 'x' * 10
151
- @padding = ' ' * 5
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(@text, :padding => 5, :width => 30)
157
- c.screen_rows[0].should == @padding + @text + @filler + @padding
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(@text, :padding => 5, :width => 30, :color => 'red')
162
- c.screen_rows[0].should == @padding + @controls[:red] + @text + @filler + @controls[:clear] + @padding
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(@text, :padding => 5, :width => 30, :bold => true)
167
- c.screen_rows[0].should == @padding + @controls[:bold] + @text + @filler + @controls[:clear] + @padding
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
- before :each do
173
- @text = 'x' * 10
174
- @padding = ' ' * 5
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(@text, :align => 'right', :padding => 5, :width => 30)
180
- c.screen_rows[0].should == @padding + @filler + @text + @padding
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(@text, :align => 'right', :padding => 5, :width => 30, :color => 'red')
185
- c.screen_rows[0].should == @padding + @controls[:red] + @filler + @text + @controls[:clear] + @padding
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(@text, :align => 'right', :padding => 5, :width => 30, :bold => true)
190
- c.screen_rows[0].should == @padding + @controls[:bold] + @filler + @text + @controls[:clear] + @padding
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
- before :each do
196
- @text = ' ' * 10
197
- @padding = ' ' * 5
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(@text, :align => 'center', :padding => 5, :width => 30)
203
- c.screen_rows[0].should == @padding + @filler + @text + @filler + @padding
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(@text, :align => 'center', :padding => 5, :width => 30, :color => 'red')
208
- c.screen_rows[0].should == @padding + @controls[:red] + @filler + @text + @filler + @controls[:clear] + @padding
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(@text, :align => 'center', :padding => 5, :width => 30, :bold => true)
213
- c.screen_rows[0].should == @padding + @controls[:bold] + @filler + @text + @filler + @controls[:clear] + @padding
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
- before :each do
223
- @text = 'x' * 25
224
- @full_line = 'x' * 10
225
- @remainder = 'x' * 5
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(@text, :width => 10)
231
- c.screen_rows.should == [@full_line, @full_line, @remainder + @filler]
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(@text, :width => 10, :color => 'red')
236
- c.screen_rows.should == [
237
- @controls[:red] + @full_line + @controls[:clear],
238
- @controls[:red] + @full_line + @controls[:clear],
239
- @controls[:red] + @remainder + @filler + @controls[:clear],
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(@text, :width => 10, :bold => true)
245
- c.screen_rows.should == [
246
- @controls[:bold] + @full_line + @controls[:clear],
247
- @controls[:bold] + @full_line + @controls[:clear],
248
- @controls[:bold] + @remainder + @filler + @controls[:clear],
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
- before :each do
255
- @text = 'x' * 25
256
- @full_line = 'x' * 10
257
- @remainder = 'x' * 5
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(@text, :align => 'right', :width => 10)
263
- c.screen_rows.should == [@full_line, @full_line, @filler + @remainder]
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(@text, :align => 'right', :width => 10, :color => 'red')
268
- c.screen_rows.should == [
269
- @controls[:red] + @full_line + @controls[:clear],
270
- @controls[:red] + @full_line + @controls[:clear],
271
- @controls[:red] + @filler + @remainder + @controls[:clear],
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(@text, :align => 'right', :width => 10, :bold => true)
277
- c.screen_rows.should == [
278
- @controls[:bold] + @full_line + @controls[:clear],
279
- @controls[:bold] + @full_line + @controls[:clear],
280
- @controls[:bold] + @filler + @remainder + @controls[:clear],
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
- before :each do
287
- @text = 'x' * 25
288
- @full_line = 'x' * 10
289
- @remainder = 'x' * 5
290
- @left_filler = ' ' * 3
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(@text, :align => 'center', :width => 10)
296
- c.screen_rows.should == [@full_line, @full_line, ' ' * 3 + @remainder + @right_filler]
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(@text, :align => 'center', :width => 10, :color => 'red')
301
- c.screen_rows.should == [
302
- @controls[:red] + @full_line + @controls[:clear],
303
- @controls[:red] + @full_line + @controls[:clear],
304
- @controls[:red] + @left_filler + @remainder + @right_filler + @controls[:clear],
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(@text, :align => 'center', :width => 10, :bold => true)
310
- c.screen_rows.should == [
311
- @controls[:bold] + @full_line + @controls[:clear],
312
- @controls[:bold] + @full_line + @controls[:clear],
313
- @controls[:bold] + @left_filler + @remainder + @right_filler + @controls[:clear],
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
- before :each do
322
- @text = 'x' * 25
323
- @full_line = 'x' * 16
324
- @remainder = 'x' * 9
325
- @padding = ' ' * 2
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(@text, :padding => 2, :width => 20)
331
- c.screen_rows.should == [
332
- @padding + @full_line + @padding,
333
- @padding + @remainder + @filler + @padding,
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(@text, :padding => 2, :width => 20, :color => 'red')
339
- c.screen_rows.should == [
340
- @padding + @controls[:red] + @full_line + @controls[:clear] + @padding,
341
- @padding + @controls[:red] + @remainder + @filler + @controls[:clear] + @padding,
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(@text, :padding => 2, :width => 20, :bold => true)
347
- c.screen_rows.should == [
348
- @padding + @controls[:bold] + @full_line + @controls[:clear] + @padding,
349
- @padding + @controls[:bold] + @remainder + @filler + @controls[:clear] + @padding,
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
- before :each do
356
- @text = 'x' * 25
357
- @full_line = 'x' * 16
358
- @remainder = 'x' * 9
359
- @padding = ' ' * 2
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(@text, :padding => 2, :align => 'right', :width => 20)
365
- c.screen_rows.should == [
366
- @padding + @full_line + @padding,
367
- @padding + @filler + @remainder + @padding,
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(@text, :align => 'right', :padding => 2, :width => 20, :color => 'red')
373
- c.screen_rows.should == [
374
- @padding + @controls[:red] + @full_line + @controls[:clear] + @padding,
375
- @padding + @controls[:red] + @filler + @remainder + @controls[:clear] + @padding,
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(@text, :align => 'right', :padding => 2, :width => 20, :bold => true)
381
- c.screen_rows.should == [
382
- @padding + @controls[:bold] + @full_line + @controls[:clear] + @padding,
383
- @padding + @controls[:bold] + @filler + @remainder + @controls[:clear] + @padding,
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
- before :each do
390
- @text = 'x' * 25
391
- @full_line = 'x' * 16
392
- @remainder = 'x' * 9
393
- @padding = ' ' * 2
394
- @left_filler = ' ' * 4
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(@text, :padding => 2, :align => 'center', :width => 20)
400
- c.screen_rows.should == [
401
- @padding + @full_line + @padding,
402
- @padding + @left_filler + @remainder + @right_filler + @padding,
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(@text, :padding => 2, :align => 'center', :width => 20, :color => 'red')
408
- c.screen_rows.should == [
409
- @padding + @controls[:red] + @full_line + @controls[:clear] + @padding,
410
- @padding + @controls[:red] + @left_filler + @remainder + @right_filler + @controls[:clear] + @padding,
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(@text, :padding => 2, :align => 'center', :width => 20, :bold => true)
416
- c.screen_rows.should == [
417
- @padding + @controls[:bold] + @full_line + @controls[:clear] + @padding,
418
- @padding + @controls[:bold] + @left_filler + @remainder + @right_filler + @controls[:clear] + @padding,
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