Skip to content

Commit ec5ec2d

Browse files
committed
rubocop: fix violations
1 parent 665f4dd commit ec5ec2d

19 files changed

+125
-44
lines changed

lib/facter/pip_version.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Make pip version available as a fact
24

35
def get_pip_version(executable)

lib/facter/python_release.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Make python release available as facts
24

35
def get_python_release(executable)

lib/facter/python_version.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Make python versions available as facts
24

35
def get_python_version(executable)

lib/facter/virtualenv_version.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Make virtualenv version available as a fact
24

35
Facter.add('virtualenv_version') do

spec/acceptance/class_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper_acceptance'
24

35
describe 'python class' do
@@ -28,10 +30,11 @@ class { 'python':
2830
apply_manifest(pp, catch_failures: true)
2931
apply_manifest(pp, catch_changes: true)
3032
end
33+
3134
fact_notices = <<-EOS
3235
notify{"pip_version: ${facts['pip3_version']}":}
3336
notify{"python_version: ${facts['python3_version']}":}
34-
EOS
37+
EOS
3538
it 'outputs python facts when not installed' do
3639
apply_manifest(fact_notices, catch_failures: true) do |r|
3740
expect(r.stdout).to match(%r{python_version: 3\.\S+})

spec/acceptance/facts_test_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper_acceptance'
24

35
describe 'python class' do
@@ -6,13 +8,13 @@
68
class { 'python' :
79
pip => 'present',
810
}
9-
EOS
11+
EOS
1012

1113
fact_notices = <<-EOS
1214
notify{"pip_version: ${facts['pip_version']}":}
1315
notify{"system_python_version: ${facts['system_python_version']}":}
1416
notify{"python_version: ${facts['python_version']}":}
15-
EOS
17+
EOS
1618

1719
# rubocop:disable RSpec/RepeatedExample
1820
it 'outputs python facts when not installed' do

spec/acceptance/pip_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper_acceptance'
24

35
describe 'python::pip defined resource' do
@@ -28,6 +30,7 @@ class { 'python':
2830
end
2931
end
3032

33+
# rubocop:disable RSpec/RepeatedExampleGroupDescription
3134
describe command('/opt/test-venv/bin/pip list') do
3235
its(:exit_status) { is_expected.to eq 0 }
3336
its(:stdout) { is_expected.to match %r{agent.* 0\.1\.2} }
@@ -71,4 +74,5 @@ class { 'python':
7174
its(:exit_status) { is_expected.to eq 0 }
7275
its(:stdout) { is_expected.not_to match %r{agent.* 0\.1\.2} }
7376
end
77+
# rubocop:enable RSpec/RepeatedExampleGroupDescription
7478
end

spec/acceptance/pyvenv_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper_acceptance'
24

35
describe 'python::pyvenv defined resource with python 3' do

spec/classes/python_spec.rb

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper'
24
describe 'python' do
35
on_supported_os.each do |os, facts|
46
next if os == 'gentoo-3-x86_64'
7+
58
context "on #{os}" do
69
let :facts do
710
facts
@@ -51,13 +54,15 @@
5154
end
5255
end
5356

57+
# rubocop:disable RSpec/RepeatedExampleGroupDescription
5458
describe 'with python::dev' do
5559
context 'true' do
5660
let(:params) { { dev: 'present' } }
5761

5862
it { is_expected.to compile.with_all_deps }
5963
it { is_expected.to contain_package('python-dev').with_ensure('present') }
6064
end
65+
6166
context 'empty/default' do
6267
it { is_expected.to compile.with_all_deps }
6368
it { is_expected.to contain_package('python-dev').with_ensure('absent') }
@@ -117,8 +122,9 @@
117122

118123
it { is_expected.to contain_python__pyvenv('/opt/env1').with_ensure('present') }
119124
it { is_expected.to contain_python__pyvenv('/opt/env2').with_ensure('present') }
125+
120126
it {
121-
is_expected.to contain_exec('python_virtualenv_/opt/env1').
127+
expect(subject).to contain_exec('python_virtualenv_/opt/env1').
122128
with(
123129
command: 'python3.8 -m venv --clear /opt/env1 && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade pip && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade setuptools',
124130
user: 'root',
@@ -132,12 +138,13 @@
132138
cwd: '/tmp',
133139
environment: [],
134140
timeout: 600,
135-
unless: %r{^grep '\^\[\\t \]\*VIRTUAL_ENV=\[\\\\'\\\"\]\*/opt/env1\[\\\"\\\\'\]\[\\t \]\*\$' /opt/env1/bin/activate$}
141+
unless: %r{^grep '\^\[\\t \]\*VIRTUAL_ENV=\[\\\\'\\"\]\*/opt/env1\[\\"\\\\'\]\[\\t \]\*\$' /opt/env1/bin/activate$}
136142
).
137143
that_requires('File[/opt/env1]')
138144
}
145+
139146
it {
140-
is_expected.to contain_exec('python_virtualenv_/opt/env2').
147+
expect(subject).to contain_exec('python_virtualenv_/opt/env2').
141148
with(
142149
command: 'python3.8 -m venv --clear /opt/env2 && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade \'pip <= 20.3.4\' && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade setuptools',
143150
user: 'root',
@@ -151,10 +158,11 @@
151158
cwd: '/tmp',
152159
environment: [],
153160
timeout: 600,
154-
unless: %r{^grep '\^\[\\t \]\*VIRTUAL_ENV=\[\\\\'\\\"\]\*/opt/env2\[\\\"\\\\'\]\[\\t \]\*\$' /opt/env2/bin/activate$}
161+
unless: %r{^grep '\^\[\\t \]\*VIRTUAL_ENV=\[\\\\'\\"\]\*/opt/env2\[\\"\\\\'\]\[\\t \]\*\$' /opt/env2/bin/activate$}
155162
).
156163
that_requires('File[/opt/env2]')
157164
}
165+
158166
it { is_expected.to contain_file('/opt/env1') }
159167
it { is_expected.to contain_file('/opt/env2') }
160168
end
@@ -166,10 +174,12 @@
166174

167175
it { is_expected.to contain_package('gunicorn') }
168176
end
177+
169178
context 'empty args' do
170179
# let(:params) {{ :manage_gunicorn => '' }}
171180
it { is_expected.to contain_package('gunicorn') }
172181
end
182+
173183
context 'false' do
174184
let(:params) { { manage_gunicorn: false } }
175185

@@ -198,6 +208,7 @@
198208

199209
it { is_expected.to contain_package('python-dev').with_ensure('present') }
200210
end
211+
201212
context 'default/empty' do
202213
it { is_expected.to contain_package('python-dev').with_ensure('absent') }
203214
end
@@ -246,10 +257,12 @@
246257

247258
it { is_expected.to contain_package('gunicorn').with_name('python-gunicorn') }
248259
end
260+
249261
context 'empty args' do
250262
# let(:params) {{ :manage_gunicorn => '' }}
251263
it { is_expected.to contain_package('gunicorn').with_name('python-gunicorn') }
252264
end
265+
253266
context 'false' do
254267
let(:params) { { manage_gunicorn: false } }
255268

@@ -265,19 +278,22 @@
265278

266279
it { is_expected.to compile.with_all_deps }
267280
end
281+
268282
context '3.6 SCL python package' do
269283
let(:params) { { version: 'rh-python36-python' } }
270284

271285
it { is_expected.to compile.with_all_deps }
272286
end
273287
end
288+
274289
describe 'with manage_scl' do
275290
context 'true' do
276291
let(:params) { { provider: 'scl', manage_scl: true } }
277292

278293
it { is_expected.to contain_package('centos-release-scl') }
279294
it { is_expected.to contain_package('scl-utils') }
280295
end
296+
281297
context 'false' do
282298
let(:params) { { provider: 'scl', manage_scl: false } }
283299

@@ -310,10 +326,12 @@
310326

311327
it { is_expected.to contain_package('gunicorn').with_name('python3-gunicorn') }
312328
end
329+
313330
context 'empty args' do
314331
# let(:params) {{ :manage_gunicorn => '' }}
315332
it { is_expected.to contain_package('gunicorn').with_name('python3-gunicorn') }
316333
end
334+
317335
context 'false' do
318336
let(:params) { { manage_gunicorn: false } }
319337

@@ -329,19 +347,22 @@
329347

330348
it { is_expected.to compile.with_all_deps }
331349
end
350+
332351
context '3.6 SCL python package' do
333352
let(:params) { { version: 'rh-python36-python' } }
334353

335354
it { is_expected.to compile.with_all_deps }
336355
end
337356
end
357+
338358
describe 'with manage_scl' do
339359
context 'true' do
340360
let(:params) { { provider: 'scl', manage_scl: true } }
341361

342362
it { is_expected.to contain_package('centos-release-scl') }
343363
it { is_expected.to contain_package('scl-utils') }
344364
end
365+
345366
context 'false' do
346367
let(:params) { { provider: 'scl', manage_scl: false } }
347368

@@ -371,6 +392,7 @@
371392

372393
it { is_expected.to contain_package('python-dev').with_ensure('present') }
373394
end
395+
374396
context 'empty/default' do
375397
it { is_expected.to contain_package('python-dev').with_ensure('absent') }
376398
end
@@ -382,10 +404,12 @@
382404

383405
it { is_expected.to contain_package('gunicorn') }
384406
end
407+
385408
context 'empty args' do
386409
# let(:params) {{ :manage_gunicorn => '' }}
387410
it { is_expected.to contain_package('gunicorn') }
388411
end
412+
389413
context 'false' do
390414
let(:params) { { manage_gunicorn: false } }
391415

@@ -398,7 +422,7 @@
398422
let(:params) { { provider: 'pip' } }
399423

400424
it {
401-
is_expected.to contain_package('pip').with(
425+
expect(subject).to contain_package('pip').with(
402426
'provider' => 'pip'
403427
)
404428
}
@@ -418,6 +442,7 @@
418442

419443
it { is_expected.to contain_package('python-dev').with_ensure('present') }
420444
end
445+
421446
context 'default/empty' do
422447
it { is_expected.to contain_package('python-dev').with_ensure('absent') }
423448
end
@@ -445,10 +470,12 @@
445470

446471
it { is_expected.to contain_package('gunicorn') }
447472
end
473+
448474
context 'empty args' do
449475
# let(:params) {{ :manage_gunicorn => '' }}
450476
it { is_expected.to contain_package('gunicorn') }
451477
end
478+
452479
context 'false' do
453480
let(:params) { { manage_gunicorn: false } }
454481

@@ -468,3 +495,4 @@
468495
end
469496
end
470497
end
498+
# rubocop:enable RSpec/RepeatedExampleGroupDescription

spec/defines/dotfile_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper'
24

35
describe 'python::dotfile', type: :define do
46
on_supported_os.each do |os, facts|
5-
context("on #{os} ") do
7+
context("on #{os}") do
68
let :facts do
79
facts
810
end
@@ -13,30 +15,35 @@
1315

1416
it { is_expected.to raise_error(%r{Evaluation Error: Empty string title at 0. Title strings must have a length greater than zero.}) }
1517
end
18+
1619
context 'fails with incorrect mode' do
1720
let(:title) { '/etc/pip.conf' }
1821
let(:params) { { mode: 'not-a-mode' } }
1922

2023
it { is_expected.to raise_error(%r{Evaluation Error: Error while evaluating a Resource}) }
2124
end
25+
2226
context 'succeeds with filename in existing path' do
2327
let(:title) { '/etc/pip.conf' }
2428

2529
it { is_expected.to contain_file('/etc/pip.conf').with_mode('0644') }
2630
end
31+
2732
context 'succeeds with filename in a non-existing path' do
2833
let(:title) { '/home/someuser/.pip/pip.conf' }
2934

3035
it { is_expected.to contain_exec('create /home/someuser/.pip/pip.conf\'s parent dir').with_command('install -o root -g root -d /home/someuser/.pip') }
3136
it { is_expected.to contain_file('/home/someuser/.pip/pip.conf').with_mode('0644') }
3237
end
38+
3339
context 'succeeds when set owner' do
3440
let(:title) { '/home/someuser/.pip/pip.conf' }
3541
let(:params) { { owner: 'someuser' } }
3642

3743
it { is_expected.to contain_exec('create /home/someuser/.pip/pip.conf\'s parent dir').with_command('install -o someuser -g root -d /home/someuser/.pip') }
3844
it { is_expected.to contain_file('/home/someuser/.pip/pip.conf').with_owner('someuser') }
3945
end
46+
4047
context 'succeeds when set group set' do
4148
let(:title) { '/home/someuser/.pip/pip.conf' }
4249
let(:params) { { group: 'somegroup' } }

0 commit comments

Comments
 (0)