Skip to content

Commit 9450621

Browse files
committed
(CONT-773) Rubocop Manual Fix 3 - Lint/ConstantDefinitionInBlock
1 parent 8a7fc62 commit 9450621

File tree

4 files changed

+23
-51
lines changed

4 files changed

+23
-51
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@
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: 3
10-
# Configuration parameters: AllowedMethods.
11-
# AllowedMethods: enums
12-
Lint/ConstantDefinitionInBlock:
13-
Exclude:
14-
- 'spec/defines/key_compat_spec.rb'
15-
- 'spec/defines/source_compat_spec.rb'
16-
- 'spec/defines/source_spec.rb'
17-
189
# Offense count: 6
1910
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
2011
Metrics/AbcSize:

spec/defines/key_compat_spec.rb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def apt_key_example(title)
2121
end
2222

2323
describe 'apt::key', type: :define do
24-
GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
25-
24+
let(:title) { '6F6B15509CF8E59E6E469F327F438280EF8D349F' }
25+
let(:pre_condition) { 'include apt' }
2626
let(:facts) do
2727
{
2828
os: {
@@ -40,14 +40,6 @@ def apt_key_example(title)
4040
}
4141
end
4242

43-
let :title do
44-
GPG_KEY_ID
45-
end
46-
47-
let :pre_condition do
48-
'include apt'
49-
end
50-
5143
describe 'normal operation' do
5244
describe 'default options' do
5345
it {
@@ -70,20 +62,20 @@ def apt_key_example(title)
7062

7163
let :params do
7264
{
73-
id: GPG_KEY_ID
65+
id: title
7466
}
7567
end
7668

7769
it 'contains the apt_key' do
78-
expect(subject).to contain_apt_key(title).with(id: GPG_KEY_ID,
70+
expect(subject).to contain_apt_key(title).with(id: title,
7971
ensure: 'present',
8072
source: nil,
8173
server: 'keyserver.ubuntu.com',
8274
content: nil)
8375
end
8476

8577
it 'contains the apt_key present anchor' do
86-
expect(subject).to contain_anchor("apt_key #{GPG_KEY_ID} present")
78+
expect(subject).to contain_anchor("apt_key #{title} present")
8779
end
8880
end
8981

spec/defines/source_compat_spec.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
require 'spec_helper'
44

55
describe 'apt::source', type: :define do
6-
GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
7-
8-
let :title do
9-
'my_source'
10-
end
11-
6+
let(:id) { '6F6B15509CF8E59E6E469F327F438280EF8D349F' }
7+
let(:title) { 'my_source' }
128
let :facts do
139
{
1410
os: {
@@ -47,7 +43,7 @@
4743
'release' => 'sid',
4844
'repos' => 'testing',
4945
'include' => { 'src' => false },
50-
'key' => GPG_KEY_ID,
46+
'key' => id,
5147
'pin' => '10',
5248
'architecture' => 'x86_64',
5349
'allow_unsigned' => true
@@ -66,8 +62,8 @@
6662
}
6763

6864
it {
69-
expect(subject).to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
70-
'id' => GPG_KEY_ID)
65+
expect(subject).to contain_apt__key("Add key: #{id} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
66+
'id' => id)
7167
}
7268
end
7369

spec/defines/source_spec.rb

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,9 @@
33
require 'spec_helper'
44

55
describe 'apt::source' do
6-
GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
7-
8-
let :pre_condition do
9-
'class { "apt": }'
10-
end
11-
12-
let :title do
13-
'my_source'
14-
end
15-
6+
let(:id) { '6F6B15509CF8E59E6E469F327F438280EF8D349F' }
7+
let(:title) { 'my_source' }
8+
let(:pre_condition) { 'class { "apt": }' }
169
let :facts do
1710
{
1811
os: {
@@ -79,7 +72,7 @@
7972
location: 'http://debian.mirror.iweb.ca/debian/',
8073
release: 'sid',
8174
repos: 'testing',
82-
key: GPG_KEY_ID,
75+
key: id,
8376
pin: '10',
8477
architecture: 'x86_64',
8578
allow_unsigned: true
@@ -98,8 +91,8 @@
9891
}
9992

10093
it {
101-
expect(subject).to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
102-
id: GPG_KEY_ID)
94+
expect(subject).to contain_apt__key("Add key: #{id} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
95+
id: id)
10396
}
10497
end
10598

@@ -112,7 +105,7 @@
112105
repos: 'testing',
113106
key: {
114107
'ensure' => 'refreshed',
115-
'id' => GPG_KEY_ID,
108+
'id' => id,
116109
'server' => 'pgp.mit.edu',
117110
'content' => 'GPG key content',
118111
'source' => 'http://apt.puppetlabs.com/pubkey.gpg',
@@ -136,12 +129,12 @@
136129
}
137130

138131
it {
139-
expect(subject).to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'refreshed',
140-
id: GPG_KEY_ID,
141-
server: 'pgp.mit.edu',
142-
content: 'GPG key content',
143-
source: 'http://apt.puppetlabs.com/pubkey.gpg',
144-
weak_ssl: true)
132+
expect(subject).to contain_apt__key("Add key: #{id} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'refreshed',
133+
id: GPG_KEY_ID,
134+
server: 'pgp.mit.edu',
135+
content: 'GPG key content',
136+
source: 'http://apt.puppetlabs.com/pubkey.gpg',
137+
weak_ssl: true)
145138
}
146139
end
147140
end

0 commit comments

Comments
 (0)