From ec7f4e29c6f57ee9250c65432ee0051282367760 Mon Sep 17 00:00:00 2001 From: david22swan Date: Fri, 21 Apr 2023 13:44:09 +0100 Subject: [PATCH] (CONT-773) Rubocop Auto Fixes 6-10 - Lint/SymbolConversion - RSpec/BeNil - RSpec/EmptyLineAfterExample - RSpec/EmptyLineAfterExampleGroup - RSpec/EmptyLineAfterHook --- .rubocop_todo.yml | 69 ------------------- spec/acceptance/apt_key_provider_spec.rb | 4 ++ spec/acceptance/apt_spec.rb | 1 + spec/acceptance/init_task_spec.rb | 3 + spec/classes/apt_backports_spec.rb | 13 ++++ spec/classes/apt_spec.rb | 2 + spec/classes/apt_update_spec.rb | 16 +++-- spec/defines/key_compat_spec.rb | 12 ++++ spec/defines/key_spec.rb | 14 ++++ spec/defines/pin_spec.rb | 1 + spec/defines/ppa_spec.rb | 7 ++ spec/defines/source_spec.rb | 3 + spec/unit/facter/apt_dist_has_updates_spec.rb | 3 + .../apt_dist_package_security_updates_spec.rb | 3 +- .../facter/apt_dist_package_updates_spec.rb | 4 +- .../facter/apt_dist_security_updates_spec.rb | 3 +- spec/unit/facter/apt_dist_updates_spec.rb | 4 +- spec/unit/facter/apt_has_updates_spec.rb | 3 + .../apt_package_security_updates_spec.rb | 3 +- spec/unit/facter/apt_package_updates_spec.rb | 4 +- spec/unit/facter/apt_reboot_required_spec.rb | 2 + spec/unit/facter/apt_security_updates_spec.rb | 3 +- spec/unit/facter/apt_updates_spec.rb | 4 +- spec/unit/puppet/provider/apt_key_spec.rb | 2 + 24 files changed, 100 insertions(+), 83 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 31aae81..5ae1290 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -21,14 +21,6 @@ Lint/ConstantDefinitionInBlock: - 'spec/defines/source_compat_spec.rb' - 'spec/defines/source_spec.rb' -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: strict, consistent -Lint/SymbolConversion: - Exclude: - - 'spec/classes/apt_update_spec.rb' - # Offense count: 6 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: @@ -68,21 +60,6 @@ RSpec/BeEq: - 'spec/unit/facter/apt_reboot_required_spec.rb' - 'spec/unit/puppet/type/apt_key_spec.rb' -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: be, be_nil -RSpec/BeNil: - Exclude: - - 'spec/unit/facter/apt_dist_package_security_updates_spec.rb' - - 'spec/unit/facter/apt_dist_package_updates_spec.rb' - - 'spec/unit/facter/apt_dist_security_updates_spec.rb' - - 'spec/unit/facter/apt_dist_updates_spec.rb' - - 'spec/unit/facter/apt_package_security_updates_spec.rb' - - 'spec/unit/facter/apt_package_updates_spec.rb' - - 'spec/unit/facter/apt_security_updates_spec.rb' - - 'spec/unit/facter/apt_updates_spec.rb' - # Offense count: 6 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without @@ -97,52 +74,6 @@ RSpec/ContextWording: RSpec/DescribeClass: Enabled: false -# Offense count: 23 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowConsecutiveOneLiners. -RSpec/EmptyLineAfterExample: - Exclude: - - 'spec/acceptance/apt_key_provider_spec.rb' - - 'spec/acceptance/apt_spec.rb' - - 'spec/classes/apt_spec.rb' - - 'spec/defines/key_compat_spec.rb' - - 'spec/defines/key_spec.rb' - - 'spec/defines/pin_spec.rb' - - 'spec/defines/ppa_spec.rb' - - 'spec/defines/source_spec.rb' - -# Offense count: 39 -# This cop supports safe autocorrection (--autocorrect). -RSpec/EmptyLineAfterExampleGroup: - Exclude: - - 'spec/acceptance/apt_key_provider_spec.rb' - - 'spec/acceptance/init_task_spec.rb' - - 'spec/classes/apt_backports_spec.rb' - - 'spec/classes/apt_spec.rb' - - 'spec/classes/apt_update_spec.rb' - - 'spec/defines/key_compat_spec.rb' - - 'spec/defines/key_spec.rb' - - 'spec/defines/source_spec.rb' - -# Offense count: 24 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowConsecutiveOneLiners. -RSpec/EmptyLineAfterHook: - Exclude: - - 'spec/acceptance/apt_key_provider_spec.rb' - - 'spec/unit/facter/apt_dist_has_updates_spec.rb' - - 'spec/unit/facter/apt_dist_package_security_updates_spec.rb' - - 'spec/unit/facter/apt_dist_package_updates_spec.rb' - - 'spec/unit/facter/apt_dist_security_updates_spec.rb' - - 'spec/unit/facter/apt_dist_updates_spec.rb' - - 'spec/unit/facter/apt_has_updates_spec.rb' - - 'spec/unit/facter/apt_package_security_updates_spec.rb' - - 'spec/unit/facter/apt_package_updates_spec.rb' - - 'spec/unit/facter/apt_reboot_required_spec.rb' - - 'spec/unit/facter/apt_security_updates_spec.rb' - - 'spec/unit/facter/apt_updates_spec.rb' - - 'spec/unit/puppet/provider/apt_key_spec.rb' - # Offense count: 13 # Configuration parameters: CountAsOne. RSpec/ExampleLength: diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index aa76340..4ca9dba 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -669,6 +669,7 @@ describe 'apt_key' do it 'add an apt_key resource' do apply_manifest_twice(ensure_present_pp) end + it 'remove the apt_key resource' do apply_manifest_twice(ensure_absent_pp) end @@ -855,6 +856,7 @@ describe 'apt_key' do after(:each) do run_shell('rm /tmp/fake-key.gpg') end + it 'fails' do apply_manifest(path_bogus_content_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{no valid OpenPGP data found}) @@ -897,6 +899,7 @@ describe 'apt_key' do apply_manifest(refresh_del_key_pp) apply_manifest(refresh_pp, catch_failures: true) end + context 'when refresh => true' do it 'updates an expired key' do apply_manifest(refresh_true_pp) @@ -904,6 +907,7 @@ describe 'apt_key' do run_shell(PUPPETLABS_EXP_CHECK_COMMAND.to_s) end end + context 'when refresh => false' do it 'does not replace an expired key' do apply_manifest(refresh_false_pp) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 35277bb..d726c34 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -45,6 +45,7 @@ describe 'apt class' do apply_manifest(everything_everything_pp, catch_failures: true) end end + it 'stills work' do run_shell('apt-get update') run_shell('apt-get -y --force-yes upgrade') diff --git a/spec/acceptance/init_task_spec.rb b/spec/acceptance/init_task_spec.rb index 02b3f34..7a21a43 100644 --- a/spec/acceptance/init_task_spec.rb +++ b/spec/acceptance/init_task_spec.rb @@ -10,18 +10,21 @@ describe 'apt tasks' do expect(result.stdout).to contain(%r{Reading package lists}) end end + describe 'upgrade' do it 'upgrades packages' do result = run_bolt_task('apt', 'action' => 'upgrade') expect(result.stdout).to contain(%r{\d+ upgraded, \d+ newly installed, \d+ to remove and \d+ not upgraded}) end end + describe 'dist-upgrade' do it 'dist-upgrades packages' do result = run_bolt_task('apt', 'action' => 'dist-upgrade') expect(result.stdout).to contain(%r{\d+ upgraded, \d+ newly installed, \d+ to remove and \d+ not upgraded}) end end + describe 'autoremove' do it 'autoremoves obsolete packages' do result = run_bolt_task('apt', 'action' => 'autoremove') diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index 6f6d530..2ae8429 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -31,6 +31,7 @@ describe 'apt::backports', type: :class do pin: { 'priority' => 200, 'release' => 'stretch-backports' }) } end + context 'with defaults on ubuntu' do let(:facts) do { @@ -57,6 +58,7 @@ describe 'apt::backports', type: :class do pin: { 'priority' => 200, 'release' => 'bionac-backports' }) } end + context 'with everything set' do let(:facts) do { @@ -92,6 +94,7 @@ describe 'apt::backports', type: :class do pin: { 'priority' => 90, 'release' => 'vivid' }) } end + context 'when set things with hashes' do let(:facts) do { @@ -126,6 +129,7 @@ describe 'apt::backports', type: :class do } end end + describe 'mint tests' do let(:facts) do { @@ -162,6 +166,7 @@ describe 'apt::backports', type: :class do pin: { 'priority' => 200, 'release' => 'trusty-backports' }) } end + context 'with missing location' do let(:params) do { @@ -175,6 +180,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end + context 'with missing release' do let(:params) do { @@ -188,6 +194,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end + context 'with missing repos' do let(:params) do { @@ -201,6 +208,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end + context 'with missing key' do let(:params) do { @@ -215,6 +223,7 @@ describe 'apt::backports', type: :class do end end end + describe 'validation' do let(:facts) do { @@ -244,6 +253,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end + context 'with invalid release' do let(:params) do { @@ -255,6 +265,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end + context 'with invalid repos' do let(:params) do { @@ -266,6 +277,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end + context 'with invalid key' do let(:params) do { @@ -277,6 +289,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end + context 'with invalid pin' do let(:params) do { diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index b7ef6b5..afd7797 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -214,6 +214,7 @@ describe 'apt' do %r{Acquire::https::proxy "https://localhost:8080/";}, ) } + it { is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8080/";}, @@ -232,6 +233,7 @@ describe 'apt' do } end end + context 'with lots of non-defaults' do let :params do { diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 6ab9534..5a73eb4 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -24,7 +24,7 @@ describe 'apt::update', type: :class do id: 'Debian', }, }, - 'apt_update_last_success': factval, + apt_update_last_success: factval, } end let(:pre_condition) do @@ -61,6 +61,7 @@ describe 'apt::update', type: :class do is_expected.to contain_exec('apt_update').with('refreshonly' => false) end end + context 'and Exec[apt_update] refreshonly is overridden to true and has recent run' do let(:facts) do { @@ -76,7 +77,7 @@ describe 'apt::update', type: :class do id: 'Debian', }, }, - 'apt_update_last_success': Time.now.to_i, + apt_update_last_success: Time.now.to_i, } end let(:pre_condition) do @@ -92,6 +93,7 @@ describe 'apt::update', type: :class do end end end + context "when apt::update['frequency']='reluctantly'" do { 'a recent run' => Time.now.to_i, @@ -113,7 +115,7 @@ describe 'apt::update', type: :class do id: 'Debian', }, }, - 'apt_update_last_success': factval, + apt_update_last_success: factval, } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } @@ -149,6 +151,7 @@ describe 'apt::update', type: :class do end end end + ['daily', 'weekly'].each do |update_frequency| context "when apt::update['frequency'] has the value of #{update_frequency}" do { 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| @@ -167,7 +170,7 @@ describe 'apt::update', type: :class do id: 'Debian', }, }, - 'apt_update_last_success': factval, + apt_update_last_success: factval, } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } @@ -193,7 +196,7 @@ describe 'apt::update', type: :class do id: 'Debian', }, }, - 'apt_update_last_success': Time.now.to_i, + apt_update_last_success: Time.now.to_i, } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } @@ -203,6 +206,7 @@ describe 'apt::update', type: :class do is_expected.to contain_exec('apt_update').with('refreshonly' => true) end end + context 'when $apt_update_last_success is nil' do let(:facts) do { @@ -218,7 +222,7 @@ describe 'apt::update', type: :class do id: 'Debian', }, }, - 'apt_update_last_success': nil, + apt_update_last_success: nil, } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index 2fb7e65..ab305a9 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -57,6 +57,7 @@ describe 'apt::key', type: :define do server: 'keyserver.ubuntu.com', content: nil) } + it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{title} present") end @@ -80,6 +81,7 @@ describe 'apt::key', type: :define do 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") end @@ -99,6 +101,7 @@ describe 'apt::key', type: :define do server: 'keyserver.ubuntu.com', content: nil) end + it 'contains the apt_key absent anchor' do is_expected.to contain_anchor("apt_key #{title} absent") end @@ -117,6 +120,7 @@ describe 'apt::key', type: :define do it 'contains the apt_key' do is_expected.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") end @@ -147,6 +151,7 @@ describe 'apt::key', type: :define do server: 'hkp://pgp.mit.edu') end end + context 'with url and port number' do let :params do { @@ -197,6 +202,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end + context 'when url character limit is exceeded' do let :params do { @@ -208,6 +214,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end + context 'with incorrect port number url' do let :params do { @@ -219,6 +226,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end + context 'with incorrect protocol for url' do let :params do { @@ -230,6 +238,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end + context 'with missing port number url' do let :params do { @@ -241,6 +250,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end + context 'with url ending with a dot' do let :params do { @@ -252,6 +262,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end + context 'with url begin with a dash' do let(:params) do { @@ -263,6 +274,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end + context 'with invalid key' do let :title do 'Out of rum. Why? Why are we out of rum?' diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 8c8d503..956c9b6 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -70,6 +70,7 @@ describe 'apt::key' do it 'contains the apt_key' do is_expected.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") end @@ -89,6 +90,7 @@ describe 'apt::key' do it 'contains the apt_key' do is_expected.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") end @@ -104,6 +106,7 @@ describe 'apt::key' do it 'contains the apt_key' do is_expected.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") end @@ -137,6 +140,7 @@ describe 'apt::key' do it 'contains the apt_key' do is_expected.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") end @@ -167,6 +171,7 @@ describe 'apt::key' do server: 'hkp://pgp.mit.edu') end end + context 'when url with port number' do let :params do { @@ -217,6 +222,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end + context 'when character url exceeded' do let :params do { @@ -228,6 +234,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end + context 'with incorrect port number url' do let :params do { @@ -239,6 +246,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end + context 'with incorrect protocol for url' do let :params do { @@ -250,6 +258,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end + context 'with missing port number url' do let :params do { @@ -261,6 +270,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end + context 'with url ending with a dot' do let :params do { @@ -272,6 +282,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end + context 'when url begins with a dash' do let(:params) do { @@ -283,6 +294,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end + context 'with invalid key' do let :title do 'Out of rum. Why? Why are we out of rum?' @@ -365,6 +377,7 @@ describe 'apt::key' do is_expected.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') @@ -373,6 +386,7 @@ describe 'apt::key' do it 'contains only a single apt_key - duplicate' do is_expected.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) end diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index f22d92a..8b30a4c 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -65,6 +65,7 @@ describe 'apt::pin', type: :define do end 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) } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 00424dc..4732350 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -37,6 +37,7 @@ describe 'apt::ppa' do let(:title) { 'ppa:needs/substitution' } it { is_expected.not_to contain_package('python-software-properties') } + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution') .that_notifies('Class[Apt::Update]') @@ -168,6 +169,7 @@ describe 'apt::ppa' do let(:title) { 'ppa:needs/substitution' } it { is_expected.to contain_package('software-properties-common') } + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution') .that_notifies('Class[Apt::Update]') @@ -207,6 +209,7 @@ describe 'apt::ppa' do let(:title) { 'ppa:needs/substitution' } it { is_expected.not_to contain_package('python-software-properties') } + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution') .that_notifies('Class[Apt::Update]') @@ -250,6 +253,7 @@ describe 'apt::ppa' do it { is_expected.to compile.with_all_deps } it { is_expected.to contain_package('software-properties-common') } + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') @@ -291,6 +295,7 @@ describe 'apt::ppa' do let(:title) { 'ppa:user/foo' } it { is_expected.to contain_package('software-properties-common') } + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') @@ -332,6 +337,7 @@ describe 'apt::ppa' do let(:title) { 'ppa:user/foo' } it { is_expected.to contain_package('software-properties-common') } + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') @@ -373,6 +379,7 @@ describe 'apt::ppa' do let(:title) { 'ppa:user/foo' } it { is_expected.to contain_package('software-properties-common') } + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index e5df79f..b2c0989 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -36,6 +36,7 @@ describe 'apt::source' do is_expected.to raise_error(Puppet::Error, %r{source entry without specifying a location}) end end + context 'with location' do let(:params) { { location: 'hello.there' } } @@ -372,6 +373,7 @@ describe 'apt::source' do it { is_expected.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}) } end @@ -386,6 +388,7 @@ describe 'apt::source' do it { is_expected.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}) } end diff --git a/spec/unit/facter/apt_dist_has_updates_spec.rb b/spec/unit/facter/apt_dist_has_updates_spec.rb index 3ed4f3b..b5b05b6 100644 --- a/spec/unit/facter/apt_dist_has_updates_spec.rb +++ b/spec/unit/facter/apt_dist_has_updates_spec.rb @@ -11,6 +11,7 @@ describe 'apt_has_dist_updates fact' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Redhat') end + it { is_expected.to be_nil } end @@ -20,6 +21,7 @@ describe 'apt_has_dist_updates fact' do allow(File).to receive(:executable?) # Stub all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(false) end + it { is_expected.to be_nil } end @@ -36,6 +38,7 @@ describe 'apt_has_dist_updates fact' do "Conf planet.rb (22-2~bpo8+1 Debian Backports:stretch-backports [all])\n" allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output) end + it { is_expected.to be true } end end diff --git a/spec/unit/facter/apt_dist_package_security_updates_spec.rb b/spec/unit/facter/apt_dist_package_security_updates_spec.rb index f16ff52..1e8aeb8 100644 --- a/spec/unit/facter/apt_dist_package_security_updates_spec.rb +++ b/spec/unit/facter/apt_dist_package_security_updates_spec.rb @@ -11,7 +11,8 @@ describe 'apt_package_security_dist_updates fact' do before(:each) do allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has updates' do diff --git a/spec/unit/facter/apt_dist_package_updates_spec.rb b/spec/unit/facter/apt_dist_package_updates_spec.rb index a27d607..43e2d7e 100644 --- a/spec/unit/facter/apt_dist_package_updates_spec.rb +++ b/spec/unit/facter/apt_dist_package_updates_spec.rb @@ -11,7 +11,8 @@ describe 'apt_package_dist_updates fact' do before(:each) do allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has updates' do @@ -28,6 +29,7 @@ describe 'apt_package_dist_updates fact' do "Conf planet.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n" allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output) end + it { is_expected.to eq(['extremetuxracer', 'planet.rb']) } end end diff --git a/spec/unit/facter/apt_dist_security_updates_spec.rb b/spec/unit/facter/apt_dist_security_updates_spec.rb index aa21e64..baaf048 100644 --- a/spec/unit/facter/apt_dist_security_updates_spec.rb +++ b/spec/unit/facter/apt_dist_security_updates_spec.rb @@ -11,7 +11,8 @@ describe 'apt_security_updates fact' do before(:each) do allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has security updates' do diff --git a/spec/unit/facter/apt_dist_updates_spec.rb b/spec/unit/facter/apt_dist_updates_spec.rb index 21352b5..ac87f66 100644 --- a/spec/unit/facter/apt_dist_updates_spec.rb +++ b/spec/unit/facter/apt_dist_updates_spec.rb @@ -11,7 +11,8 @@ describe 'apt_updates fact' do before(:each) do allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has updates' do @@ -28,6 +29,7 @@ describe 'apt_updates fact' do "Conf planet.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n" allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output) end + it { is_expected.to eq(2) } end end diff --git a/spec/unit/facter/apt_has_updates_spec.rb b/spec/unit/facter/apt_has_updates_spec.rb index 0f0a740..77a95b4 100644 --- a/spec/unit/facter/apt_has_updates_spec.rb +++ b/spec/unit/facter/apt_has_updates_spec.rb @@ -11,6 +11,7 @@ describe 'apt_has_updates fact' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Redhat') end + it { is_expected.to be_nil } end @@ -20,6 +21,7 @@ describe 'apt_has_updates fact' do allow(File).to receive(:executable?) # Stub all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(false) end + it { is_expected.to be_nil } end @@ -35,6 +37,7 @@ describe 'apt_has_updates fact' do "Conf unhide.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n" allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output) end + it { is_expected.to be true } end end diff --git a/spec/unit/facter/apt_package_security_updates_spec.rb b/spec/unit/facter/apt_package_security_updates_spec.rb index 28516ca..d546715 100644 --- a/spec/unit/facter/apt_package_security_updates_spec.rb +++ b/spec/unit/facter/apt_package_security_updates_spec.rb @@ -11,7 +11,8 @@ describe 'apt_package_security_updates fact' do before(:each) do allow(Facter.fact(:apt_has_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has updates' do diff --git a/spec/unit/facter/apt_package_updates_spec.rb b/spec/unit/facter/apt_package_updates_spec.rb index 69db490..7960306 100644 --- a/spec/unit/facter/apt_package_updates_spec.rb +++ b/spec/unit/facter/apt_package_updates_spec.rb @@ -11,7 +11,8 @@ describe 'apt_package_updates fact' do before(:each) do allow(Facter.fact(:apt_has_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has updates' do @@ -26,6 +27,7 @@ describe 'apt_package_updates fact' do "Conf unhide.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n" allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output) end + it { is_expected.to eq(['tzdata', 'unhide.rb']) } end end diff --git a/spec/unit/facter/apt_reboot_required_spec.rb b/spec/unit/facter/apt_reboot_required_spec.rb index 7621872..f922822 100644 --- a/spec/unit/facter/apt_reboot_required_spec.rb +++ b/spec/unit/facter/apt_reboot_required_spec.rb @@ -13,6 +13,7 @@ describe 'apt_reboot_required fact' do allow(File).to receive(:file?).and_return(true) allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(true) end + it { is_expected.to eq true } end @@ -22,6 +23,7 @@ describe 'apt_reboot_required fact' do allow(File).to receive(:file?).and_return(true) allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(false) end + it { is_expected.to eq false } end end diff --git a/spec/unit/facter/apt_security_updates_spec.rb b/spec/unit/facter/apt_security_updates_spec.rb index 9d3e587..25ba311 100644 --- a/spec/unit/facter/apt_security_updates_spec.rb +++ b/spec/unit/facter/apt_security_updates_spec.rb @@ -11,7 +11,8 @@ describe 'apt_security_updates fact' do before(:each) do allow(Facter.fact(:apt_has_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has security updates' do diff --git a/spec/unit/facter/apt_updates_spec.rb b/spec/unit/facter/apt_updates_spec.rb index a8eacbf..4397f76 100644 --- a/spec/unit/facter/apt_updates_spec.rb +++ b/spec/unit/facter/apt_updates_spec.rb @@ -11,7 +11,8 @@ describe 'apt_updates fact' do before(:each) do allow(Facter.fact(:apt_has_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has updates' do @@ -26,6 +27,7 @@ describe 'apt_updates fact' do "Conf unhide.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n" allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output) end + it { is_expected.to eq(2) } end end diff --git a/spec/unit/puppet/provider/apt_key_spec.rb b/spec/unit/puppet/provider/apt_key_spec.rb index d2fa8b2..668a953 100644 --- a/spec/unit/puppet/provider/apt_key_spec.rb +++ b/spec/unit/puppet/provider/apt_key_spec.rb @@ -22,6 +22,7 @@ describe Puppet::Type.type(:apt_key).provider(:apt_key) do ['adv', '--no-tty', '--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'], ).and_return('uid:-::::1284991450::07BEBE04F4AE4A8E885A761325717D8509D9C1DC::Ubuntu Extras Archive Automatic Signing Key ::::::::::0:') end + it 'returns no resources' do expect(described_class.instances.size).to eq(0) end @@ -43,6 +44,7 @@ describe Puppet::Type.type(:apt_key).provider(:apt_key) do ['adv', '--no-tty', '--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'], ).and_return(command_output) end + it 'returns 2 resources' do # rubocop:disable RSpec/MultipleExpectations expect(described_class.instances.size).to eq(2) expect(described_class.instances[0].name).to eq('630239CC130E1A7FD81A27B140976EAF437D05B5') -- 2.45.2