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