Skip to content

Commit 9446785

Browse files
committed
(CONT-799) Rubocop Fixes 13-15
- RSpec/ContextWording - RSpec/ExampleLength - RSpec/MultipleExpectations
1 parent 9144a50 commit 9446785

8 files changed

+40
-57
lines changed

.rubocop.yml

+2
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,5 @@ Style/Documentation:
8383
- spec/**/*
8484
Style/WordArray:
8585
EnforcedStyle: brackets
86+
RSpec/MultipleExpectations:
87+
Max: 3

.rubocop_todo.yml

-19
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,11 @@
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 33
10-
# Configuration parameters: Prefixes, AllowedPatterns.
11-
# Prefixes: when, with, without
12-
RSpec/ContextWording:
13-
Exclude:
14-
- 'spec/acceptance/listen_spec.rb'
15-
- 'spec/classes/haproxy_spec.rb'
16-
- 'spec/defines/balancermember_spec.rb'
17-
- 'spec/defines/instance_spec.rb'
18-
199
# Offense count: 22
2010
# Configuration parameters: IgnoredMetadata.
2111
RSpec/DescribeClass:
2212
Enabled: false
2313

24-
# Offense count: 3
25-
# Configuration parameters: CountAsOne.
26-
RSpec/ExampleLength:
27-
Max: 7
28-
2914
# Offense count: 66
3015
# This cop supports safe autocorrection (--autocorrect).
3116
# Configuration parameters: EnforcedStyle.
@@ -48,10 +33,6 @@ RSpec/ImplicitSubject:
4833
- 'spec/defines/resolver_spec.rb'
4934
- 'spec/defines/userlist_spec.rb'
5035

51-
# Offense count: 15
52-
RSpec/MultipleExpectations:
53-
Max: 3
54-
5536
# Offense count: 3
5637
# Configuration parameters: AllowSubject.
5738
RSpec/MultipleMemoizedHelpers:

spec/acceptance/basic_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class { 'haproxy': }
5555
end
5656
end
5757

58-
it 'has stats listening on each port' do
59-
['9090', '9091'].each do |port|
58+
['9090', '9091'].each do |port|
59+
it "port #{port} has stats listening on each port" do
6060
run_shell("/usr/bin/curl -u puppet:puppet localhost:#{port}") do |r|
6161
expect(r.stdout).to contain %r{HAProxy}
6262
expect(r.exit_code).to eq 0
@@ -85,8 +85,8 @@ class { 'haproxy': }
8585
end
8686
end
8787

88-
it 'has stats listening on each port' do
89-
['9090', '9091'].each do |port|
88+
['9090', '9091'].each do |port|
89+
it "port #{port} has stats listening on each port" do
9090
run_shell("/usr/bin/curl -u puppet:puppet localhost:#{port}") do |r|
9191
expect(r.stdout).to contain %r{HAProxy}
9292
expect(r.exit_code).to eq 0

spec/acceptance/frontbackend_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class { 'haproxy': }
3535
# This is not great since it depends on the ordering served by the load
3636
# balancer. Something with retries would be better.
3737
# C9945
38-
it 'does a curl against the LB to make sure it gets a response from each port' do
38+
it 'does a curl against the LB to make sure it gets a response from each port' do # rubocop:disable RSpec/ExampleLength
3939
response_connection = run_shell('curl localhost:5555').stdout.chomp
4040
expect(response_connection).to match(%r{Response on 555(6|7)})
4141
if response_connection == 'Response on 5556'

spec/acceptance/listen_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require 'spec_helper_acceptance'
44

55
describe 'listen define' do
6-
context 'pp_one' do
6+
context 'with standard setup' do
77
pp_one = <<-PUPPETCODE
88
class { 'haproxy': }
99
haproxy::listen { 'app00':
@@ -36,7 +36,7 @@ class { 'haproxy': }
3636
end
3737
end
3838

39-
context 'pp_two' do
39+
context 'with options' do
4040
# C9955
4141
pp_two = <<-PUPPETCODE
4242
class { 'haproxy': }
@@ -71,7 +71,7 @@ class { 'haproxy': }
7171
end
7272
# C9942 C9944 WONTFIX
7373

74-
context 'pp_three' do
74+
context 'with one node up' do
7575
# C9943
7676
pp_three = <<-PUPPETCODE
7777
class { 'haproxy': }
@@ -102,7 +102,7 @@ class { 'haproxy': }
102102
end
103103
end
104104

105-
context 'pp_three' do
105+
context 'with no addess' do
106106
pp_four = <<-PUPPETCODE
107107
class { 'haproxy': }
108108
haproxy::listen { 'app0':

spec/classes/haproxy_spec.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
describe 'for OS-agnostic configuration' do
1616
['Debian', 'RedHat', 'Archlinux', 'FreeBSD', 'Gentoo'].each do |osfamily|
17-
context "on #{osfamily} family operatingsystems" do
17+
context "when on #{osfamily} family operatingsystems" do
1818
let(:facts) do
1919
{ os: { family: osfamily } }.merge default_facts
2020
end
@@ -40,7 +40,7 @@
4040
end
4141
end
4242

43-
context "on #{osfamily} specifying a package version" do
43+
context "when on #{osfamily} specifying a package version" do
4444
let(:facts) do
4545
{ os: { family: osfamily } }.merge default_facts
4646
end
@@ -67,7 +67,7 @@
6767
end
6868

6969
# C9938
70-
context "on #{osfamily} when specifying custom content" do
70+
context "when on #{osfamily} when specifying custom content" do
7171
let(:facts) do
7272
{ os: { family: osfamily } }.merge default_facts
7373
end
@@ -86,7 +86,7 @@
8686

8787
describe 'for linux operating systems' do
8888
['Debian', 'RedHat', 'Archlinux', 'Gentoo'].each do |osfamily|
89-
context "on #{osfamily} family operatingsystems" do
89+
context "when on #{osfamily} family operatingsystems" do
9090
let(:facts) do
9191
{ os: { family: osfamily } }.merge default_facts
9292
end
@@ -155,7 +155,7 @@
155155
end
156156
end
157157

158-
context "on #{osfamily} family operatingsystems with setting haproxy.cfg location" do
158+
context "when on #{osfamily} family operatingsystems with setting haproxy.cfg location" do
159159
let(:facts) do
160160
{ os: { family: osfamily } }.merge default_facts
161161
end
@@ -174,7 +174,7 @@
174174
end
175175
end
176176

177-
context "on #{osfamily} family operatingsystems without managing the service" do
177+
context "when on #{osfamily} family operatingsystems without managing the service" do
178178
let(:facts) do
179179
{ os: { family: osfamily } }.merge default_facts
180180
end
@@ -257,7 +257,7 @@
257257
end
258258
end
259259

260-
context "on #{osfamily} when specifying a restart_command" do
260+
context "when on #{osfamily} when specifying a restart_command" do
261261
let(:facts) do
262262
{ os: { family: osfamily } }.merge default_facts
263263
end
@@ -461,7 +461,7 @@
461461
# Debian OS family so that we don't have to juggle different sets of
462462
# global_options and defaults_options (like for FreeBSD).
463463
['Debian'].each do |osfamily|
464-
context "on #{osfamily} family operatingsystems" do
464+
context "when on #{osfamily} family operatingsystems" do
465465
let(:facts) do
466466
{ os: { family: osfamily } }.merge default_facts
467467
end
@@ -572,7 +572,7 @@
572572
# Debian OS family so that we don't have to juggle different sets of
573573
# global_options and defaults_options (like for FreeBSD).
574574
['Debian'].each do |osfamily|
575-
context "on #{osfamily} family operatingsystems" do
575+
context "when on #{osfamily} family operatingsystems" do
576576
let(:facts) do
577577
{ os: { family: osfamily } }.merge default_facts
578578
end

spec/defines/balancermember_spec.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
}
200200
end
201201

202-
context 'server-template' do
202+
context 'with server-template' do
203203
let(:params) do
204204
{
205205
name: 'tyler',
@@ -218,7 +218,7 @@
218218
}
219219
end
220220

221-
context 'server-template with port' do
221+
context 'with server-template with port' do
222222
let(:params) do
223223
{
224224
name: 'tyler',
@@ -238,7 +238,7 @@
238238
}
239239
end
240240

241-
context 'server-template with port with num amount' do
241+
context 'with server-template with port with num amount' do
242242
let(:params) do
243243
{
244244
name: 'tyler',
@@ -259,7 +259,7 @@
259259
}
260260
end
261261

262-
context 'server-template with port with range amount' do
262+
context 'with server-template with port with range amount' do
263263
let(:params) do
264264
{
265265
name: 'tyler',
@@ -280,7 +280,7 @@
280280
}
281281
end
282282

283-
context 'server-template with port with range amount with server prefix' do
283+
context 'with server-template with port with range amount with server prefix' do
284284
let(:params) do
285285
{
286286
name: 'tyler',
@@ -302,7 +302,7 @@
302302
}
303303
end
304304

305-
context 'server-template with port with range amount with server prefix with options' do
305+
context 'with server-template with port with range amount with server prefix with options' do
306306
let(:params) do
307307
{
308308
name: 'tyler',
@@ -325,7 +325,7 @@
325325
}
326326
end
327327

328-
context 'server-template with port with range amount with server prefix with multiple options' do
328+
context 'with server-template with port with range amount with server prefix with multiple options' do
329329
let(:params) do
330330
{
331331
name: 'tyler',
@@ -348,7 +348,7 @@
348348
}
349349
end
350350

351-
context 'server-template with port with range amount with server prefix with options with weight' do
351+
context 'with server-template with port with range amount with server prefix with options with weight' do
352352
let(:params) do
353353
{
354354
name: 'tyler',
@@ -372,7 +372,7 @@
372372
}
373373
end
374374

375-
context 'server-template with port with range amount with server prefix with options with weight with cookies' do
375+
context 'with server-template with port with range amount with server prefix with options with weight with cookies' do
376376
let(:params) do
377377
{
378378
name: 'tyler',
@@ -397,7 +397,7 @@
397397
}
398398
end
399399

400-
context 'server-template with port with range amount with server prefix with options with weight with cookies with verifyhost' do
400+
context 'with server-template with port with range amount with server prefix with options with weight with cookies with verifyhost' do
401401
let(:params) do
402402
{
403403
name: 'tyler',

spec/defines/instance_spec.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
describe 'for OS-agnostic configuration' do
2525
['Debian', 'RedHat', 'Archlinux', 'FreeBSD'].each do |osfamily|
26-
context "on #{osfamily} family operatingsystems" do
26+
context "when on #{osfamily} family operatingsystems" do
2727
let(:facts) do
2828
{ os: { family: osfamily } }.merge default_facts
2929
end
@@ -50,7 +50,7 @@
5050
end
5151
end
5252

53-
context "on #{osfamily} family specifying a package version" do
53+
context "when on #{osfamily} family specifying a package version" do
5454
let(:facts) do
5555
{ os: { family: osfamily } }.merge default_facts
5656
end
@@ -78,7 +78,7 @@
7878
end
7979

8080
# C9938
81-
context "on #{osfamily} when specifying custom content" do
81+
context "when on #{osfamily} when specifying custom content" do
8282
let(:facts) do
8383
{ os: { family: osfamily } }.merge default_facts
8484
end
@@ -97,7 +97,7 @@
9797

9898
describe 'for linux operating systems' do
9999
['Debian', 'RedHat', 'Archlinux'].each do |osfamily|
100-
context "on #{osfamily} family operatingsystems" do
100+
context "when on #{osfamily} family operatingsystems" do
101101
let(:facts) do
102102
{ os: { family: osfamily } }.merge default_facts
103103
end
@@ -265,7 +265,7 @@
265265
end
266266
end
267267

268-
context "on #{osfamily} when specifying a restart_command" do
268+
context "when on #{osfamily} when specifying a restart_command" do
269269
let(:facts) do
270270
{ os: { family: osfamily } }.merge default_facts
271271
end
@@ -293,7 +293,7 @@
293293

294294
describe 'for OS-agnostic configuration' do
295295
['Debian', 'RedHat', 'Archlinux', 'FreeBSD'].each do |osfamily|
296-
context "on #{osfamily} family operatingsystems" do
296+
context "when on #{osfamily} family operatingsystems" do
297297
let(:facts) do
298298
{ os: { family: osfamily } }.merge default_facts
299299
end
@@ -331,7 +331,7 @@
331331
end
332332

333333
# C9938
334-
context "on #{osfamily} when specifying custom content" do
334+
context "when on #{osfamily} when specifying custom content" do
335335
let(:facts) do
336336
{ os: { family: osfamily } }.merge default_facts
337337
end
@@ -350,7 +350,7 @@
350350

351351
describe 'for linux operating systems' do
352352
['Debian', 'RedHat', 'Archlinux'].each do |osfamily|
353-
context "on #{osfamily} family operatingsystems" do
353+
context "when on #{osfamily} family operatingsystems" do
354354
let(:facts) do
355355
{ os: { family: osfamily } }.merge default_facts
356356
end
@@ -419,7 +419,7 @@
419419
end
420420
end
421421

422-
context "on #{osfamily} family operatingsystems without managing the service" do
422+
context "when on #{osfamily} family operatingsystems without managing the service" do
423423
let(:facts) do
424424
{ os: { family: osfamily } }.merge default_facts
425425
end
@@ -503,7 +503,7 @@
503503
end
504504
end
505505

506-
context "on #{osfamily} when specifying a restart_command" do
506+
context "when on #{osfamily} when specifying a restart_command" do
507507
let(:facts) do
508508
{ os: { family: osfamily } }.merge default_facts
509509
end

0 commit comments

Comments
 (0)