Skip to content

Commit 55fa371

Browse files
committed
(CONT-772) Correct RSpec/ImplicitSubject
1 parent 8081069 commit 55fa371

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+362
-363
lines changed

.rubocop_todo.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-04-20 08:33:47 UTC using RuboCop version 1.48.1.
3+
# on 2023-04-20 10:23:43 UTC using RuboCop version 1.48.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -90,15 +90,8 @@ RSpec/FilePath:
9090
- 'spec/classes/mod/lookup_identity.rb'
9191
- 'spec/classes/mod/proxy_wstunnel.rb'
9292

93-
# Offense count: 292
94-
# This cop supports safe autocorrection (--autocorrect).
95-
# Configuration parameters: EnforcedStyle.
96-
# SupportedStyles: single_line_only, single_statement_only, disallow, require_implicit
97-
RSpec/ImplicitSubject:
98-
Enabled: false
99-
10093
# Offense count: 16
101-
# This cop supports safe autocorrection.
94+
# This cop supports safe autocorrection (--autocorrect).
10295
RSpec/LetBeforeExamples:
10396
Exclude:
10497
- 'spec/classes/mod/auth_kerb_spec.rb'
@@ -120,6 +113,12 @@ RSpec/MultipleExpectations:
120113
RSpec/MultipleMemoizedHelpers:
121114
Max: 6
122115

116+
# Offense count: 291
117+
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
118+
# SupportedStyles: always, named_only
119+
RSpec/NamedSubject:
120+
Enabled: false
121+
123122
# Offense count: 123
124123
# Configuration parameters: AllowedGroups.
125124
RSpec/NestedGroups:

spec/classes/apache_spec.rb

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
it { is_expected.to contain_class('apache::params') }
1010

1111
it {
12-
is_expected.to contain_package('httpd').with(
12+
expect(subject).to contain_package('httpd').with(
1313
'notify' => 'Class[Apache::Service]',
1414
'ensure' => 'installed',
1515
)
@@ -20,27 +20,27 @@
2020
it { is_expected.to contain_class('apache::service') }
2121

2222
it {
23-
is_expected.to contain_file('/var/www/html').with(
23+
expect(subject).to contain_file('/var/www/html').with(
2424
'ensure' => 'directory',
2525
)
2626
}
2727

2828
it {
29-
is_expected.to contain_file('/etc/apache2/sites-enabled').with(
29+
expect(subject).to contain_file('/etc/apache2/sites-enabled').with(
3030
'ensure' => 'directory', 'recurse' => 'true',
3131
'purge' => 'true'
3232
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
3333
}
3434

3535
it {
36-
is_expected.to contain_file('/etc/apache2/mods-enabled').with(
36+
expect(subject).to contain_file('/etc/apache2/mods-enabled').with(
3737
'ensure' => 'directory', 'recurse' => 'true',
3838
'purge' => 'true'
3939
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
4040
}
4141

4242
it {
43-
is_expected.to contain_file('/etc/apache2/mods-available').with(
43+
expect(subject).to contain_file('/etc/apache2/mods-available').with(
4444
'ensure' => 'directory', 'recurse' => 'true',
4545
'purge' => 'false'
4646
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
@@ -49,7 +49,7 @@
4949
it { is_expected.to contain_file('/etc/apache2/apache2.conf').without_content(%r{ServerAdmin}) }
5050

5151
it {
52-
is_expected.to contain_concat('/etc/apache2/ports.conf').with(
52+
expect(subject).to contain_concat('/etc/apache2/ports.conf').with(
5353
'owner' => 'root', 'group' => 'root',
5454
'mode' => '0644'
5555
).that_notifies('Class[Apache::Service]')
@@ -58,14 +58,14 @@
5858
# Assert that load files are placed and symlinked for these mods, but no conf file.
5959
['auth_basic', 'authn_file', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname|
6060
it {
61-
is_expected.to contain_file("#{modname}.load").with(
61+
expect(subject).to contain_file("#{modname}.load").with(
6262
'path' => "/etc/apache2/mods-available/#{modname}.load",
6363
'ensure' => 'file',
6464
)
6565
}
6666

6767
it {
68-
is_expected.to contain_file("#{modname}.load symlink").with(
68+
expect(subject).to contain_file("#{modname}.load symlink").with(
6969
'path' => "/etc/apache2/mods-enabled/#{modname}.load",
7070
'ensure' => 'link',
7171
'target' => "/etc/apache2/mods-available/#{modname}.load",
@@ -131,29 +131,29 @@
131131
# Assert that both load files and conf files are placed and symlinked for these mods
132132
['alias', 'autoindex', 'dav_fs', 'deflate', 'dir', 'mime', 'negotiation', 'setenvif'].each do |modname|
133133
it {
134-
is_expected.to contain_file("#{modname}.load").with(
134+
expect(subject).to contain_file("#{modname}.load").with(
135135
'path' => "/etc/apache2/mods-available/#{modname}.load",
136136
'ensure' => 'file',
137137
)
138138
}
139139

140140
it {
141-
is_expected.to contain_file("#{modname}.load symlink").with(
141+
expect(subject).to contain_file("#{modname}.load symlink").with(
142142
'path' => "/etc/apache2/mods-enabled/#{modname}.load",
143143
'ensure' => 'link',
144144
'target' => "/etc/apache2/mods-available/#{modname}.load",
145145
)
146146
}
147147

148148
it {
149-
is_expected.to contain_file("#{modname}.conf").with(
149+
expect(subject).to contain_file("#{modname}.conf").with(
150150
'path' => "/etc/apache2/mods-available/#{modname}.conf",
151151
'ensure' => 'file',
152152
)
153153
}
154154

155155
it {
156-
is_expected.to contain_file("#{modname}.conf symlink").with(
156+
expect(subject).to contain_file("#{modname}.conf symlink").with(
157157
'path' => "/etc/apache2/mods-enabled/#{modname}.conf",
158158
'ensure' => 'link',
159159
'target' => "/etc/apache2/mods-available/#{modname}.conf",
@@ -210,13 +210,13 @@
210210
]
211211
it 'Expected to contain' do
212212
expected.each do |reg|
213-
is_expected.to contain_file('/etc/apache2/apache2.conf').with_content reg
213+
expect(subject).to contain_file('/etc/apache2/apache2.conf').with_content reg
214214
end
215215
end
216216

217217
it 'Not expected to contain' do
218218
unexpected.each do |reg|
219-
is_expected.to contain_file('/etc/apache2/apache2.conf').without_content reg
219+
expect(subject).to contain_file('/etc/apache2/apache2.conf').without_content reg
220220
end
221221
end
222222
end
@@ -234,7 +234,7 @@
234234
include_examples 'Ubuntu 18.04'
235235

236236
it {
237-
is_expected.to contain_file('/var/www/html').with(
237+
expect(subject).to contain_file('/var/www/html').with(
238238
'ensure' => 'directory',
239239
)
240240
}
@@ -247,7 +247,7 @@
247247
it { is_expected.to contain_class('apache::params') }
248248

249249
it {
250-
is_expected.to contain_package('httpd').with(
250+
expect(subject).to contain_package('httpd').with(
251251
'notify' => 'Class[Apache::Service]',
252252
'ensure' => 'installed',
253253
)
@@ -258,20 +258,20 @@
258258
it { is_expected.to contain_class('apache::service') }
259259

260260
it {
261-
is_expected.to contain_file('/var/www/html').with(
261+
expect(subject).to contain_file('/var/www/html').with(
262262
'ensure' => 'directory',
263263
)
264264
}
265265

266266
it {
267-
is_expected.to contain_file('/etc/httpd/conf.d').with(
267+
expect(subject).to contain_file('/etc/httpd/conf.d').with(
268268
'ensure' => 'directory', 'recurse' => 'true',
269269
'purge' => 'true'
270270
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
271271
}
272272

273273
it {
274-
is_expected.to contain_concat('/etc/httpd/conf/ports.conf').with(
274+
expect(subject).to contain_concat('/etc/httpd/conf/ports.conf').with(
275275
'owner' => 'root', 'group' => 'root',
276276
'mode' => '0644'
277277
).that_notifies('Class[Apache::Service]')
@@ -288,7 +288,7 @@
288288

289289
['mod.d', 'site.d', 'conf.d'].each do |dir|
290290
it {
291-
is_expected.to contain_file("/etc/httpd/#{dir}").with(
291+
expect(subject).to contain_file("/etc/httpd/#{dir}").with(
292292
'ensure' => 'directory', 'recurse' => 'true',
293293
'purge' => 'true'
294294
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
@@ -298,13 +298,13 @@
298298
# Assert that load files are placed for these mods, but no conf file.
299299
['auth_basic', 'authn_file', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname|
300300
it {
301-
is_expected.to contain_file("#{modname}.load").with_path(
301+
expect(subject).to contain_file("#{modname}.load").with_path(
302302
"/etc/httpd/mod.d/#{modname}.load",
303303
)
304304
}
305305

306306
it {
307-
is_expected.not_to contain_file("#{modname}.conf").with_path(
307+
expect(subject).not_to contain_file("#{modname}.conf").with_path(
308308
"/etc/httpd/mod.d/#{modname}.conf",
309309
)
310310
}
@@ -313,13 +313,13 @@
313313
# Assert that both load files and conf files are placed for these mods
314314
['alias', 'autoindex', 'dav_fs', 'deflate', 'dir', 'mime', 'negotiation', 'setenvif'].each do |modname|
315315
it {
316-
is_expected.to contain_file("#{modname}.load").with_path(
316+
expect(subject).to contain_file("#{modname}.load").with_path(
317317
"/etc/httpd/mod.d/#{modname}.load",
318318
)
319319
}
320320

321321
it {
322-
is_expected.to contain_file("#{modname}.conf").with_path(
322+
expect(subject).to contain_file("#{modname}.conf").with_path(
323323
"/etc/httpd/mod.d/#{modname}.conf",
324324
)
325325
}
@@ -375,7 +375,7 @@
375375
end
376376

377377
it {
378-
is_expected.to contain_file('/opt/rh/root/etc/httpd/conf/httpd.conf').with(
378+
expect(subject).to contain_file('/opt/rh/root/etc/httpd/conf/httpd.conf').with(
379379
'ensure' => 'file',
380380
).that_notifies('Class[Apache::Service]').that_requires(['Package[httpd]', 'Concat[/etc/httpd/conf/ports.conf]'])
381381
}
@@ -387,7 +387,7 @@
387387
end
388388

389389
it {
390-
is_expected.to contain_file('/etc/httpd/special_conf.d').with(
390+
expect(subject).to contain_file('/etc/httpd/special_conf.d').with(
391391
'ensure' => 'directory', 'recurse' => 'true',
392392
'purge' => 'true'
393393
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
@@ -402,7 +402,7 @@
402402
unexpected = ['apache::mod::event', 'apache::mod::itk', 'apache::mod::peruser', 'apache::mod::prefork', 'apache::mod::worker']
403403
it 'does not declare mpm modules' do
404404
unexpected.each do |not_expect|
405-
is_expected.not_to contain_class(not_expect)
405+
expect(subject).not_to contain_class(not_expect)
406406
end
407407
end
408408
end
@@ -560,27 +560,27 @@
560560
it { is_expected.to contain_class('apache::service') }
561561

562562
it {
563-
is_expected.to contain_file('/usr/local/www/apache24/data').with(
563+
expect(subject).to contain_file('/usr/local/www/apache24/data').with(
564564
'ensure' => 'directory',
565565
)
566566
}
567567

568568
it {
569-
is_expected.to contain_file('/usr/local/etc/apache24/Vhosts').with(
569+
expect(subject).to contain_file('/usr/local/etc/apache24/Vhosts').with(
570570
'ensure' => 'directory', 'recurse' => 'true',
571571
'purge' => 'true'
572572
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
573573
}
574574

575575
it {
576-
is_expected.to contain_file('/usr/local/etc/apache24/Modules').with(
576+
expect(subject).to contain_file('/usr/local/etc/apache24/Modules').with(
577577
'ensure' => 'directory', 'recurse' => 'true',
578578
'purge' => 'true'
579579
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
580580
}
581581

582582
it {
583-
is_expected.to contain_concat('/usr/local/etc/apache24/ports.conf').with(
583+
expect(subject).to contain_concat('/usr/local/etc/apache24/ports.conf').with(
584584
'owner' => 'root', 'group' => 'wheel',
585585
'mode' => '0644'
586586
).that_notifies('Class[Apache::Service]')
@@ -589,7 +589,7 @@
589589
# Assert that load files are placed for these mods, but no conf file.
590590
['auth_basic', 'authn_core', 'authn_file', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname|
591591
it {
592-
is_expected.to contain_file("#{modname}.load").with(
592+
expect(subject).to contain_file("#{modname}.load").with(
593593
'path' => "/usr/local/etc/apache24/Modules/#{modname}.load",
594594
'ensure' => 'file',
595595
)
@@ -601,14 +601,14 @@
601601
# Assert that both load files and conf files are placed for these mods
602602
['alias', 'autoindex', 'dav_fs', 'deflate', 'dir', 'mime', 'negotiation', 'setenvif'].each do |modname|
603603
it {
604-
is_expected.to contain_file("#{modname}.load").with(
604+
expect(subject).to contain_file("#{modname}.load").with(
605605
'path' => "/usr/local/etc/apache24/Modules/#{modname}.load",
606606
'ensure' => 'file',
607607
)
608608
}
609609

610610
it {
611-
is_expected.to contain_file("#{modname}.conf").with(
611+
expect(subject).to contain_file("#{modname}.conf").with(
612612
'path' => "/usr/local/etc/apache24/Modules/#{modname}.conf",
613613
'ensure' => 'file',
614614
)
@@ -625,27 +625,27 @@
625625
it { is_expected.to contain_class('apache::service') }
626626

627627
it {
628-
is_expected.to contain_file('/var/www/localhost/htdocs').with(
628+
expect(subject).to contain_file('/var/www/localhost/htdocs').with(
629629
'ensure' => 'directory',
630630
)
631631
}
632632

633633
it {
634-
is_expected.to contain_file('/etc/apache2/vhosts.d').with(
634+
expect(subject).to contain_file('/etc/apache2/vhosts.d').with(
635635
'ensure' => 'directory', 'recurse' => 'true',
636636
'purge' => 'true'
637637
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
638638
}
639639

640640
it {
641-
is_expected.to contain_file('/etc/apache2/modules.d').with(
641+
expect(subject).to contain_file('/etc/apache2/modules.d').with(
642642
'ensure' => 'directory', 'recurse' => 'true',
643643
'purge' => 'true'
644644
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
645645
}
646646

647647
it {
648-
is_expected.to contain_concat('/etc/apache2/ports.conf').with(
648+
expect(subject).to contain_concat('/etc/apache2/ports.conf').with(
649649
'owner' => 'root', 'group' => 'wheel',
650650
'mode' => '0644'
651651
).that_notifies('Class[Apache::Service]')
@@ -663,7 +663,7 @@
663663
end
664664

665665
it {
666-
is_expected.to contain_package('httpd').with(
666+
expect(subject).to contain_package('httpd').with(
667667
'ensure' => 'installed',
668668
'name' => 'httpd24-httpd',
669669
).that_notifies('Class[Apache::Service]')
@@ -678,7 +678,7 @@
678678
end
679679

680680
it {
681-
is_expected.to contain_concat('/etc/httpd/conf/ports.conf').with(
681+
expect(subject).to contain_concat('/etc/httpd/conf/ports.conf').with(
682682
'mode' => '0640',
683683
)
684684
}

spec/classes/mod/auth_cas_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
it { is_expected.to contain_file('/var/cache/mod_auth_cas/').with_owner('apache') }
6767

6868
it {
69-
is_expected.to contain_concat__fragment('test.server-auth_cas').with(content: %r{^\s+CASRootProxiedAs http://test.server$})
70-
is_expected.to contain_concat__fragment('test.server-auth_cas').with(content: %r{^\s+CASCookiePath /my/cas/path$})
69+
expect(subject).to contain_concat__fragment('test.server-auth_cas').with(content: %r{^\s+CASRootProxiedAs http://test.server$})
70+
expect(subject).to contain_concat__fragment('test.server-auth_cas').with(content: %r{^\s+CASCookiePath /my/cas/path$})
7171
}
7272
end
7373
end

spec/classes/mod/auth_openidc_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
it { is_expected.to contain_package('mod_auth_openidc') }
3636

3737
it do
38-
is_expected.to contain_package('dnf-module-mod_auth_openidc')
38+
expect(subject).to contain_package('dnf-module-mod_auth_openidc')
3939
.with_ensure('present')
4040
.with_name('mod_auth_openidc')
4141
.that_comes_before('Package[mod_auth_openidc]')

0 commit comments

Comments
 (0)