(CONT-773) Rubocop Manual Fix 3 - Lint/ConstantDefinitionInBlock
authordavid22swan <david.swan@puppet.com>
Wed, 26 Apr 2023 16:09:00 +0000 (17:09 +0100)
committerdavid22swan <david.swan@puppet.com>
Wed, 26 Apr 2023 16:09:00 +0000 (17:09 +0100)
.rubocop_todo.yml
spec/defines/key_compat_spec.rb
spec/defines/source_compat_spec.rb
spec/defines/source_spec.rb

index fb3857b0362552813b571d3c34576ff433c26ef8..5c52997eb081137b1c9da84c47220c09329802a2 100644 (file)
@@ -6,15 +6,6 @@
 # Note that changes in the inspected code, or installation of new
 # versions of RuboCop, may require this file to be generated again.
 
-# Offense count: 3
-# Configuration parameters: AllowedMethods.
-# AllowedMethods: enums
-Lint/ConstantDefinitionInBlock:
-  Exclude:
-    - 'spec/defines/key_compat_spec.rb'
-    - 'spec/defines/source_compat_spec.rb'
-    - 'spec/defines/source_spec.rb'
-
 # Offense count: 6
 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
 Metrics/AbcSize:
index 4420337d19d46b9197620356c81d99eac56ed4ed..8a0972e72b6a7f6892b58491a44735946cc8fb95 100644 (file)
@@ -21,8 +21,8 @@ def apt_key_example(title)
 end
 
 describe 'apt::key', type: :define do
-  GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
-
+  let(:title) { '6F6B15509CF8E59E6E469F327F438280EF8D349F' }
+  let(:pre_condition) { 'include apt' }
   let(:facts) do
     {
       os: {
@@ -40,14 +40,6 @@ describe 'apt::key', type: :define do
     }
   end
 
-  let :title do
-    GPG_KEY_ID
-  end
-
-  let :pre_condition do
-    'include apt'
-  end
-
   describe 'normal operation' do
     describe 'default options' do
       it {
@@ -70,12 +62,12 @@ describe 'apt::key', type: :define do
 
       let :params do
         {
-          id: GPG_KEY_ID
+          id: title
         }
       end
 
       it 'contains the apt_key' do
-        expect(subject).to contain_apt_key(title).with(id: GPG_KEY_ID,
+        expect(subject).to contain_apt_key(title).with(id: title,
                                                        ensure: 'present',
                                                        source: nil,
                                                        server: 'keyserver.ubuntu.com',
@@ -83,7 +75,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'contains the apt_key present anchor' do
-        expect(subject).to contain_anchor("apt_key #{GPG_KEY_ID} present")
+        expect(subject).to contain_anchor("apt_key #{title} present")
       end
     end
 
index a414c493862c2067ea6d427eca24b986d803e815..55be585aa63918a02ceb5c7f649bbd5a8c8e3cc8 100644 (file)
@@ -3,12 +3,8 @@
 require 'spec_helper'
 
 describe 'apt::source', type: :define do
-  GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
-
-  let :title do
-    'my_source'
-  end
-
+  let(:id) { '6F6B15509CF8E59E6E469F327F438280EF8D349F' }
+  let(:title) { 'my_source' }
   let :facts do
     {
       os: {
@@ -47,7 +43,7 @@ describe 'apt::source', type: :define do
         'release' => 'sid',
         'repos' => 'testing',
         'include' => { 'src' => false },
-        'key' => GPG_KEY_ID,
+        'key' => id,
         'pin' => '10',
         'architecture' => 'x86_64',
         'allow_unsigned' => true
@@ -66,8 +62,8 @@ describe 'apt::source', type: :define do
     }
 
     it {
-      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',
-                                                                                                                                                      'id' => GPG_KEY_ID)
+      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',
+                                                                                                                                              'id' => id)
     }
   end
 
index 8cf9a453aa38188e78d66c2fbc9e0a02ff86c788..e9c0cf28af2d52205c9ffdc80c10ccaff31f544b 100644 (file)
@@ -3,16 +3,9 @@
 require 'spec_helper'
 
 describe 'apt::source' do
-  GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
-
-  let :pre_condition do
-    'class { "apt": }'
-  end
-
-  let :title do
-    'my_source'
-  end
-
+  let(:id) { '6F6B15509CF8E59E6E469F327F438280EF8D349F' }
+  let(:title) { 'my_source' }
+  let(:pre_condition) { 'class { "apt": }' }
   let :facts do
     {
       os: {
@@ -79,7 +72,7 @@ describe 'apt::source' do
           location: 'http://debian.mirror.iweb.ca/debian/',
           release: 'sid',
           repos: 'testing',
-          key: GPG_KEY_ID,
+          key: id,
           pin: '10',
           architecture: 'x86_64',
           allow_unsigned: true
@@ -98,8 +91,8 @@ describe 'apt::source' do
       }
 
       it {
-        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',
-                                                                                                                                                        id: GPG_KEY_ID)
+        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',
+                                                                                                                                                id: id)
       }
     end
 
@@ -112,7 +105,7 @@ describe 'apt::source' do
           repos: 'testing',
           key: {
             'ensure' => 'refreshed',
-            'id' => GPG_KEY_ID,
+            'id' => id,
             'server' => 'pgp.mit.edu',
             'content' => 'GPG key content',
             'source' => 'http://apt.puppetlabs.com/pubkey.gpg',
@@ -136,12 +129,12 @@ describe 'apt::source' do
       }
 
       it {
-        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',
-                                                                                                                                                        id: GPG_KEY_ID,
-                                                                                                                                                        server: 'pgp.mit.edu',
-                                                                                                                                                        content: 'GPG key content',
-                                                                                                                                                        source: 'http://apt.puppetlabs.com/pubkey.gpg',
-                                                                                                                                                        weak_ssl: true)
+        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',
+                                                                                                                                                id: GPG_KEY_ID,
+                                                                                                                                                server: 'pgp.mit.edu',
+                                                                                                                                                content: 'GPG key content',
+                                                                                                                                                source: 'http://apt.puppetlabs.com/pubkey.gpg',
+                                                                                                                                                weak_ssl: true)
       }
     end
   end