command_line_reporter 3.3.6 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,11 +2,11 @@ module CommandLineReporter
2
2
  class Table
3
3
  include OptionsValidator
4
4
 
5
- VALID_OPTIONS = [:border, :width, :encoding]
5
+ VALID_OPTIONS = %i[border width encoding].freeze
6
6
  attr_accessor :rows, *VALID_OPTIONS
7
7
 
8
8
  def initialize(options = {})
9
- self.validate_options(options, *VALID_OPTIONS)
9
+ validate_options(options, *VALID_OPTIONS)
10
10
 
11
11
  self.border = options[:border] || false
12
12
  self.width = options[:width] || false
@@ -14,41 +14,47 @@ module CommandLineReporter
14
14
 
15
15
  @rows = []
16
16
 
17
- raise ArgumentError, "Invalid encoding" unless [ :ascii, :unicode ].include? self.encoding
17
+ raise ArgumentError, 'Invalid encoding' unless %i[ascii unicode].include? encoding
18
18
  end
19
19
 
20
20
  def add(row)
21
21
  # Inheritance from the table
22
- row.border = self.border
22
+ row.border = border
23
23
 
24
24
  # Inherit properties from the appropriate row
25
- inherit_column_attrs(row) if self.rows[0]
25
+ inherit_column_attrs(row) if rows[0]
26
26
 
27
- self.rows << row
27
+ rows << row
28
28
  end
29
29
 
30
+ # rubocop:disable Metrics/AbcSize
31
+ # rubocop:disable Metrics/CyclomaticComplexity
32
+ # rubocop:disable Metrics/MethodLength
30
33
  def output
31
- return if self.rows.size == 0 # we got here with nothing to print to the screen
32
- auto_adjust_widths if self.width == :auto
34
+ return if rows.empty? # we got here with nothing to print to the screen
35
+ auto_adjust_widths if width == :auto
33
36
 
34
- puts separator('first') if self.border
35
- self.rows.each_with_index do |row, index|
37
+ puts separator('first') if border
38
+
39
+ rows.each_with_index do |row, index|
36
40
  row.output
37
- puts separator('middle') if self.border && (index != self.rows.size - 1)
41
+ puts separator('middle') if border && (index != rows.size - 1)
38
42
  end
39
- puts separator('last') if self.border
43
+
44
+ puts separator('last') if border
40
45
  end
41
46
 
47
+ # TODO: This doesn't appear to be used and if it is, it will not handle span appropriately
42
48
  def auto_adjust_widths
43
49
  column_widths = []
44
50
 
45
- self.rows.each do |row|
51
+ rows.each do |row|
46
52
  row.columns.each_with_index do |col, i|
47
- column_widths[i] = [ col.required_width, ( column_widths[i] || 0 ) ].max
53
+ column_widths[i] = [col.required_width, (column_widths[i] || 0)].max
48
54
  end
49
55
  end
50
56
 
51
- self.rows.each do |row|
57
+ rows.each do |row|
52
58
  row.columns.each_with_index do |col, i|
53
59
  col.width = column_widths[i]
54
60
  end
@@ -60,11 +66,11 @@ module CommandLineReporter
60
66
  def separator(type = 'middle')
61
67
  left, center, right, bar = use_utf8? ? utf8_separator(type) : ascii_separator
62
68
 
63
- left + self.rows[0].columns.map {|c| bar * (c.width + 2)}.join(center) + right
69
+ left + rows[0].columns.map { |c| bar * (c.width + 2) }.join(center) + right
64
70
  end
65
71
 
66
72
  def use_utf8?
67
- self.encoding == :unicode && "\u2501" != "u2501"
73
+ encoding == :unicode && "\u2501" != 'u2501'
68
74
  end
69
75
 
70
76
  def ascii_separator
@@ -89,7 +95,7 @@ module CommandLineReporter
89
95
  end
90
96
 
91
97
  def inherit_column_attrs(row)
92
- row.columns.each_with_index do |c,i|
98
+ row.columns.each_with_index do |c, i|
93
99
  use_positional_attrs(c, i)
94
100
  use_color(row, c, i)
95
101
  use_bold(row, c, i)
@@ -97,16 +103,22 @@ module CommandLineReporter
97
103
  end
98
104
 
99
105
  def use_positional_attrs(c, i)
100
- # The positional attributes are always required to inheret to make sure the table
106
+ return if c.span > 1
107
+
108
+ # The positional attributes are always required to inherit to make sure the table
101
109
  # displays properly
102
- %w{align padding width}.each do |attr|
103
- val = self.rows[0].columns[i].send(attr)
104
- c.send(attr + "=", val)
110
+ %w[align padding width].each do |attr|
111
+ val = rows[0].columns[i].send(attr)
112
+ c.send(attr + '=', val)
105
113
  end
114
+
115
+ # spanning columns overrides inheritance for width
116
+ # val = rows[0].columns[i].width
117
+ # c.width = val unless c.span > 1
106
118
  end
107
119
 
108
120
  def inherit_from
109
- self.rows[0].header ? 1 : 0
121
+ rows[0].header ? 1 : 0
110
122
  end
111
123
 
112
124
  def use_color(row, c, i)
@@ -115,7 +127,7 @@ module CommandLineReporter
115
127
  elsif row.color
116
128
  c.color = row.color
117
129
  elsif inherit_from != 1
118
- c.color = self.rows[inherit_from].columns[i].color
130
+ c.color = rows[inherit_from].columns[i].color
119
131
  end
120
132
  end
121
133
 
@@ -123,7 +135,7 @@ module CommandLineReporter
123
135
  if row.bold
124
136
  c.bold = row.bold
125
137
  elsif inherit_from != 1
126
- c.bold = self.rows[inherit_from].columns[i].bold
138
+ c.bold = rows[inherit_from].columns[i].bold
127
139
  end
128
140
  end
129
141
  end
@@ -1,3 +1,3 @@
1
1
  module CommandLineReporter
2
- VERSION = '3.3.6'
2
+ VERSION = '4.0.0'.freeze
3
3
  end
@@ -1,94 +1,159 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CommandLineReporter::Column do
4
- describe '#initialize' do
4
+ subject { CommandLineReporter::Column }
5
+
6
+ context '#initialize' do
5
7
  it 'rejects invalid options' do
6
- expect {
7
- CommandLineReporter::Column.new('test', :asdf => '1234')
8
- }.to raise_error ArgumentError
8
+ expect do
9
+ subject.new('test', asdf: '1234')
10
+ end.to raise_error ArgumentError
9
11
  end
10
12
 
11
13
  it 'defaults options hash' do
12
- expect {
13
- CommandLineReporter::Column.new('test')
14
- }.to_not raise_error
14
+ expect do
15
+ subject.new('test')
16
+ end.to_not raise_error Exception
15
17
  end
16
18
 
17
19
  it 'defaults the width' do
18
- expect(CommandLineReporter::Column.new('test').width).to eq(10)
20
+ c = subject.new('test')
21
+ expect(c.width).to eq(10)
19
22
  end
20
23
 
21
24
  it 'accepts the width' do
22
- expect(CommandLineReporter::Column.new('test', :width => 50).width).to eq(50)
25
+ c = subject.new('test', width: 50)
26
+ expect(c.width).to eq(50)
23
27
  end
24
28
 
25
29
  it 'requires valid width' do
26
- expect {
27
- CommandLineReporter::Column.new('test', :width => 'asdf')
28
- }.to raise_error ArgumentError
30
+ expect do
31
+ subject.new('test', width: 'asdf')
32
+ end.to raise_error ArgumentError
29
33
  end
30
34
 
31
35
  it 'accepts text' do
32
- expect(CommandLineReporter::Column.new('asdf').text).to eq('asdf')
36
+ c = subject.new('asdf')
37
+ expect(c.text).to eq('asdf')
33
38
  end
34
39
 
35
40
  it 'accepts color' do
36
- expect(CommandLineReporter::Column.new('asdf', :color => 'red').color).to eq('red')
41
+ c = subject.new('asdf', color: 'red')
42
+ expect(c.color).to eq('red')
37
43
  end
38
44
 
39
45
  it 'accepts bold' do
40
- expect(CommandLineReporter::Column.new('asdf', :bold => true).bold).to be true
46
+ c = subject.new('asdf', bold: true)
47
+ expect(c.bold).to be true
41
48
  end
42
49
 
43
50
  it 'defaults the padding' do
44
- expect(CommandLineReporter::Column.new('test').padding).to eq(0)
51
+ c = subject.new('test')
52
+ expect(c.padding).to eq(0)
45
53
  end
46
54
 
47
55
  it 'accepts the padding' do
48
- expect(CommandLineReporter::Column.new('test', :padding => 5).padding).to eq(5)
56
+ c = subject.new('test', padding: 5)
57
+ expect(c.padding).to eq(5)
49
58
  end
50
59
 
51
60
  it 'requires valid width' do
52
- expect {
53
- CommandLineReporter::Column.new('test', :padding => 'asdf')
54
- }.to raise_error ArgumentError
61
+ expect do
62
+ subject.new('test', padding: 'asdf')
63
+ end.to raise_error ArgumentError
55
64
  end
56
65
  end
57
66
 
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)
67
+ context '#size' do
68
+ it 'should have default width' do
69
+ c = subject.new('test')
70
+ expect(c.size).to eq(10)
71
+ end
72
+
73
+ it 'should have custom width' do
74
+ c = subject.new('test', width: 5)
75
+ expect(c.size).to eq(5)
76
+ end
77
+
78
+ it 'should be reduced by the padding' do
79
+ c = subject.new('test', width: 5, padding: 1)
80
+ expect(c.size).to eq(3)
63
81
  end
64
82
  end
65
83
 
66
- describe '#required_width' do
84
+ context '#required_width' do
67
85
  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)
86
+ c = subject.new('test')
87
+ expect(c.required_width).to eq(4)
88
+ end
89
+
90
+ it 'should be length of string plus twice default padding' do
91
+ c = subject.new('test', padding: 1)
92
+ expect(c.required_width).to eq(6)
93
+ end
94
+
95
+ it 'should be length of string plus twice custom padding' do
96
+ c = subject.new('test', padding: 5)
97
+ expect(c.required_width).to eq(14)
98
+ end
99
+ end
100
+
101
+ context 'spanning columns' do
102
+ it 'should adjust width for 2 default columns' do
103
+ col = subject.new('test', span: 2)
104
+ expect(col.width).to eq(20)
105
+ expect(col.size).to eq(23)
106
+ end
107
+
108
+ it 'should adjust width for 2 custom sized columns' do
109
+ col = subject.new('test', width: 20, span: 2)
110
+ expect(col.width).to eq(40)
111
+ expect(col.size).to eq(43)
112
+ end
113
+
114
+ it 'should adjust width for 3 default columns' do
115
+ col = subject.new('test', span: 3)
116
+ expect(col.width).to eq(30)
117
+ expect(col.size).to eq(36)
118
+ end
119
+
120
+ it 'should adjust width for 3 custom sized columns' do
121
+ col = subject.new('test', width: 20, span: 3)
122
+ expect(col.width).to eq(60)
123
+ expect(col.size).to eq(66)
124
+ end
125
+
126
+ it 'should adjust width for 4 default columns' do
127
+ col = subject.new('test', span: 4)
128
+ expect(col.width).to eq(40)
129
+ expect(col.size).to eq(49)
130
+ end
131
+
132
+ it 'should adjust width for 2 custom sized columns' do
133
+ col = subject.new('test', width: 20, span: 4)
134
+ expect(col.width).to eq(80)
135
+ expect(col.size).to eq(89)
71
136
  end
72
137
  end
73
138
 
74
- describe '#screen_rows' do
139
+ context '#screen_rows' do
75
140
  let :controls do
76
141
  {
77
- :clear => "\e[0m",
78
- :bold => "\e[1m",
79
- :red => "\e[31m",
142
+ clear: "\e[0m",
143
+ bold: "\e[1m",
144
+ red: "\e[31m"
80
145
  }
81
146
  end
82
147
 
83
148
  context 'no wrapping' do
84
149
  context 'no padding' do
85
150
  it 'gives a single row' do
86
- c = CommandLineReporter::Column.new('x' * 5)
151
+ c = subject.new('x' * 5)
87
152
  c.screen_rows.size == 1
88
153
  end
89
154
 
90
155
  it 'handles empty text' do
91
- c = CommandLineReporter::Column.new
156
+ c = subject.new
92
157
  expect(c.screen_rows[0]).to eq(' ' * 10)
93
158
  end
94
159
 
@@ -97,17 +162,17 @@ describe CommandLineReporter::Column do
97
162
  let(:filler) { ' ' * 10 }
98
163
 
99
164
  it 'plain text' do
100
- c = CommandLineReporter::Column.new(text, :width => 20)
165
+ c = subject.new(text, width: 20)
101
166
  expect(c.screen_rows[0]).to eq(text + filler)
102
167
  end
103
168
 
104
169
  it 'outputs red' do
105
- c = CommandLineReporter::Column.new(text, :align => 'left', :width => 20, :color => 'red')
170
+ c = subject.new(text, align: 'left', width: 20, color: 'red')
106
171
  expect(c.screen_rows[0]).to eq(controls[:red] + text + filler + controls[:clear])
107
172
  end
108
173
 
109
174
  it 'outputs bold' do
110
- c = CommandLineReporter::Column.new(text, :align => 'left', :width => 20, :bold => true)
175
+ c = subject.new(text, align: 'left', width: 20, bold: true)
111
176
  expect(c.screen_rows[0]).to eq(controls[:bold] + text + filler + controls[:clear])
112
177
  end
113
178
  end
@@ -117,17 +182,17 @@ describe CommandLineReporter::Column do
117
182
  let(:filler) { ' ' * 10 }
118
183
 
119
184
  it 'plain text' do
120
- c = CommandLineReporter::Column.new(text, :align => 'right', :width => 20)
185
+ c = subject.new(text, align: 'right', width: 20)
121
186
  expect(c.screen_rows[0]).to eq(filler + text)
122
187
  end
123
188
 
124
189
  it 'outputs red' do
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])
190
+ c = subject.new(text, align: 'right', width: 20, color: 'red')
191
+ expect(c.screen_rows[0]).to eq(controls[:red] + filler + text + controls[:clear])
127
192
  end
128
193
 
129
194
  it 'outputs bold' do
130
- c = CommandLineReporter::Column.new(text, :align => 'right', :width => 20, :bold => true)
195
+ c = subject.new(text, align: 'right', width: 20, bold: true)
131
196
  expect(c.screen_rows[0]).to eq(controls[:bold] + filler + text + controls[:clear])
132
197
  end
133
198
  end
@@ -137,17 +202,17 @@ describe CommandLineReporter::Column do
137
202
  let(:filler) { ' ' * 5 }
138
203
 
139
204
  it 'plain text' do
140
- c = CommandLineReporter::Column.new(text, :align => 'center', :width => 20)
205
+ c = subject.new(text, align: 'center', width: 20)
141
206
  expect(c.screen_rows[0]).to eq(filler + text + filler)
142
207
  end
143
208
 
144
209
  it 'outputs red' do
145
- c = CommandLineReporter::Column.new(text, :align => 'center', :width => 20, :color => 'red')
210
+ c = subject.new(text, align: 'center', width: 20, color: 'red')
146
211
  expect(c.screen_rows[0]).to eq(controls[:red] + filler + text + filler + controls[:clear])
147
212
  end
148
213
 
149
214
  it 'outputs bold' do
150
- c = CommandLineReporter::Column.new(text, :align => 'center', :width => 20, :bold => true)
215
+ c = subject.new(text, align: 'center', width: 20, bold: true)
151
216
  expect(c.screen_rows[0]).to eq(controls[:bold] + filler + text + filler + controls[:clear])
152
217
  end
153
218
  end
@@ -160,17 +225,17 @@ describe CommandLineReporter::Column do
160
225
  let(:filler) { ' ' * 10 }
161
226
 
162
227
  it 'plain text' do
163
- c = CommandLineReporter::Column.new(text, :padding => 5, :width => 30)
228
+ c = subject.new(text, padding: 5, width: 30)
164
229
  expect(c.screen_rows[0]).to eq(padding + text + filler + padding)
165
230
  end
166
231
 
167
232
  it 'outputs red' do
168
- c = CommandLineReporter::Column.new(text, :padding => 5, :width => 30, :color => 'red')
233
+ c = subject.new(text, padding: 5, width: 30, color: 'red')
169
234
  expect(c.screen_rows[0]).to eq(padding + controls[:red] + text + filler + controls[:clear] + padding)
170
235
  end
171
236
 
172
237
  it 'outputs bold' do
173
- c = CommandLineReporter::Column.new(text, :padding => 5, :width => 30, :bold => true)
238
+ c = subject.new(text, padding: 5, width: 30, bold: true)
174
239
  expect(c.screen_rows[0]).to eq(padding + controls[:bold] + text + filler + controls[:clear] + padding)
175
240
  end
176
241
  end
@@ -181,17 +246,17 @@ describe CommandLineReporter::Column do
181
246
  let(:filler) { ' ' * 10 }
182
247
 
183
248
  it 'plain text' do
184
- c = CommandLineReporter::Column.new(text, :align => 'right', :padding => 5, :width => 30)
249
+ c = subject.new(text, align: 'right', padding: 5, width: 30)
185
250
  expect(c.screen_rows[0]).to eq(padding + filler + text + padding)
186
251
  end
187
252
 
188
253
  it 'outputs red' do
189
- c = CommandLineReporter::Column.new(text, :align => 'right', :padding => 5, :width => 30, :color => 'red')
254
+ c = subject.new(text, align: 'right', padding: 5, width: 30, color: 'red')
190
255
  expect(c.screen_rows[0]).to eq(padding + controls[:red] + filler + text + controls[:clear] + padding)
191
256
  end
192
257
 
193
258
  it 'outputs bold' do
194
- c = CommandLineReporter::Column.new(text, :align => 'right', :padding => 5, :width => 30, :bold => true)
259
+ c = subject.new(text, align: 'right', padding: 5, width: 30, bold: true)
195
260
  expect(c.screen_rows[0]).to eq(padding + controls[:bold] + filler + text + controls[:clear] + padding)
196
261
  end
197
262
  end
@@ -202,17 +267,17 @@ describe CommandLineReporter::Column do
202
267
  let(:filler) { ' ' * 5 }
203
268
 
204
269
  it 'plain text' do
205
- c = CommandLineReporter::Column.new(text, :align => 'center', :padding => 5, :width => 30)
270
+ c = subject.new(text, align: 'center', padding: 5, width: 30)
206
271
  expect(c.screen_rows[0]).to eq(padding + filler + text + filler + padding)
207
272
  end
208
273
 
209
274
  it 'outputs red' do
210
- c = CommandLineReporter::Column.new(text, :align => 'center', :padding => 5, :width => 30, :color => 'red')
275
+ c = subject.new(text, align: 'center', padding: 5, width: 30, color: 'red')
211
276
  expect(c.screen_rows[0]).to eq(padding + controls[:red] + filler + text + filler + controls[:clear] + padding)
212
277
  end
213
278
 
214
279
  it 'outputs bold' do
215
- c = CommandLineReporter::Column.new(text, :align => 'center', :padding => 5, :width => 30, :bold => true)
280
+ c = subject.new(text, align: 'center', padding: 5, width: 30, bold: true)
216
281
  expect(c.screen_rows[0]).to eq(padding + controls[:bold] + filler + text + filler + controls[:clear] + padding)
217
282
  end
218
283
  end
@@ -228,26 +293,30 @@ describe CommandLineReporter::Column do
228
293
  let(:filler) { ' ' * 5 }
229
294
 
230
295
  it 'plain text' do
231
- c = CommandLineReporter::Column.new(text, :width => 10)
296
+ c = subject.new(text, width: 10)
232
297
  expect(c.screen_rows).to eq([full_line, full_line, remainder + filler])
233
298
  end
234
299
 
235
300
  it 'outputs red' do
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
- ])
301
+ c = subject.new(text, width: 10, color: 'red')
302
+ expect(c.screen_rows).to eq(
303
+ [
304
+ controls[:red] + full_line + controls[:clear],
305
+ controls[:red] + full_line + controls[:clear],
306
+ controls[:red] + remainder + filler + controls[:clear]
307
+ ]
308
+ )
242
309
  end
243
310
 
244
311
  it 'outputs bold' do
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
- ])
312
+ c = subject.new(text, width: 10, bold: true)
313
+ expect(c.screen_rows).to eq(
314
+ [
315
+ controls[:bold] + full_line + controls[:clear],
316
+ controls[:bold] + full_line + controls[:clear],
317
+ controls[:bold] + remainder + filler + controls[:clear]
318
+ ]
319
+ )
251
320
  end
252
321
  end
253
322
 
@@ -258,26 +327,30 @@ describe CommandLineReporter::Column do
258
327
  let(:filler) { ' ' * 5 }
259
328
 
260
329
  it 'plain text' do
261
- c = CommandLineReporter::Column.new(text, :align => 'right', :width => 10)
330
+ c = subject.new(text, align: 'right', width: 10)
262
331
  expect(c.screen_rows).to eq([full_line, full_line, filler + remainder])
263
332
  end
264
333
 
265
334
  it 'outputs red' do
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
- ])
335
+ c = subject.new(text, align: 'right', width: 10, color: 'red')
336
+ expect(c.screen_rows).to eq(
337
+ [
338
+ controls[:red] + full_line + controls[:clear],
339
+ controls[:red] + full_line + controls[:clear],
340
+ controls[:red] + filler + remainder + controls[:clear]
341
+ ]
342
+ )
272
343
  end
273
344
 
274
345
  it 'outputs bold' do
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
- ])
346
+ c = subject.new(text, align: 'right', width: 10, bold: true)
347
+ expect(c.screen_rows).to eq(
348
+ [
349
+ controls[:bold] + full_line + controls[:clear],
350
+ controls[:bold] + full_line + controls[:clear],
351
+ controls[:bold] + filler + remainder + controls[:clear]
352
+ ]
353
+ )
281
354
  end
282
355
  end
283
356
 
@@ -289,26 +362,30 @@ describe CommandLineReporter::Column do
289
362
  let(:right_filler) { ' ' * 2 }
290
363
 
291
364
  it 'plain text' do
292
- c = CommandLineReporter::Column.new(text, :align => 'center', :width => 10)
365
+ c = subject.new(text, align: 'center', width: 10)
293
366
  expect(c.screen_rows).to eq([full_line, full_line, ' ' * 3 + remainder + right_filler])
294
367
  end
295
368
 
296
369
  it 'outputs red' do
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
- ])
370
+ c = subject.new(text, align: 'center', width: 10, color: 'red')
371
+ expect(c.screen_rows).to eq(
372
+ [
373
+ controls[:red] + full_line + controls[:clear],
374
+ controls[:red] + full_line + controls[:clear],
375
+ controls[:red] + left_filler + remainder + right_filler + controls[:clear]
376
+ ]
377
+ )
303
378
  end
304
379
 
305
380
  it 'outputs bold' do
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
- ])
381
+ c = subject.new(text, align: 'center', width: 10, bold: true)
382
+ expect(c.screen_rows).to eq(
383
+ [
384
+ controls[:bold] + full_line + controls[:clear],
385
+ controls[:bold] + full_line + controls[:clear],
386
+ controls[:bold] + left_filler + remainder + right_filler + controls[:clear]
387
+ ]
388
+ )
312
389
  end
313
390
  end
314
391
  end
@@ -322,27 +399,33 @@ describe CommandLineReporter::Column do
322
399
  let(:filler) { ' ' * 7 }
323
400
 
324
401
  it 'plain text' do
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
- ])
402
+ c = subject.new(text, padding: 2, width: 20)
403
+ expect(c.screen_rows).to eq(
404
+ [
405
+ padding + full_line + padding,
406
+ padding + remainder + filler + padding
407
+ ]
408
+ )
330
409
  end
331
410
 
332
411
  it 'outputs red' do
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
- ])
412
+ c = subject.new(text, padding: 2, width: 20, color: 'red')
413
+ expect(c.screen_rows).to eq(
414
+ [
415
+ padding + controls[:red] + full_line + controls[:clear] + padding,
416
+ padding + controls[:red] + remainder + filler + controls[:clear] + padding
417
+ ]
418
+ )
338
419
  end
339
420
 
340
421
  it 'outputs bold' do
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
- ])
422
+ c = subject.new(text, padding: 2, width: 20, bold: true)
423
+ expect(c.screen_rows).to eq(
424
+ [
425
+ padding + controls[:bold] + full_line + controls[:clear] + padding,
426
+ padding + controls[:bold] + remainder + filler + controls[:clear] + padding
427
+ ]
428
+ )
346
429
  end
347
430
  end
348
431
 
@@ -354,27 +437,33 @@ describe CommandLineReporter::Column do
354
437
  let(:filler) { ' ' * 7 }
355
438
 
356
439
  it 'plain text' do
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
- ])
440
+ c = subject.new(text, padding: 2, align: 'right', width: 20)
441
+ expect(c.screen_rows).to eq(
442
+ [
443
+ padding + full_line + padding,
444
+ padding + filler + remainder + padding
445
+ ]
446
+ )
362
447
  end
363
448
 
364
449
  it 'outputs red' do
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
- ])
450
+ c = subject.new(text, align: 'right', padding: 2, width: 20, color: 'red')
451
+ expect(c.screen_rows).to eq(
452
+ [
453
+ padding + controls[:red] + full_line + controls[:clear] + padding,
454
+ padding + controls[:red] + filler + remainder + controls[:clear] + padding
455
+ ]
456
+ )
370
457
  end
371
458
 
372
459
  it 'outputs bold' do
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
- ])
460
+ c = subject.new(text, align: 'right', padding: 2, width: 20, bold: true)
461
+ expect(c.screen_rows).to eq(
462
+ [
463
+ padding + controls[:bold] + full_line + controls[:clear] + padding,
464
+ padding + controls[:bold] + filler + remainder + controls[:clear] + padding
465
+ ]
466
+ )
378
467
  end
379
468
  end
380
469
 
@@ -387,27 +476,33 @@ describe CommandLineReporter::Column do
387
476
  let(:right_filler) { ' ' * 3 }
388
477
 
389
478
  it 'plain text' do
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
- ])
479
+ c = subject.new(text, padding: 2, align: 'center', width: 20)
480
+ expect(c.screen_rows).to eq(
481
+ [
482
+ padding + full_line + padding,
483
+ padding + left_filler + remainder + right_filler + padding
484
+ ]
485
+ )
395
486
  end
396
487
 
397
488
  it 'outputs red' do
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
- ])
489
+ c = subject.new(text, padding: 2, align: 'center', width: 20, color: 'red')
490
+ expect(c.screen_rows).to eq(
491
+ [
492
+ padding + controls[:red] + full_line + controls[:clear] + padding,
493
+ padding + controls[:red] + left_filler + remainder + right_filler + controls[:clear] + padding
494
+ ]
495
+ )
403
496
  end
404
497
 
405
498
  it 'outputs bold' do
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
- ])
499
+ c = subject.new(text, padding: 2, align: 'center', width: 20, bold: true)
500
+ expect(c.screen_rows).to eq(
501
+ [
502
+ padding + controls[:bold] + full_line + controls[:clear] + padding,
503
+ padding + controls[:bold] + left_filler + remainder + right_filler + controls[:clear] + padding
504
+ ]
505
+ )
411
506
  end
412
507
  end
413
508
  end