Skip to content

Commit 03a9b27

Browse files
committed
Chore: Remove Unneeded Projector From Progress
1 parent 2bc31d0 commit 03a9b27

File tree

2 files changed

+26
-52
lines changed

2 files changed

+26
-52
lines changed

spec/lib/ruby-progressbar/components/bar_spec.rb

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ module Components
3030

3131
describe '#bar' do
3232
it 'displays the bar with no indication of progress when just begun' do
33-
projector = Projectors::SmoothedAverage.new
34-
progress = Progress.new(:projector => projector, :total => 50)
33+
progress = Progress.new(:total => 50)
3534
progressbar = Bar.new(:progress => progress,
3635
:length => 100)
3736

@@ -41,8 +40,7 @@ module Components
4140

4241
it 'displays the bar with an indication of progress when nothing has been ' \
4342
'completed and the bar is incremented' do
44-
projector = Projectors::SmoothedAverage.new
45-
progress = Progress.new(:projector => projector, :total => 50)
43+
progress = Progress.new(:total => 50)
4644
progressbar = Bar.new(:progress => progress,
4745
:length => 100)
4846
progress.increment
@@ -53,8 +51,7 @@ module Components
5351

5452
it 'displays the bar with no indication of progress when a fraction of a percentage ' \
5553
'has been completed' do
56-
projector = Projectors::SmoothedAverage.new
57-
progress = Progress.new(:projector => projector, :total => 200)
54+
progress = Progress.new(:total => 200)
5855
progressbar = Bar.new(:progress => progress,
5956
:length => 100)
6057
progress.start :at => 1
@@ -64,8 +61,7 @@ module Components
6461
end
6562

6663
it 'displays the bar as 100% complete when completed' do
67-
projector = Projectors::SmoothedAverage.new
68-
progress = Progress.new(:projector => projector, :total => 50)
64+
progress = Progress.new(:total => 50)
6965
progressbar = Bar.new(:progress => progress,
7066
:length => 100)
7167
progress.start :at => 50
@@ -76,8 +72,7 @@ module Components
7672
end
7773

7874
it 'displays the bar as 98% complete when completed and the bar is decremented' do
79-
projector = Projectors::SmoothedAverage.new
80-
progress = Progress.new(:projector => projector, :total => 50)
75+
progress = Progress.new(:total => 50)
8176
progressbar = Bar.new(:progress => progress,
8277
:length => 100)
8378
progress.start :at => 50
@@ -90,8 +85,7 @@ module Components
9085

9186
describe '#bar_with_percentage' do
9287
it 'displays the bar with an integrated percentage properly when empty' do
93-
projector = Projectors::SmoothedAverage.new
94-
progress = Progress.new(:projector => projector, :total => 100)
88+
progress = Progress.new(:total => 100)
9589
progressbar = Bar.new(:progress => progress,
9690
:length => 100)
9791

@@ -101,8 +95,7 @@ module Components
10195

10296
it 'displays the bar with an integrated percentage properly just before' \
10397
'the percentage is displayed' do
104-
projector = Projectors::SmoothedAverage.new
105-
progress = Progress.new(:projector => projector, :total => 100)
98+
progress = Progress.new(:total => 100)
10699
progressbar = Bar.new(:progress => progress,
107100
:length => 100)
108101

@@ -114,8 +107,7 @@ module Components
114107

115108
it 'displays the bar with an integrated percentage properly immediately after' \
116109
'the percentage is displayed' do
117-
projector = Projectors::SmoothedAverage.new
118-
progress = Progress.new(:projector => projector, :total => 100)
110+
progress = Progress.new(:total => 100)
119111
progressbar = Bar.new(:progress => progress,
120112
:length => 100)
121113

@@ -127,8 +119,7 @@ module Components
127119

128120
it 'displays the bar with an integrated percentage properly on double digit' \
129121
'percentage' do
130-
projector = Projectors::SmoothedAverage.new
131-
progress = Progress.new(:projector => projector, :total => 100)
122+
progress = Progress.new(:total => 100)
132123
progressbar = Bar.new(:progress => progress,
133124
:length => 100)
134125

@@ -139,8 +130,7 @@ module Components
139130
end
140131

141132
it 'displays the bar with an integrated percentage properly when finished' do
142-
projector = Projectors::SmoothedAverage.new
143-
progress = Progress.new(:projector => projector, :total => 100)
133+
progress = Progress.new(:total => 100)
144134
progressbar = Bar.new(:progress => progress,
145135
:length => 100)
146136
progress.finish
@@ -151,8 +141,7 @@ module Components
151141

152142
it 'calculates the remaining negative space properly with an integrated percentage ' \
153143
'bar of 0 percent' do
154-
projector = Projectors::SmoothedAverage.new
155-
progress = Progress.new(:projector => projector, :total => 200)
144+
progress = Progress.new(:total => 200)
156145
progressbar = Bar.new(:progress => progress,
157146
:length => 100)
158147

@@ -173,8 +162,7 @@ module Components
173162

174163
describe '#incomplete_space' do
175164
it 'displays the bar with an integrated percentage properly when empty' do
176-
projector = Projectors::SmoothedAverage.new
177-
progress = Progress.new(:projector => projector, :total => 100)
165+
progress = Progress.new(:total => 100)
178166
progressbar = Bar.new(:progress => progress,
179167
:length => 100)
180168

@@ -184,8 +172,7 @@ module Components
184172

185173
it 'displays the bar with an integrated percentage properly just before' \
186174
'the percentage is displayed' do
187-
projector = Projectors::SmoothedAverage.new
188-
progress = Progress.new(:projector => projector, :total => 100)
175+
progress = Progress.new(:total => 100)
189176
progressbar = Bar.new(:progress => progress,
190177
:length => 100)
191178

@@ -197,8 +184,7 @@ module Components
197184

198185
it 'displays the bar with an integrated percentage properly immediately after' \
199186
'the percentage is displayed' do
200-
projector = Projectors::SmoothedAverage.new
201-
progress = Progress.new(:projector => projector, :total => 100)
187+
progress = Progress.new(:total => 100)
202188
progressbar = Bar.new(:progress => progress,
203189
:length => 100)
204190

@@ -210,8 +196,7 @@ module Components
210196

211197
it 'displays the bar with an integrated percentage properly on double digit' \
212198
'percentage' do
213-
projector = Projectors::SmoothedAverage.new
214-
progress = Progress.new(:projector => projector, :total => 100)
199+
progress = Progress.new(:total => 100)
215200
progressbar = Bar.new(:progress => progress,
216201
:length => 100)
217202

@@ -222,8 +207,7 @@ module Components
222207
end
223208

224209
it 'displays the bar with an integrated percentage properly when finished' do
225-
projector = Projectors::SmoothedAverage.new
226-
progress = Progress.new(:projector => projector, :total => 100)
210+
progress = Progress.new(:total => 100)
227211
progressbar = Bar.new(:progress => progress,
228212
:length => 100)
229213
progress.finish
@@ -234,8 +218,7 @@ module Components
234218

235219
it 'calculates the remaining negative space properly with an integrated percentage ' \
236220
'bar of 0 percent' do
237-
projector = Projectors::SmoothedAverage.new
238-
progress = Progress.new(:projector => projector, :total => 200)
221+
progress = Progress.new(:total => 200)
239222
progressbar = Bar.new(:progress => progress,
240223
:length => 100)
241224

@@ -254,8 +237,7 @@ module Components
254237
end
255238

256239
it 'is represented correctly when a bar has an unknown amount to completion' do
257-
projector = Projectors::SmoothedAverage.new
258-
progress = Progress.new(:projector => projector, :total => nil)
240+
progress = Progress.new(:total => nil)
259241
progressbar = Bar.new(:progress => progress,
260242
:length => 80)
261243

@@ -265,8 +247,7 @@ module Components
265247

266248
it 'is represented after being incremented once when a bar has an unknown amount ' \
267249
'to completion' do
268-
projector = Projectors::SmoothedAverage.new
269-
progress = Progress.new(:projector => projector, :total => nil)
250+
progress = Progress.new(:total => nil)
270251
progressbar = Bar.new(:progress => progress,
271252
:length => 80)
272253

@@ -278,8 +259,7 @@ module Components
278259

279260
it 'is represented after being incremented twice when a bar has an unknown amount ' \
280261
'to completion' do
281-
projector = Projectors::SmoothedAverage.new
282-
progress = Progress.new(:projector => projector, :total => nil)
262+
progress = Progress.new(:total => nil)
283263
progressbar = Bar.new(:progress => progress,
284264
:length => 80)
285265

@@ -290,8 +270,7 @@ module Components
290270
end
291271

292272
it 'is represented correctly when a bar has a customized unknown animation' do
293-
projector = Projectors::SmoothedAverage.new
294-
progress = Progress.new(:projector => projector, :total => nil)
273+
progress = Progress.new(:total => nil)
295274
progressbar = Bar.new(:progress => progress,
296275
:unknown_progress_animation_steps => [
297276
'*--',
@@ -307,8 +286,7 @@ module Components
307286

308287
it 'raises an error when attempting to set the current value of the bar to be ' \
309288
'greater than the total' do
310-
projector = Projectors::SmoothedAverage.new
311-
progress = Progress.new(:projector => projector, :total => 10)
289+
progress = Progress.new(:total => 10)
312290
_progressbar = Bar.new(:progress => progress)
313291

314292
expect { progress.start :at => 11 }.

spec/lib/ruby-progressbar/components/percentage_spec.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ module Components
66
describe Percentage do
77
describe '#percentage' do
88
it 'returns the percentage' do
9-
projector = Projectors::SmoothedAverage.new
10-
progress = Progress.new(:projector => projector, :total => 10)
9+
progress = Progress.new(:total => 10)
1110
percentage = Percentage.new(:progress => progress)
1211

1312
progress.progress = 5
@@ -18,8 +17,7 @@ module Components
1817

1918
describe '#percentage_with_precision' do
2019
it 'returns the percentage' do
21-
projector = Projectors::SmoothedAverage.new
22-
progress = Progress.new(:projector => projector, :total => 10)
20+
progress = Progress.new(:total => 10)
2321
percentage = Percentage.new(:progress => progress)
2422

2523
progress.progress = 5
@@ -30,8 +28,7 @@ module Components
3028

3129
describe '#justified_percentage' do
3230
it 'returns the percentage' do
33-
projector = Projectors::SmoothedAverage.new
34-
progress = Progress.new(:projector => projector, :total => 10)
31+
progress = Progress.new(:total => 10)
3532
percentage = Percentage.new(:progress => progress)
3633

3734
progress.progress = 5
@@ -42,8 +39,7 @@ module Components
4239

4340
describe '#justified_percentage_with_precision' do
4441
it 'returns the percentage' do
45-
projector = Projectors::SmoothedAverage.new
46-
progress = Progress.new(:projector => projector, :total => 10)
42+
progress = Progress.new(:total => 10)
4743
percentage = Percentage.new(:progress => progress)
4844

4945
progress.progress = 5

0 commit comments

Comments
 (0)