(CONT-773) Rubocop Auto Fixes 11-15
authordavid22swan <david.swan@puppet.com>
Fri, 21 Apr 2023 12:48:27 +0000 (13:48 +0100)
committerdavid22swan <david.swan@puppet.com>
Fri, 21 Apr 2023 12:48:27 +0000 (13:48 +0100)
- RSpec/ExampleWording
- RSpec/ImplicitSubject
- Style/IfUnlessModifier
- Style/QuotedSymbols
- Style/RedundantRegexpEscape

18 files changed:
.rubocop_todo.yml
lib/facter/apt_updates.rb
lib/puppet/provider/apt_key/apt_key.rb
lib/puppet/type/apt_key.rb
spec/classes/apt_backports_spec.rb
spec/classes/apt_spec.rb
spec/classes/apt_update_spec.rb
spec/defines/conf_spec.rb
spec/defines/key_compat_spec.rb
spec/defines/key_spec.rb
spec/defines/mark_spec.rb
spec/defines/pin_spec.rb
spec/defines/ppa_spec.rb
spec/defines/setting_spec.rb
spec/defines/source_compat_spec.rb
spec/defines/source_spec.rb
spec/unit/facter/apt_update_last_success_spec.rb
spec/unit/puppet/provider/apt_key_spec.rb

index 5ae1290b5aa48272274b13715919d4fb34217fcf..a088dced4b2bd7d15dcd85cb5e5044a4b0dcef7f 100644 (file)
@@ -1,6 +1,6 @@
 # This configuration was generated by
 # `rubocop --auto-gen-config`
-# on 2023-04-21 09:13:34 UTC using RuboCop version 1.48.1.
+# on 2023-04-21 12:46:34 UTC using RuboCop version 1.48.1.
 # The point is for the user to remove these configuration records
 # one by one as the offenses are removed from the code base.
 # Note that changes in the inspected code, or installation of new
@@ -87,18 +87,22 @@ RSpec/ExampleWording:
   Exclude:
     - 'spec/acceptance/apt_key_provider_spec.rb'
 
-# Offense count: 2
-# This cop supports safe autocorrection (--autocorrect).
-RSpec/ExcessiveDocstringSpacing:
+# Offense count: 3
+RSpec/LeakyConstantDeclaration:
   Exclude:
     - 'spec/defines/key_compat_spec.rb'
-    - 'spec/defines/setting_spec.rb'
+    - 'spec/defines/source_compat_spec.rb'
+    - 'spec/defines/source_spec.rb'
+
+# Offense count: 3
+# Configuration parameters: AllowSubject.
+RSpec/MultipleMemoizedHelpers:
+  Max: 6
 
 # Offense count: 204
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: single_line_only, single_statement_only, disallow, require_implicit
-RSpec/ImplicitSubject:
+# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
+# SupportedStyles: always, named_only
+RSpec/NamedSubject:
   Exclude:
     - 'spec/classes/apt_backports_spec.rb'
     - 'spec/classes/apt_spec.rb'
@@ -114,18 +118,6 @@ RSpec/ImplicitSubject:
     - 'spec/defines/source_spec.rb'
     - 'spec/unit/facter/apt_update_last_success_spec.rb'
 
-# Offense count: 3
-RSpec/LeakyConstantDeclaration:
-  Exclude:
-    - 'spec/defines/key_compat_spec.rb'
-    - 'spec/defines/source_compat_spec.rb'
-    - 'spec/defines/source_spec.rb'
-
-# Offense count: 3
-# Configuration parameters: AllowSubject.
-RSpec/MultipleMemoizedHelpers:
-  Max: 6
-
 # Offense count: 2
 # Configuration parameters: AllowedGroups.
 RSpec/NestedGroups:
@@ -170,33 +162,11 @@ Style/GlobalStdStream:
   Exclude:
     - 'tasks/init.rb'
 
-# Offense count: 10
-# This cop supports safe autocorrection (--autocorrect).
-Style/IfUnlessModifier:
-  Exclude:
-    - 'lib/facter/apt_updates.rb'
-    - 'lib/puppet/provider/apt_key/apt_key.rb'
-    - 'lib/puppet/type/apt_key.rb'
-
 # Offense count: 1
 Style/MixinUsage:
   Exclude:
     - 'spec/spec_helper.rb'
 
-# Offense count: 3
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: same_as_string_literals, single_quotes, double_quotes
-Style/QuotedSymbols:
-  Exclude:
-    - 'spec/unit/puppet/provider/apt_key_spec.rb'
-
-# Offense count: 4
-# This cop supports safe autocorrection (--autocorrect).
-Style/RedundantRegexpEscape:
-  Exclude:
-    - 'lib/puppet/type/apt_key.rb'
-
 # Offense count: 1
 # This cop supports safe autocorrection (--autocorrect).
 # Configuration parameters: EnforcedStyle.
index 3b46e2d63d696adc243bab33e895bec673b901be..66c6a892867be4b15161f41cc84aad3ea9ca0510 100644 (file)
@@ -23,9 +23,7 @@ def get_updates(upgrade_option)
           %r{ gNewSense[^\s]+-security[, ]},
         ]
         re = Regexp.union(security_matches)
-        if line.match(re)
-          apt_updates[1].push(package)
-        end
+        apt_updates[1].push(package) if line.match(re)
       end
     end
   end
@@ -36,9 +34,7 @@ Facter.add('apt_has_updates') do
   confine osfamily: 'Debian'
   setcode do
     apt_package_updates = get_updates('upgrade')
-    if !apt_package_updates.nil? && apt_package_updates.length == 2
-      apt_package_updates != [[], []]
-    end
+    apt_package_updates != [[], []] if !apt_package_updates.nil? && apt_package_updates.length == 2
   end
 end
 
@@ -46,9 +42,7 @@ Facter.add('apt_has_dist_updates') do
   confine osfamily: 'Debian'
   setcode do
     apt_dist_updates = get_updates('dist-upgrade')
-    if !apt_dist_updates.nil? && apt_dist_updates.length == 2
-      apt_dist_updates != [[], []]
-    end
+    apt_dist_updates != [[], []] if !apt_dist_updates.nil? && apt_dist_updates.length == 2
   end
 end
 
index 9f461cc62cafa9f79049982bce65dac1090127db..c91e26ecb6666992d6c50bf310d43a1177268cce 100644 (file)
@@ -49,9 +49,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
 
       expired = false
 
-      if line_hash[:key_expiry]
-        expired = Time.now >= line_hash[:key_expiry]
-      end
+      expired = Time.now >= line_hash[:key_expiry] if line_hash[:key_expiry]
 
       new(
         name: line_hash[:key_fingerprint],
@@ -171,9 +169,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
 
         found_match = false
         extracted_key.each_line do |line|
-          if line.chomp == name
-            found_match = true
-          end
+          found_match = true if line.chomp == name
         end
         unless found_match
           raise(_('The id in your manifest %{_resource} and the fingerprint from content/source don\'t match. Check for an error in the id and content/source is legitimate.') % { _resource: resource[:name] }) # rubocop:disable Layout/LineLength
@@ -196,9 +192,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
       # Breaking up the command like this is needed because it blows up
       # if --recv-keys isn't the last argument.
       command.push('adv', '--no-tty', '--keyserver', resource[:server])
-      unless resource[:options].nil?
-        command.push('--keyserver-options', resource[:options])
-      end
+      command.push('--keyserver-options', resource[:options]) unless resource[:options].nil?
       command.push('--recv-keys', resource[:id])
     elsif resource[:content]
       key_file = tempfile(resource[:content])
index 99be930e28b8e51ff47af87c2e568a33bb55f463..faa430be4263132488fd3448f27733b0990b8a2a 100644 (file)
@@ -25,16 +25,10 @@ Puppet::Type.newtype(:apt_key) do
   ensurable
 
   validate do
-    if self[:refresh] == true && self[:ensure] == :absent
-      raise(_('ensure => absent and refresh => true are mutually exclusive'))
-    end
-    if self[:content] && self[:source]
-      raise(_('The properties content and source are mutually exclusive.'))
-    end
+    raise(_('ensure => absent and refresh => true are mutually exclusive')) if self[:refresh] == true && self[:ensure] == :absent
+    raise(_('The properties content and source are mutually exclusive.')) if self[:content] && self[:source]
 
-    if self[:id].length < 40
-      warning(_('The id should be a full fingerprint (40 characters), see README.'))
-    end
+    warning(_('The id should be a full fingerprint (40 characters), see README.')) if self[:id].length < 40
   end
 
   newparam(:id, namevar: true) do
@@ -62,16 +56,14 @@ Puppet::Type.newtype(:apt_key) do
   end
 
   autorequire(:file) do
-    if self[:source] && Pathname.new(self[:source]).absolute?
-      self[:source]
-    end
+    self[:source] if self[:source] && Pathname.new(self[:source]).absolute?
   end
 
   newparam(:server) do
     desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.'
     defaultto :'keyserver.ubuntu.com'
 
-    newvalues(%r{\A((hkp|hkps|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?(\/[a-zA-Z\d\-_.]+)*\/?$})
+    newvalues(%r{\A((hkp|hkps|http|https)://)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?(/[a-zA-Z\d\-_.]+)*/?$})
   end
 
   newparam(:options) do
index 2ae8429478775dc4c55f2eee0e5089365710fe09..bfe4a252dfe7f19d773b5945e9760f9831ec5af6 100644 (file)
@@ -25,10 +25,10 @@ describe 'apt::backports', type: :class do
       end
 
       it {
-        is_expected.to contain_apt__source('backports').with(location: 'http://deb.debian.org/debian',
-                                                             repos: 'main contrib non-free',
-                                                             release: 'stretch-backports',
-                                                             pin: { 'priority' => 200, 'release' => 'stretch-backports' })
+        expect(subject).to contain_apt__source('backports').with(location: 'http://deb.debian.org/debian',
+                                                                 repos: 'main contrib non-free',
+                                                                 release: 'stretch-backports',
+                                                                 pin: { 'priority' => 200, 'release' => 'stretch-backports' })
       }
     end
 
@@ -51,11 +51,11 @@ describe 'apt::backports', type: :class do
       end
 
       it {
-        is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
-                                                             key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
-                                                             repos: 'main universe multiverse restricted',
-                                                             release: 'bionac-backports',
-                                                             pin: { 'priority' => 200, 'release' => 'bionac-backports' })
+        expect(subject).to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
+                                                                 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
+                                                                 repos: 'main universe multiverse restricted',
+                                                                 release: 'bionac-backports',
+                                                                 pin: { 'priority' => 200, 'release' => 'bionac-backports' })
       }
     end
 
@@ -87,11 +87,11 @@ describe 'apt::backports', type: :class do
       end
 
       it {
-        is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu-test',
-                                                             key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
-                                                             repos: 'main',
-                                                             release: 'vivid',
-                                                             pin: { 'priority' => 90, 'release' => 'vivid' })
+        expect(subject).to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu-test',
+                                                                 key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
+                                                                 repos: 'main',
+                                                                 release: 'vivid',
+                                                                 pin: { 'priority' => 90, 'release' => 'vivid' })
       }
     end
 
@@ -124,8 +124,8 @@ describe 'apt::backports', type: :class do
       end
 
       it {
-        is_expected.to contain_apt__source('backports').with(key: { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' },
-                                                             pin: { 'priority' => '90' })
+        expect(subject).to contain_apt__source('backports').with(key: { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' },
+                                                                 pin: { 'priority' => '90' })
       }
     end
   end
@@ -159,11 +159,11 @@ describe 'apt::backports', type: :class do
       end
 
       it {
-        is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
-                                                             key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
-                                                             repos: 'main universe multiverse restricted',
-                                                             release: 'trusty-backports',
-                                                             pin: { 'priority' => 200, 'release' => 'trusty-backports' })
+        expect(subject).to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
+                                                                 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
+                                                                 repos: 'main universe multiverse restricted',
+                                                                 release: 'trusty-backports',
+                                                                 pin: { 'priority' => 200, 'release' => 'trusty-backports' })
       }
     end
 
@@ -177,7 +177,7 @@ describe 'apt::backports', type: :class do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
+        expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
       end
     end
 
@@ -191,7 +191,7 @@ describe 'apt::backports', type: :class do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
+        expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
       end
     end
 
@@ -205,7 +205,7 @@ describe 'apt::backports', type: :class do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
+        expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
       end
     end
 
@@ -219,7 +219,7 @@ describe 'apt::backports', type: :class do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
+        expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
       end
     end
   end
@@ -250,7 +250,7 @@ describe 'apt::backports', type: :class do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{expects a})
+        expect(subject).to raise_error(Puppet::Error, %r{expects a})
       end
     end
 
@@ -262,7 +262,7 @@ describe 'apt::backports', type: :class do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{expects a})
+        expect(subject).to raise_error(Puppet::Error, %r{expects a})
       end
     end
 
@@ -274,7 +274,7 @@ describe 'apt::backports', type: :class do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{expects a})
+        expect(subject).to raise_error(Puppet::Error, %r{expects a})
       end
     end
 
@@ -286,7 +286,7 @@ describe 'apt::backports', type: :class do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{expects a})
+        expect(subject).to raise_error(Puppet::Error, %r{expects a})
       end
     end
 
@@ -298,7 +298,7 @@ describe 'apt::backports', type: :class do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{expects a})
+        expect(subject).to raise_error(Puppet::Error, %r{expects a})
       end
     end
   end
index afd7797049bede5b7e25c2691aab66a8d0c0434b..65ae50b2aa664a6383613eb362bbab1579923bf8 100644 (file)
@@ -58,36 +58,36 @@ describe 'apt' do
 
   context 'with defaults' do
     it {
-      is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with(sources_list)
+      expect(subject).to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with(sources_list)
     }
 
     it {
-      is_expected.to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with(sources_list_d)
+      expect(subject).to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with(sources_list_d)
     }
 
     it {
-      is_expected.to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with(preferences)
+      expect(subject).to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with(preferences)
     }
 
     it {
-      is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with(preferences_d)
+      expect(subject).to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with(preferences_d)
     }
 
     it {
-      is_expected.to contain_file('apt.conf.d').that_notifies('Class[Apt::Update]').only_with(apt_conf_d)
+      expect(subject).to contain_file('apt.conf.d').that_notifies('Class[Apt::Update]').only_with(apt_conf_d)
     }
 
     it { is_expected.to contain_file('/etc/apt/auth.conf').with_ensure('absent') }
 
     it 'lays down /etc/apt/apt.conf.d/15update-stamp' do
-      is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with(group: 'root',
-                                                                             owner: 'root').with_content(
-                                                                               %r{APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};},
-                                                                             )
+      expect(subject).to contain_file('/etc/apt/apt.conf.d/15update-stamp').with(group: 'root',
+                                                                                 owner: 'root').with_content(
+                                                                                   %r{APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};},
+                                                                                 )
     end
 
     it {
-      is_expected.to contain_exec('apt_update').with(refreshonly: 'true')
+      expect(subject).to contain_exec('apt_update').with(refreshonly: 'true')
     }
 
     it { is_expected.not_to contain_apt__setting('conf-proxy') }
@@ -98,7 +98,7 @@ describe 'apt' do
       let(:params) { { proxy: { 'host' => 'localhost' } } }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+        expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
           %r{Acquire::http::proxy "http://localhost:8080/";},
         ).without_content(
           %r{Acquire::https::proxy },
@@ -110,7 +110,7 @@ describe 'apt' do
       let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'host' => 'proxyhost' }] } } }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+        expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
           %r{Acquire::http::proxy::proxyscope "http://proxyhost:8080/";},
         )
       }
@@ -120,7 +120,7 @@ describe 'apt' do
       let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'host' => 'proxyhost', 'port' => 8081 }] } } }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+        expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
           %r{Acquire::http::proxy::proxyscope "http://proxyhost:8081/";},
         )
       }
@@ -130,7 +130,7 @@ describe 'apt' do
       let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'host' => 'proxyhost', 'https' => true }] } } }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+        expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
           %r{Acquire::https::proxy::proxyscope "https://proxyhost:8080/";},
         )
       }
@@ -140,7 +140,7 @@ describe 'apt' do
       let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'direct' => true }] } } }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+        expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
           %r{Acquire::http::proxy::proxyscope "DIRECT";},
         )
       }
@@ -150,7 +150,7 @@ describe 'apt' do
       let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'https' => true, 'direct' => true }] } } }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+        expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
           %r{Acquire::https::proxy::proxyscope "DIRECT";},
         )
       }
@@ -160,7 +160,7 @@ describe 'apt' do
       let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'host' => 'proxyhost' }, { 'scope' => 'proxyscope2', 'host' => 'proxyhost2' }] } } }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+        expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
           %r{Acquire::http::proxy::proxyscope "http://proxyhost:8080/";},
         ).with_content(
           %r{Acquire::http::proxy::proxyscope2 "http://proxyhost2:8080/";},
@@ -172,7 +172,7 @@ describe 'apt' do
       let(:params) { { proxy: { 'host' => 'localhost', 'port' => 8180 } } }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+        expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
           %r{Acquire::http::proxy "http://localhost:8180/";},
         ).without_content(
           %r{Acquire::https::proxy },
@@ -184,7 +184,7 @@ describe 'apt' do
       let(:params) { { proxy: { 'host' => 'localhost', 'https' => true } } }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+        expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
           %r{Acquire::http::proxy "http://localhost:8080/";},
         ).with_content(
           %r{Acquire::https::proxy "https://localhost:8080/";},
@@ -196,7 +196,7 @@ describe 'apt' do
       let(:params) { { proxy: { 'host' => 'localhost', 'direct' => true } } }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+        expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
           %r{Acquire::http::proxy "http://localhost:8080/";},
         ).with_content(
           %r{Acquire::https::proxy "DIRECT";},
@@ -208,7 +208,7 @@ describe 'apt' do
       let(:params) { { proxy: { 'host' => 'localhost', 'https' => true, 'direct' => true } } }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+        expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
           %r{Acquire::http::proxy "http://localhost:8080/";},
         ).with_content(
           %r{Acquire::https::proxy "https://localhost:8080/";},
@@ -216,7 +216,7 @@ describe 'apt' do
       }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+        expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
           %r{Acquire::http::proxy "http://localhost:8080/";},
         ).without_content(
           %r{Acquire::https::proxy "DIRECT";},
@@ -228,8 +228,8 @@ describe 'apt' do
       let(:params) { { proxy: { 'ensure' => 'absent' } } }
 
       it {
-        is_expected.to contain_apt__setting('conf-proxy').with(ensure: 'absent',
-                                                               priority: '01')
+        expect(subject).to contain_apt__setting('conf-proxy').with(ensure: 'absent',
+                                                                   priority: '01')
       }
     end
   end
@@ -245,32 +245,32 @@ describe 'apt' do
     end
 
     it {
-      is_expected.to contain_file('sources.list').with(content: nil)
+      expect(subject).to contain_file('sources.list').with(content: nil)
     }
 
     it {
-      is_expected.to contain_file('sources.list.d').with(purge: false,
-                                                         recurse: false)
+      expect(subject).to contain_file('sources.list.d').with(purge: false,
+                                                             recurse: false)
     }
 
     it {
-      is_expected.to contain_file('preferences').with(ensure: 'file')
+      expect(subject).to contain_file('preferences').with(ensure: 'file')
     }
 
     it {
-      is_expected.to contain_file('preferences.d').with(purge: false,
-                                                        recurse: false)
+      expect(subject).to contain_file('preferences.d').with(purge: false,
+                                                            recurse: false)
     }
 
     it {
-      is_expected.to contain_file('apt.conf.d').with(purge: false,
-                                                     recurse: false)
+      expect(subject).to contain_file('apt.conf.d').with(purge: false,
+                                                         recurse: false)
     }
 
     it {
-      is_expected.to contain_exec('apt_update').with(refreshonly: false,
-                                                     timeout: 1,
-                                                     tries: 3)
+      expect(subject).to contain_exec('apt_update').with(refreshonly: false,
+                                                         timeout: 1,
+                                                         tries: 3)
     }
   end
 
@@ -285,32 +285,32 @@ describe 'apt' do
     end
 
     it {
-      is_expected.to contain_file('sources.list').with(content: "# Repos managed by puppet.\n")
+      expect(subject).to contain_file('sources.list').with(content: "# Repos managed by puppet.\n")
     }
 
     it {
-      is_expected.to contain_file('sources.list.d').with(purge: true,
-                                                         recurse: true)
+      expect(subject).to contain_file('sources.list.d').with(purge: true,
+                                                             recurse: true)
     }
 
     it {
-      is_expected.to contain_file('preferences').with(ensure: 'absent')
+      expect(subject).to contain_file('preferences').with(ensure: 'absent')
     }
 
     it {
-      is_expected.to contain_file('preferences.d').with(purge: true,
-                                                        recurse: true)
+      expect(subject).to contain_file('preferences.d').with(purge: true,
+                                                            recurse: true)
     }
 
     it {
-      is_expected.to contain_file('apt.conf.d').with(purge: true,
-                                                     recurse: true)
+      expect(subject).to contain_file('apt.conf.d').with(purge: true,
+                                                         recurse: true)
     }
 
     it {
-      is_expected.to contain_exec('apt_update').with(refreshonly: false,
-                                                     timeout: 1,
-                                                     tries: 3)
+      expect(subject).to contain_exec('apt_update').with(refreshonly: false,
+                                                         timeout: 1,
+                                                         tries: 3)
     }
   end
 
@@ -324,7 +324,7 @@ describe 'apt' do
     end
 
     it {
-      is_expected.to contain_file('sources.list').with(content: "# Repos managed by puppet.\n")
+      expect(subject).to contain_file('sources.list').with(content: "# Repos managed by puppet.\n")
     }
   end
 
@@ -338,7 +338,7 @@ describe 'apt' do
     end
 
     it {
-      is_expected.to contain_file('sources.list').with(ensure: 'absent')
+      expect(subject).to contain_file('sources.list').with(ensure: 'absent')
     }
   end
 
@@ -421,12 +421,12 @@ machine apt.example.com login aptlogin password supersecret
 "
 
           it {
-            is_expected.to contain_file('/etc/apt/auth.conf').with(ensure: 'present',
-                                                                   owner: '_apt',
-                                                                   group: 'root',
-                                                                   mode: '0600',
-                                                                   notify: 'Class[Apt::Update]',
-                                                                   content: sensitive(auth_conf_content))
+            expect(subject).to contain_file('/etc/apt/auth.conf').with(ensure: 'present',
+                                                                       owner: '_apt',
+                                                                       group: 'root',
+                                                                       mode: '0600',
+                                                                       notify: 'Class[Apt::Update]',
+                                                                       content: sensitive(auth_conf_content))
           }
         end
 
@@ -436,7 +436,7 @@ machine apt.example.com login aptlogin password supersecret
           end
 
           it {
-            is_expected.not_to contain_file('/etc/apt/auth.conf')
+            expect(subject).not_to contain_file('/etc/apt/auth.conf')
           }
         end
       end
@@ -500,14 +500,14 @@ machine apt.example.com login aptlogin password supersecret
     end
 
     it {
-      is_expected.to contain_apt__setting('list-debian_unstable').with(ensure: 'present')
+      expect(subject).to contain_apt__setting('list-debian_unstable').with(ensure: 'present')
     }
 
     it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(%r{^deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free$}) }
     it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(%r{^deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free$}) }
 
     it {
-      is_expected.to contain_apt__setting('list-puppetlabs').with(ensure: 'present')
+      expect(subject).to contain_apt__setting('list-puppetlabs').with(ensure: 'present')
     }
 
     it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(%r{^deb http://apt.puppetlabs.com bionic main$}) }
@@ -542,11 +542,11 @@ machine apt.example.com login aptlogin password supersecret
     end
 
     it {
-      is_expected.to contain_apt__conf('foo').with(content: 'foo')
+      expect(subject).to contain_apt__conf('foo').with(content: 'foo')
     }
 
     it {
-      is_expected.to contain_apt__conf('bar').with(content: 'bar')
+      expect(subject).to contain_apt__conf('bar').with(content: 'bar')
     }
   end
 
@@ -579,11 +579,11 @@ machine apt.example.com login aptlogin password supersecret
     end
 
     it {
-      is_expected.to contain_apt__key('55BE302B').with(server: 'subkeys.pgp.net')
+      expect(subject).to contain_apt__key('55BE302B').with(server: 'subkeys.pgp.net')
     }
 
     it {
-      is_expected.to contain_apt__key('EF8D349F').with(server: 'pgp.mit.edu')
+      expect(subject).to contain_apt__key('EF8D349F').with(server: 'pgp.mit.edu')
     }
   end
 
@@ -676,7 +676,7 @@ machine apt.example.com login aptlogin password supersecret
       let(:params) { { purge: { 'sources.list' => 'banana' } } }
 
       it do
-        is_expected.to raise_error(Puppet::Error)
+        expect(subject).to raise_error(Puppet::Error)
       end
     end
 
@@ -684,7 +684,7 @@ machine apt.example.com login aptlogin password supersecret
       let(:params) { { purge: { 'sources.list.d' => 'banana' } } }
 
       it do
-        is_expected.to raise_error(Puppet::Error)
+        expect(subject).to raise_error(Puppet::Error)
       end
     end
 
@@ -692,7 +692,7 @@ machine apt.example.com login aptlogin password supersecret
       let(:params) { { purge: { 'preferences' => 'banana' } } }
 
       it do
-        is_expected.to raise_error(Puppet::Error)
+        expect(subject).to raise_error(Puppet::Error)
       end
     end
 
@@ -700,7 +700,7 @@ machine apt.example.com login aptlogin password supersecret
       let(:params) { { purge: { 'preferences.d' => 'banana' } } }
 
       it do
-        is_expected.to raise_error(Puppet::Error)
+        expect(subject).to raise_error(Puppet::Error)
       end
     end
 
@@ -708,7 +708,7 @@ machine apt.example.com login aptlogin password supersecret
       let(:params) { { purge: { 'apt.conf.d' => 'banana' } } }
 
       it do
-        is_expected.to raise_error(Puppet::Error)
+        expect(subject).to raise_error(Puppet::Error)
       end
     end
   end
index 5a73eb45ec65736dabe20c47113142a560f7edc2..61335fda20296b2f70c374b686e0ff5478a08eeb 100644 (file)
@@ -33,7 +33,7 @@ describe 'apt::update', type: :class do
 
         it 'triggers an apt-get update run' do
           # set the apt_update exec's refreshonly attribute to false
-          is_expected.to contain_exec('apt_update').with('refreshonly' => false)
+          expect(subject).to contain_exec('apt_update').with('refreshonly' => false)
         end
       end
     end
@@ -58,7 +58,7 @@ describe 'apt::update', type: :class do
 
       it 'triggers an apt-get update run' do
         # set the apt_update exec\'s refreshonly attribute to false
-        is_expected.to contain_exec('apt_update').with('refreshonly' => false)
+        expect(subject).to contain_exec('apt_update').with('refreshonly' => false)
       end
     end
 
@@ -89,7 +89,7 @@ describe 'apt::update', type: :class do
 
       it 'skips an apt-get update run' do
         # set the apt_update exec's refreshonly attribute to false
-        is_expected.to contain_exec('apt_update').with('refreshonly' => true)
+        expect(subject).to contain_exec('apt_update').with('refreshonly' => true)
       end
     end
   end
@@ -122,7 +122,7 @@ describe 'apt::update', type: :class do
 
         it 'does not trigger an apt-get update run' do
           # don't change the apt_update exec's refreshonly attribute. (it should be true)
-          is_expected.to contain_exec('apt_update').with('refreshonly' => true)
+          expect(subject).to contain_exec('apt_update').with('refreshonly' => true)
         end
       end
     end
@@ -147,7 +147,7 @@ describe 'apt::update', type: :class do
 
       it 'does not trigger an apt-get update run' do
         # don't change the apt_update exec's refreshonly attribute. (it should be true)
-        is_expected.to contain_exec('apt_update').with('refreshonly' => true)
+        expect(subject).to contain_exec('apt_update').with('refreshonly' => true)
       end
     end
   end
@@ -177,7 +177,7 @@ describe 'apt::update', type: :class do
 
           it 'triggers an apt-get update run' do
             # set the apt_update exec\'s refreshonly attribute to false
-            is_expected.to contain_exec('apt_update').with('refreshonly' => false)
+            expect(subject).to contain_exec('apt_update').with('refreshonly' => false)
           end
         end
       end
@@ -203,7 +203,7 @@ describe 'apt::update', type: :class do
 
         it 'does not trigger an apt-get update run' do
           # don't change the apt_update exec\'s refreshonly attribute. (it should be true)
-          is_expected.to contain_exec('apt_update').with('refreshonly' => true)
+          expect(subject).to contain_exec('apt_update').with('refreshonly' => true)
         end
       end
 
@@ -229,7 +229,7 @@ describe 'apt::update', type: :class do
 
         it 'triggers an apt-get update run' do
           # set the apt_update exec\'s refreshonly attribute to false
-          is_expected.to contain_exec('apt_update').with('refreshonly' => false)
+          expect(subject).to contain_exec('apt_update').with('refreshonly' => false)
         end
       end
     end
index 04551b8e5dfe326668428cc4009534d281cd8630..b08cc0f395fc98d0b43ed72d2690b7e93856bc4c 100644 (file)
@@ -41,10 +41,10 @@ describe 'apt::conf', type: :define do
     end
 
     it {
-      is_expected.to contain_file(filename).with('ensure' => 'present',
-                                                 'content' => %r{Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;},
-                                                 'owner' => 'root',
-                                                 'group' => 'root')
+      expect(subject).to contain_file(filename).with('ensure' => 'present',
+                                                     'content' => %r{Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;},
+                                                     'owner' => 'root',
+                                                     'group' => 'root')
     }
 
     context 'with notify_update = true (default)' do
@@ -72,7 +72,7 @@ describe 'apt::conf', type: :define do
     end
 
     it 'fails' do
-      is_expected.to raise_error(%r{pass in content})
+      expect(subject).to raise_error(%r{pass in content})
     end
   end
 
@@ -89,9 +89,9 @@ describe 'apt::conf', type: :define do
     end
 
     it {
-      is_expected.to contain_file(filename).with('ensure' => 'absent',
-                                                 'owner' => 'root',
-                                                 'group' => 'root')
+      expect(subject).to contain_file(filename).with('ensure' => 'absent',
+                                                     'owner' => 'root',
+                                                     'group' => 'root')
     }
   end
 end
index ab305a99d37dc3adb9201802f727df40a1a4bfaa..f414503ac3f341d6a5fcaef7b4ba1121b39030df 100644 (file)
@@ -51,15 +51,15 @@ describe 'apt::key', type: :define do
   describe 'normal operation' do
     describe 'default options' do
       it {
-        is_expected.to contain_apt_key(title).with(id: title,
-                                                   ensure: 'present',
-                                                   source: nil,
-                                                   server: 'keyserver.ubuntu.com',
-                                                   content: nil)
+        expect(subject).to contain_apt_key(title).with(id: title,
+                                                       ensure: 'present',
+                                                       source: nil,
+                                                       server: 'keyserver.ubuntu.com',
+                                                       content: nil)
       }
 
       it 'contains the apt_key present anchor' do
-        is_expected.to contain_anchor("apt_key #{title} present")
+        expect(subject).to contain_anchor("apt_key #{title} present")
       end
     end
 
@@ -75,15 +75,15 @@ describe 'apt::key', type: :define do
       end
 
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(id: GPG_KEY_ID,
-                                                   ensure: 'present',
-                                                   source: nil,
-                                                   server: 'keyserver.ubuntu.com',
-                                                   content: nil)
+        expect(subject).to contain_apt_key(title).with(id: GPG_KEY_ID,
+                                                       ensure: 'present',
+                                                       source: nil,
+                                                       server: 'keyserver.ubuntu.com',
+                                                       content: nil)
       end
 
       it 'contains the apt_key present anchor' do
-        is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present")
+        expect(subject).to contain_anchor("apt_key #{GPG_KEY_ID} present")
       end
     end
 
@@ -95,15 +95,15 @@ describe 'apt::key', type: :define do
       end
 
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(id: title,
-                                                   ensure: 'absent',
-                                                   source: nil,
-                                                   server: 'keyserver.ubuntu.com',
-                                                   content: nil)
+        expect(subject).to contain_apt_key(title).with(id: title,
+                                                       ensure: 'absent',
+                                                       source: nil,
+                                                       server: 'keyserver.ubuntu.com',
+                                                       content: nil)
       end
 
       it 'contains the apt_key absent anchor' do
-        is_expected.to contain_anchor("apt_key #{title} absent")
+        expect(subject).to contain_anchor("apt_key #{title} absent")
       end
     end
 
@@ -118,11 +118,11 @@ describe 'apt::key', type: :define do
       end
 
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(contains_apt_key_example(title))
+        expect(subject).to contain_apt_key(title).with(contains_apt_key_example(title))
       end
 
       it 'contains the apt_key present anchor' do
-        is_expected.to contain_anchor("apt_key #{title} present")
+        expect(subject).to contain_anchor("apt_key #{title} present")
       end
     end
 
@@ -134,8 +134,8 @@ describe 'apt::key', type: :define do
       end
 
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(id: title,
-                                                   server: 'p-gp.m-it.edu')
+        expect(subject).to contain_apt_key(title).with(id: title,
+                                                       server: 'p-gp.m-it.edu')
       end
     end
 
@@ -147,8 +147,8 @@ describe 'apt::key', type: :define do
       end
 
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(id: title,
-                                                   server: 'hkp://pgp.mit.edu')
+        expect(subject).to contain_apt_key(title).with(id: title,
+                                                       server: 'hkp://pgp.mit.edu')
       end
     end
 
@@ -160,8 +160,8 @@ describe 'apt::key', type: :define do
       end
 
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(id: title,
-                                                   server: 'hkp://pgp.mit.edu:80')
+        expect(subject).to contain_apt_key(title).with(id: title,
+                                                       server: 'hkp://pgp.mit.edu:80')
       end
     end
   end
@@ -175,7 +175,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -187,7 +187,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -199,7 +199,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -211,7 +211,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -223,11 +223,11 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
-    context 'with incorrect protocol for  url' do
+    context 'with incorrect protocol for url' do
       let :params do
         {
           server: 'abc://pgp.mit.edu:80',
@@ -235,7 +235,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -247,7 +247,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -259,7 +259,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -271,7 +271,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -281,7 +281,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -293,7 +293,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{evaluating a Resource})
+        expect(subject).to raise_error(%r{evaluating a Resource})
       end
     end
 
@@ -305,7 +305,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a})
+        expect(subject).to raise_error(%r{expects a})
       end
     end
 
@@ -317,7 +317,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -329,7 +329,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a})
+        expect(subject).to raise_error(%r{expects a})
       end
     end
 
@@ -341,7 +341,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{Enum\['absent', 'present', 'refreshed'\]})
+        expect(subject).to raise_error(%r{Enum\['absent', 'present', 'refreshed'\]})
       end
     end
 
@@ -351,21 +351,21 @@ describe 'apt::key', type: :define do
       end
 
       it 'contains the duplicate apt::key resource' do
-        is_expected.to contain_apt__key('duplicate').with(id: title,
-                                                          ensure: 'present')
+        expect(subject).to contain_apt__key('duplicate').with(id: title,
+                                                              ensure: 'present')
       end
 
       it 'contains the original apt::key resource' do
-        is_expected.to contain_apt__key(title).with(id: title,
-                                                    ensure: 'present')
+        expect(subject).to contain_apt__key(title).with(id: title,
+                                                        ensure: 'present')
       end
 
       it 'contains the native apt_key' do
-        is_expected.to contain_apt_key('duplicate').with(apt_key_example(title))
+        expect(subject).to contain_apt_key('duplicate').with(apt_key_example(title))
       end
 
       it 'does not contain the original apt_key' do
-        is_expected.not_to contain_apt_key(title)
+        expect(subject).not_to contain_apt_key(title)
       end
     end
 
@@ -375,7 +375,7 @@ describe 'apt::key', type: :define do
       end
 
       it 'informs the user of the impossibility' do
-        is_expected.to raise_error(%r{already ensured as absent})
+        expect(subject).to raise_error(%r{already ensured as absent})
       end
     end
   end
index 956c9b68dd896eaa6ad216e818b95a32b750edf4..948833a3fd837b26eb9ae3f5b375ea95c1a6fec4 100644 (file)
@@ -68,11 +68,11 @@ describe 'apt::key' do
   describe 'normal operation' do
     describe 'default options' do
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(default_apt_key_example(title))
+        expect(subject).to contain_apt_key(title).with(default_apt_key_example(title))
       end
 
       it 'contains the apt_key present anchor' do
-        is_expected.to contain_anchor("apt_key #{title} present")
+        expect(subject).to contain_anchor("apt_key #{title} present")
       end
     end
 
@@ -88,11 +88,11 @@ describe 'apt::key' do
       end
 
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(title_key_example)
+        expect(subject).to contain_apt_key(title).with(title_key_example)
       end
 
       it 'contains the apt_key present anchor' do
-        is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present")
+        expect(subject).to contain_anchor("apt_key #{GPG_KEY_ID} present")
       end
     end
 
@@ -104,11 +104,11 @@ describe 'apt::key' do
       end
 
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(absent_apt_key(title))
+        expect(subject).to contain_apt_key(title).with(absent_apt_key(title))
       end
 
       it 'contains the apt_key absent anchor' do
-        is_expected.to contain_anchor("apt_key #{title} absent")
+        expect(subject).to contain_anchor("apt_key #{title} absent")
       end
     end
 
@@ -120,7 +120,7 @@ describe 'apt::key' do
       end
 
       it 'contains the apt_key with refresh => true' do
-        is_expected.to contain_apt_key(title).with(
+        expect(subject).to contain_apt_key(title).with(
           ensure: 'present',
           refresh: true,
         )
@@ -138,11 +138,11 @@ describe 'apt::key' do
       end
 
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(bunch_things_apt_key_example(title, params))
+        expect(subject).to contain_apt_key(title).with(bunch_things_apt_key_example(title, params))
       end
 
       it 'contains the apt_key present anchor' do
-        is_expected.to contain_anchor("apt_key #{title} present")
+        expect(subject).to contain_anchor("apt_key #{title} present")
       end
     end
 
@@ -154,8 +154,8 @@ describe 'apt::key' do
       end
 
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(id: title,
-                                                   server: 'p-gp.m-it.edu')
+        expect(subject).to contain_apt_key(title).with(id: title,
+                                                       server: 'p-gp.m-it.edu')
       end
     end
 
@@ -167,8 +167,8 @@ describe 'apt::key' do
       end
 
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(id: title,
-                                                   server: 'hkp://pgp.mit.edu')
+        expect(subject).to contain_apt_key(title).with(id: title,
+                                                       server: 'hkp://pgp.mit.edu')
       end
     end
 
@@ -180,8 +180,8 @@ describe 'apt::key' do
       end
 
       it 'contains the apt_key' do
-        is_expected.to contain_apt_key(title).with(id: title,
-                                                   server: 'hkp://pgp.mit.edu:80')
+        expect(subject).to contain_apt_key(title).with(id: title,
+                                                       server: 'hkp://pgp.mit.edu:80')
       end
     end
   end
@@ -195,7 +195,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -207,7 +207,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -219,7 +219,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -231,7 +231,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -243,7 +243,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -255,7 +255,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -267,7 +267,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -279,7 +279,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -291,7 +291,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -301,7 +301,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -313,7 +313,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{evaluating a Resource})
+        expect(subject).to raise_error(%r{evaluating a Resource})
       end
     end
 
@@ -325,7 +325,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a})
+        expect(subject).to raise_error(%r{expects a})
       end
     end
 
@@ -337,7 +337,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a match})
+        expect(subject).to raise_error(%r{expects a match})
       end
     end
 
@@ -349,7 +349,7 @@ describe 'apt::key' do
       end
 
       it 'fails' do
-        is_expected.to raise_error(%r{expects a})
+        expect(subject).to raise_error(%r{expects a})
       end
     end
 
@@ -362,7 +362,7 @@ describe 'apt::key' do
         end
 
         it 'fails' do
-          is_expected.to raise_error(%r{for Enum\['absent', 'present', 'refreshed'\], got})
+          expect(subject).to raise_error(%r{for Enum\['absent', 'present', 'refreshed'\], got})
         end
       end
     end
@@ -374,21 +374,21 @@ describe 'apt::key' do
       end
 
       it 'contains two apt::key resource - duplicate' do
-        is_expected.to contain_apt__key('duplicate').with(id: title,
-                                                          ensure: 'present')
+        expect(subject).to contain_apt__key('duplicate').with(id: title,
+                                                              ensure: 'present')
       end
 
       it 'contains two apt::key resource - title' do
-        is_expected.to contain_apt__key(title).with(id: title,
-                                                    ensure: 'present')
+        expect(subject).to contain_apt__key(title).with(id: title,
+                                                        ensure: 'present')
       end
 
       it 'contains only a single apt_key - duplicate' do
-        is_expected.to contain_apt_key('duplicate').with(default_apt_key_example(title))
+        expect(subject).to contain_apt_key('duplicate').with(default_apt_key_example(title))
       end
 
       it 'contains only a single apt_key - no title' do
-        is_expected.not_to contain_apt_key(title)
+        expect(subject).not_to contain_apt_key(title)
       end
     end
 
@@ -399,7 +399,7 @@ describe 'apt::key' do
       end
 
       it 'informs the user of the impossibility' do
-        is_expected.to raise_error(%r{already ensured as absent})
+        expect(subject).to raise_error(%r{already ensured as absent})
       end
     end
   end
@@ -413,7 +413,7 @@ describe 'apt::key' do
       end
 
       it 'uses default keyserver' do
-        is_expected.to contain_apt_key(title).with_server('keyserver.example.com')
+        expect(subject).to contain_apt_key(title).with_server('keyserver.example.com')
       end
     end
 
@@ -425,7 +425,7 @@ describe 'apt::key' do
       end
 
       it 'uses default keyserver' do
-        is_expected.to contain_apt_key(title).with_options('http-proxy=http://proxy.example.com:8080')
+        expect(subject).to contain_apt_key(title).with_options('http-proxy=http://proxy.example.com:8080')
       end
     end
   end
index 5375fe236f4e8c9ca3eb7cc564373f40372837ef..cdff673a9e561a1680d53b383cc9506798378a2d 100644 (file)
@@ -32,7 +32,7 @@ describe 'apt::mark', type: :define do
     end
 
     it {
-      is_expected.to contain_exec('apt-mark manual mysource')
+      expect(subject).to contain_exec('apt-mark manual mysource')
     }
   end
 
@@ -44,7 +44,7 @@ describe 'apt::mark', type: :define do
     end
 
     it do
-      is_expected.to raise_error(Puppet::PreformattedError, %r{expects a match for Enum\['auto', 'hold', 'manual', 'unhold'\], got 'foobar'})
+      expect(subject).to raise_error(Puppet::PreformattedError, %r{expects a match for Enum\['auto', 'hold', 'manual', 'unhold'\], got 'foobar'})
     end
   end
 
@@ -70,7 +70,7 @@ describe 'apt::mark', type: :define do
       end
 
       it do
-        is_expected.to contain_exec("apt-mark manual #{title}")
+        expect(subject).to contain_exec("apt-mark manual #{title}")
       end
     end
   end
@@ -99,7 +99,7 @@ describe 'apt::mark', type: :define do
       end
 
       it do
-        is_expected.to raise_error(Puppet::PreformattedError, %r{Invalid package name: #{title}})
+        expect(subject).to raise_error(Puppet::PreformattedError, %r{Invalid package name: #{title}})
       end
     end
   end
index 8b30a4c770d9bc620b2e4a865f32487c70dfed54..bd2c26287b9ff85d2cb1e813126f8ba1eb358d78 100644 (file)
@@ -67,7 +67,7 @@ describe 'apt::pin', type: :define do
     it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n}) }
 
     it {
-      is_expected.to contain_apt__setting('pref-my_pin').with('priority' => 99)
+      expect(subject).to contain_apt__setting('pref-my_pin').with('priority' => 99)
     }
   end
 
@@ -79,7 +79,7 @@ describe 'apt::pin', type: :define do
     end
 
     it {
-      is_expected.to contain_apt__setting('pref-my_pin').with('ensure' => 'absent')
+      expect(subject).to contain_apt__setting('pref-my_pin').with('ensure' => 'absent')
     }
   end
 
@@ -98,7 +98,7 @@ describe 'apt::pin', type: :define do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{expects an Integer value, got String})
+        expect(subject).to raise_error(Puppet::Error, %r{expects an Integer value, got String})
       end
     end
 
@@ -110,7 +110,7 @@ describe 'apt::pin', type: :define do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{parameter version cannot be used in general form})
+        expect(subject).to raise_error(Puppet::Error, %r{parameter version cannot be used in general form})
       end
     end
 
@@ -123,7 +123,7 @@ describe 'apt::pin', type: :define do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{parameters release and origin are mutually exclusive})
+        expect(subject).to raise_error(Puppet::Error, %r{parameters release and origin are mutually exclusive})
       end
     end
 
@@ -137,7 +137,7 @@ describe 'apt::pin', type: :define do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive})
+        expect(subject).to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive})
       end
     end
 
@@ -151,7 +151,7 @@ describe 'apt::pin', type: :define do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive})
+        expect(subject).to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive})
       end
     end
   end
index 4732350e84d79ffc92327cb77adc723e668210e6..3d109aed7550ded0ffed612c9be9c6d33f1ff2fd 100644 (file)
@@ -39,7 +39,7 @@ describe 'apt::ppa' do
     it { is_expected.not_to contain_package('python-software-properties') }
 
     it {
-      is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution')
+      expect(subject).to contain_exec('add-apt-repository-ppa:needs/substitution')
         .that_notifies('Class[Apt::Update]')
         .with(*ppa_exec_params('needs', 'substitution'))
     }
@@ -130,7 +130,7 @@ describe 'apt::ppa' do
     let(:title) { 'ppa:user/foo' }
 
     it {
-      is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
+      expect(subject).to contain_exec('add-apt-repository-ppa:user/foo')
         .that_notifies('Class[Apt::Update]')
         .with(*ppa_exec_params('user', 'foo', 'wily'))
     }
@@ -171,7 +171,7 @@ describe 'apt::ppa' do
     it { is_expected.to contain_package('software-properties-common') }
 
     it {
-      is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution')
+      expect(subject).to contain_exec('add-apt-repository-ppa:needs/substitution')
         .that_notifies('Class[Apt::Update]')
         .with(*ppa_exec_params('needs', 'substitution'))
     }
@@ -211,7 +211,7 @@ describe 'apt::ppa' do
     it { is_expected.not_to contain_package('python-software-properties') }
 
     it {
-      is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution')
+      expect(subject).to contain_exec('add-apt-repository-ppa:needs/substitution')
         .that_notifies('Class[Apt::Update]')
         .with(*ppa_exec_params('needs', 'substitution'))
     }
@@ -255,7 +255,7 @@ describe 'apt::ppa' do
     it { is_expected.to contain_package('software-properties-common') }
 
     it {
-      is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
+      expect(subject).to contain_exec('add-apt-repository-ppa:user/foo')
         .that_notifies('Class[Apt::Update]')
         .with(*ppa_exec_params('user', 'foo'))
     }
@@ -297,7 +297,7 @@ describe 'apt::ppa' do
     it { is_expected.to contain_package('software-properties-common') }
 
     it {
-      is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
+      expect(subject).to contain_exec('add-apt-repository-ppa:user/foo')
         .that_notifies('Class[Apt::Update]')
         .with(*ppa_exec_params('user', 'foo', 'trusty', ['http_proxy=http://localhost:8080']))
     }
@@ -339,7 +339,7 @@ describe 'apt::ppa' do
     it { is_expected.to contain_package('software-properties-common') }
 
     it {
-      is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
+      expect(subject).to contain_exec('add-apt-repository-ppa:user/foo')
         .that_notifies('Class[Apt::Update]')
         .with(*ppa_exec_params('user', 'foo', 'trusty', ['http_proxy=http://localhost:8180']))
     }
@@ -381,7 +381,7 @@ describe 'apt::ppa' do
     it { is_expected.to contain_package('software-properties-common') }
 
     it {
-      is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
+      expect(subject).to contain_exec('add-apt-repository-ppa:user/foo')
         .that_notifies('Class[Apt::Update]')
         .with(*ppa_exec_params('user', 'foo', 'trusty', ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180']))
     }
@@ -419,10 +419,10 @@ describe 'apt::ppa' do
     end
 
     it {
-      is_expected.to contain_tidy("remove-apt-repository-script-#{title}")
+      expect(subject).to contain_tidy("remove-apt-repository-script-#{title}")
         .with('path' => '/opt/puppetlabs/puppet/cache/add-apt-repository-user-ubuntu-foo-trusty.sh')
 
-      is_expected.to contain_tidy("remove-apt-repository-#{title}")
+      expect(subject).to contain_tidy("remove-apt-repository-#{title}")
         .with('path' => '/etc/apt/sources.list.d/user-ubuntu-foo-trusty.list')
         .that_notifies('Class[Apt::Update]')
     }
@@ -450,7 +450,7 @@ describe 'apt::ppa' do
       let(:title) { 'ppa:user/foo' }
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
+        expect(subject).to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
       end
     end
 
@@ -475,7 +475,7 @@ describe 'apt::ppa' do
       let(:title) { 'ppa:user/foo' }
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{not currently supported on Debian})
+        expect(subject).to raise_error(Puppet::Error, %r{not currently supported on Debian})
       end
     end
   end
index 97ebdc4658e138da356953c454d1fbd12cf74067..a142667d551c35927615c62da4b5350cb3c8733a 100644 (file)
@@ -27,11 +27,11 @@ describe 'apt::setting' do
   describe 'when using the defaults' do
     context 'without source or content' do
       it do
-        is_expected.to raise_error(Puppet::Error, %r{needs either of })
+        expect(subject).to raise_error(Puppet::Error, %r{needs either of })
       end
     end
 
-    context 'with title=conf-teddybear ' do
+    context 'with title=conf-teddybear' do
       let(:params) { default_params }
 
       it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]') }
@@ -55,10 +55,10 @@ describe 'apt::setting' do
       let(:params) { { source: 'puppet:///la/die/dah' } }
 
       it {
-        is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
-                                                                                                                owner: 'root',
-                                                                                                                group: 'root',
-                                                                                                                source: params[:source].to_s)
+        expect(subject).to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
+                                                                                                                    owner: 'root',
+                                                                                                                    group: 'root',
+                                                                                                                    source: params[:source].to_s)
       }
     end
 
@@ -66,10 +66,10 @@ describe 'apt::setting' do
       let(:params) { default_params }
 
       it {
-        is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
-                                                                                                                owner: 'root',
-                                                                                                                group: 'root',
-                                                                                                                content: params[:content].to_s)
+        expect(subject).to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
+                                                                                                                    owner: 'root',
+                                                                                                                    group: 'root',
+                                                                                                                    content: params[:content].to_s)
       }
     end
   end
@@ -109,7 +109,7 @@ describe 'apt::setting' do
       let(:params) { default_params.merge(source: 'la') }
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{cannot have both })
+        expect(subject).to raise_error(Puppet::Error, %r{cannot have both })
       end
     end
 
@@ -118,7 +118,7 @@ describe 'apt::setting' do
       let(:params) { default_params }
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{must start with either})
+        expect(subject).to raise_error(Puppet::Error, %r{must start with either})
       end
     end
 
@@ -126,7 +126,7 @@ describe 'apt::setting' do
       let(:params) { default_params.merge(ensure: 'banana') }
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]})
+        expect(subject).to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]})
       end
     end
 
@@ -147,7 +147,7 @@ describe 'apt::setting' do
     let(:params) { default_params.merge(ensure: 'absent') }
 
     it {
-      is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'absent')
+      expect(subject).to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'absent')
     }
   end
 end
index 7eef4fd23e8805d1427c88a5cd7c6c6076bf965a..dc261fbb88210fd2f0fd447e2f91d183bbf4def9 100644 (file)
@@ -35,7 +35,7 @@ describe 'apt::source', type: :define do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ stretch main\n})
+      expect(subject).to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ stretch main\n})
     }
   end
 
@@ -55,19 +55,19 @@ describe 'apt::source', type: :define do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
-                                                           .without_content(%r{deb-src})
+      expect(subject).to contain_apt__setting('list-my_source').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
+                                                               .without_content(%r{deb-src})
     }
 
     it {
-      is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
-                                                                                                          'priority' => '10',
-                                                                                                          'origin' => 'debian.mirror.iweb.ca')
+      expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
+                                                                                                              'priority' => '10',
+                                                                                                              'origin' => 'debian.mirror.iweb.ca')
     }
 
     it {
-      is_expected.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: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
+                                                                                                                                                      'id' => GPG_KEY_ID)
     }
   end
 
@@ -104,7 +104,7 @@ describe 'apt::source', type: :define do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ stretch main\n})
+      expect(subject).to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ stretch main\n})
     }
   end
 
@@ -116,7 +116,7 @@ describe 'apt::source', type: :define do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with('ensure' => 'absent')
+      expect(subject).to contain_apt__setting('list-my_source').with('ensure' => 'absent')
     }
   end
 
@@ -139,7 +139,7 @@ describe 'apt::source', type: :define do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
+        expect(subject).to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
       end
     end
   end
index b2c09891c111c05d91340558ec3a13cf7d7b1791..798279e6b26297787fe5e03c053ac15e24df7257 100644 (file)
@@ -33,7 +33,7 @@ describe 'apt::source' do
   context 'with defaults' do
     context 'without location' do
       it do
-        is_expected.to raise_error(Puppet::Error, %r{source entry without specifying a location})
+        expect(subject).to raise_error(Puppet::Error, %r{source entry without specifying a location})
       end
     end
 
@@ -41,8 +41,8 @@ describe 'apt::source' do
       let(:params) { { location: 'hello.there' } }
 
       it {
-        is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main\n})
-        is_expected.not_to contain_package('apt-transport-https')
+        expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main\n})
+        expect(subject).not_to contain_package('apt-transport-https')
       }
     end
   end
@@ -59,16 +59,16 @@ describe 'apt::source' do
       end
 
       it {
-        is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there stretch main\n})
+        expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there stretch main\n})
       }
 
       it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]') }
 
       it {
-        is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
-                                                                                                            priority: 1001,
-                                                                                                            explanation: 'wishwash',
-                                                                                                            release: 'wishwash')
+        expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
+                                                                                                                priority: 1001,
+                                                                                                                explanation: 'wishwash',
+                                                                                                                release: 'wishwash')
       }
     end
 
@@ -87,19 +87,19 @@ describe 'apt::source' do
       end
 
       it {
-        is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
-                                                             .without_content(%r{deb-src})
+        expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
+                                                                 .without_content(%r{deb-src})
       }
 
       it {
-        is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
-                                                                                                            priority: '10',
-                                                                                                            origin: 'debian.mirror.iweb.ca')
+        expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
+                                                                                                                priority: '10',
+                                                                                                                origin: 'debian.mirror.iweb.ca')
       }
 
       it {
-        is_expected.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: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
+                                                                                                                                                        id: GPG_KEY_ID)
       }
     end
 
@@ -125,23 +125,23 @@ describe 'apt::source' do
       end
 
       it {
-        is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
-                                                             .without_content(%r{deb-src})
+        expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
+                                                                 .without_content(%r{deb-src})
       }
 
       it {
-        is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
-                                                                                                            priority: '10',
-                                                                                                            origin: 'debian.mirror.iweb.ca')
+        expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
+                                                                                                                priority: '10',
+                                                                                                                origin: 'debian.mirror.iweb.ca')
       }
 
       it {
-        is_expected.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: #{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)
       }
     end
   end
@@ -155,7 +155,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[allow-insecure=yes\] hello.there stretch main\n})
+      expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[allow-insecure=yes\] hello.there stretch main\n})
     }
   end
 
@@ -168,7 +168,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[trusted=yes\] hello.there stretch main\n})
+      expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[trusted=yes\] hello.there stretch main\n})
     }
   end
 
@@ -181,7 +181,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[check-valid-until=false\] hello.there stretch main\n})
+      expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[check-valid-until=false\] hello.there stretch main\n})
     }
   end
 
@@ -194,7 +194,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there stretch main\n})
+      expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there stretch main\n})
     }
   end
 
@@ -207,7 +207,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source')
+      expect(subject).to contain_apt__setting('list-my_source')
         .with(ensure: 'present')
         .with_content(%r{# my_source\ndeb \[signed-by=/usr/share/keyrings/foo-archive-keyring.gpg\] hello.there stretch main\n})
     }
@@ -224,7 +224,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source')
+      expect(subject).to contain_apt__setting('list-my_source')
         .with(ensure: 'present')
         .with_content(%r{# my_source\ndeb \[arch=amd64 trusted=yes signed-by=/usr/share/keyrings/foo-archive-keyring.gpg\] hello.there stretch main\n})
     }
@@ -239,7 +239,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_package('apt-transport-https')
+      expect(subject).to contain_package('apt-transport-https')
     }
   end
 
@@ -270,7 +270,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_package('apt-transport-https')
+      expect(subject).to contain_package('apt-transport-https')
     }
   end
 
@@ -299,7 +299,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.not_to contain_package('apt-transport-https')
+      expect(subject).not_to contain_package('apt-transport-https')
     }
   end
 
@@ -329,7 +329,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src \[arch=x86_64\] hello.there wheezy main\n})
+      expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src \[arch=x86_64\] hello.there wheezy main\n})
     }
   end
 
@@ -345,7 +345,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there stretch main\n})
+      expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there stretch main\n})
     }
   end
 
@@ -358,7 +358,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there stretch main\ndeb-src hello.there stretch main\n})
+      expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there stretch main\ndeb-src hello.there stretch main\n})
     }
   end
 
@@ -371,7 +371,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{deb-src hello.there wheezy main\n})
+      expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{deb-src hello.there wheezy main\n})
     }
 
     it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) }
@@ -386,7 +386,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there stretch main\n})
+      expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there stretch main\n})
     }
 
     it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there stretch main\n}) }
@@ -400,7 +400,7 @@ describe 'apt::source' do
     end
 
     it {
-      is_expected.to contain_apt__setting('list-my_source').with(ensure: 'absent')
+      expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'absent')
     }
   end
 
@@ -424,7 +424,7 @@ describe 'apt::source' do
       let(:params) { { location: 'hello.there' } }
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
+        expect(subject).to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
       end
     end
 
@@ -443,7 +443,7 @@ describe 'apt::source' do
       end
 
       it do
-        is_expected.to raise_error(Puppet::Error, %r{expects a value})
+        expect(subject).to raise_error(Puppet::Error, %r{expects a value})
       end
     end
 
index c0b028aac9e7d82ddc59a9d2cce764918b19b837..05a12240aa54ac10c896a7d50b7aad7def8584bd 100644 (file)
@@ -11,7 +11,7 @@ describe 'apt_update_last_success fact' do
     it 'has a value of -1' do
       allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
       allow(File).to receive(:exist?).with('/var/lib/apt/periodic/update-success-stamp').and_return(false)
-      is_expected.to eq(-1)
+      expect(subject).to eq(-1)
     end
   end
 
@@ -20,7 +20,7 @@ describe 'apt_update_last_success fact' do
       allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
       allow(File).to receive(:exist?).and_return(true)
       allow(File).to receive(:mtime).and_return(1_407_660_561)
-      is_expected.to eq(1_407_660_561)
+      expect(subject).to eq(1_407_660_561)
     end
   end
 end
index 668a953bff76719b5333bf5c2013d8946ad821d4..6da7016dbddc16c5150852dded5b85f834f22c84 100644 (file)
@@ -58,7 +58,7 @@ describe Puppet::Type.type(:apt_key).provider(:apt_key) do
     it 'apt_key with content set and source nil' do
       expect(described_class).to receive(:apt_key).with(['adv', '--no-tty',
                                                          '--keyserver',
-                                                         :"keyserver.ubuntu.com",
+                                                         :'keyserver.ubuntu.com',
                                                          '--recv-keys',
                                                          'C105B9DE'])
       resource = Puppet::Type::Apt_key.new(name: 'source and content nil',
@@ -74,7 +74,7 @@ describe Puppet::Type.type(:apt_key).provider(:apt_key) do
     it 'apt_key content and source nil, options set' do
       expect(described_class).to receive(:apt_key).with(['adv', '--no-tty',
                                                          '--keyserver',
-                                                         :"keyserver.ubuntu.com",
+                                                         :'keyserver.ubuntu.com',
                                                          '--keyserver-options',
                                                          'jimno',
                                                          '--recv-keys',
@@ -149,7 +149,7 @@ describe Puppet::Type.type(:apt_key).provider(:apt_key) do
         it "#{key_type} #{value} is valid" do
           expect(described_class).to receive(:apt_key).with(array_including('adv', '--no-tty',
                                                                             '--keyserver',
-                                                                            :"keyserver.ubuntu.com",
+                                                                            :'keyserver.ubuntu.com',
                                                                             '--recv-keys'))
           resource = Puppet::Type::Apt_key.new(name: 'source and content nil',
                                                id: value,