From 4513a5845c2a18aece7e17ad82612ec4da3efaa0 Mon Sep 17 00:00:00 2001 From: david22swan Date: Fri, 21 Apr 2023 13:48:27 +0100 Subject: [PATCH] (CONT-773) Rubocop Auto Fixes 11-15 - RSpec/ExampleWording - RSpec/ImplicitSubject - Style/IfUnlessModifier - Style/QuotedSymbols - Style/RedundantRegexpEscape --- .rubocop_todo.yml | 56 ++------ lib/facter/apt_updates.rb | 12 +- lib/puppet/provider/apt_key/apt_key.rb | 12 +- lib/puppet/type/apt_key.rb | 18 +-- spec/classes/apt_backports_spec.rb | 60 ++++---- spec/classes/apt_spec.rb | 132 +++++++++--------- spec/classes/apt_update_spec.rb | 16 +-- spec/defines/conf_spec.rb | 16 +-- spec/defines/key_compat_spec.rb | 98 ++++++------- spec/defines/key_spec.rb | 78 +++++------ spec/defines/mark_spec.rb | 8 +- spec/defines/pin_spec.rb | 14 +- spec/defines/ppa_spec.rb | 24 ++-- spec/defines/setting_spec.rb | 28 ++-- spec/defines/source_compat_spec.rb | 22 +-- spec/defines/source_spec.rb | 86 ++++++------ .../facter/apt_update_last_success_spec.rb | 4 +- spec/unit/puppet/provider/apt_key_spec.rb | 6 +- 18 files changed, 320 insertions(+), 370 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5ae1290..a088dce 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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. diff --git a/lib/facter/apt_updates.rb b/lib/facter/apt_updates.rb index 3b46e2d..66c6a89 100644 --- a/lib/facter/apt_updates.rb +++ b/lib/facter/apt_updates.rb @@ -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 diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 9f461cc..c91e26e 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -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]) diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index 99be930..faa430b 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -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 diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index 2ae8429..bfe4a25 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -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 diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index afd7797..65ae50b 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -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 diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 5a73eb4..61335fd 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -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 diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 04551b8..b08cc0f 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -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 diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index ab305a9..f414503 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -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 diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 956c9b6..948833a 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -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 diff --git a/spec/defines/mark_spec.rb b/spec/defines/mark_spec.rb index 5375fe2..cdff673 100644 --- a/spec/defines/mark_spec.rb +++ b/spec/defines/mark_spec.rb @@ -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 diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 8b30a4c..bd2c262 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -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 diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 4732350..3d109ae 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -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 diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 97ebdc4..a142667 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -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 diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb index 7eef4fd..dc261fb 100644 --- a/spec/defines/source_compat_spec.rb +++ b/spec/defines/source_compat_spec.rb @@ -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 diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index b2c0989..798279e 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -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 diff --git a/spec/unit/facter/apt_update_last_success_spec.rb b/spec/unit/facter/apt_update_last_success_spec.rb index c0b028a..05a1224 100644 --- a/spec/unit/facter/apt_update_last_success_spec.rb +++ b/spec/unit/facter/apt_update_last_success_spec.rb @@ -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 diff --git a/spec/unit/puppet/provider/apt_key_spec.rb b/spec/unit/puppet/provider/apt_key_spec.rb index 668a953..6da7016 100644 --- a/spec/unit/puppet/provider/apt_key_spec.rb +++ b/spec/unit/puppet/provider/apt_key_spec.rb @@ -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, -- 2.45.2