From 76a12dc6d700bbda754c75a3be49a19b7798ab0c Mon Sep 17 00:00:00 2001 From: tphoney Date: Mon, 11 Feb 2019 10:04:00 +0000 Subject: [PATCH] (maint) Remove uneeded workarounds for ruby/facter --- lib/facter/apt_updates.rb | 24 +++------------- lib/puppet/provider/apt_key/apt_key.rb | 14 ---------- spec/spec_helper_acceptance.rb | 6 ---- spec/spec_helper_local.rb | 28 +++++++++++++++++++ .../facter/apt_dist_package_updates_spec.rb | 6 +--- .../apt_package_security_updates_spec.rb | 12 ++------ spec/unit/facter/apt_package_updates_spec.rb | 6 +--- 7 files changed, 36 insertions(+), 60 deletions(-) create mode 100644 spec/spec_helper_local.rb diff --git a/lib/facter/apt_updates.rb b/lib/facter/apt_updates.rb index 7a701c1..c2f38a8 100644 --- a/lib/facter/apt_updates.rb +++ b/lib/facter/apt_updates.rb @@ -48,44 +48,28 @@ end Facter.add('apt_package_updates') do confine apt_has_updates: true setcode do - if Facter.version < '2.0.0' - apt_package_updates[0].join(',') - else - apt_package_updates[0] - end + apt_package_updates[0] end end Facter.add('apt_package_dist_updates') do confine apt_has_dist_updates: true setcode do - if Facter.version < '2.0.0' - apt_dist_updates[0].join(',') - else - apt_dist_updates[0] - end + apt_dist_updates[0] end end Facter.add('apt_package_security_updates') do confine apt_has_updates: true setcode do - if Facter.version < '2.0.0' - apt_package_updates[1].join(',') - else - apt_package_updates[1] - end + apt_package_updates[1] end end Facter.add('apt_package_security_dist_updates') do confine apt_has_dist_updates: true setcode do - if Facter.version < '2.0.0' - apt_dist_updates[1].join(',') - else - apt_dist_updates[1] - end + apt_dist_updates[1] end end diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 2bcaf8d..494dd12 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -2,14 +2,6 @@ require 'open-uri' require 'net/ftp' require 'tempfile' -if RUBY_VERSION == '1.8.7' - # Mothers cry, puppies die and Ruby 1.8.7's open-uri needs to be - # monkeypatched to support passing in :ftp_passive_mode. - require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', - 'puppet_x', 'apt_key', 'patch_openuri.rb')) - OpenURI::Options[:ftp_active_mode] = false -end - Puppet::Type.type(:apt_key).provide(:apt_key) do desc 'apt-key provider for apt_key resource' @@ -245,12 +237,6 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do mk_resource_methods - # Needed until PUP-1470 is fixed and we can drop support for Puppet versions - # before that. - def expired - @property_hash[:expired] - end - # Alias the setters of read-only properties # to the read_only function. alias_method :created=, :read_only diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index a6f3d85..91d1d02 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -65,12 +65,6 @@ RSpec.configure do |c| install_language_on(host, 'ja_JP.utf-8') if not_controller(host) # This will be removed, this is temporary to test localisation. end - # Required for binding tests. - if fact('osfamily') == 'RedHat' - if fact('operatingsystemmajrelease') =~ %r{7} || fact('operatingsystem') =~ %r{Fedora} - shell('yum install -y bzip2') - end - end on host, puppet('module', 'install', 'stahnma/epel') end end diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb new file mode 100644 index 0000000..2e897cb --- /dev/null +++ b/spec/spec_helper_local.rb @@ -0,0 +1,28 @@ +if ENV['COVERAGE'] == 'yes' + require 'simplecov' + require 'simplecov-console' + require 'codecov' + + SimpleCov.formatters = [ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::Console, + SimpleCov::Formatter::Codecov, + ] + SimpleCov.start do + track_files 'lib/**/*.rb' + + add_filter '/spec' + + # do not track vendored files + add_filter '/vendor' + add_filter '/.vendor' + + # do not track gitignored files + # this adds about 4 seconds to the coverage check + # this could definitely be optimized + add_filter do |f| + # system returns true if exit status is 0, which with git-check-ignore means file is ignored + system("git check-ignore --quiet #{f.filename}") + end + end +end diff --git a/spec/unit/facter/apt_dist_package_updates_spec.rb b/spec/unit/facter/apt_dist_package_updates_spec.rb index 080e21f..1a7d8e9 100644 --- a/spec/unit/facter/apt_dist_package_updates_spec.rb +++ b/spec/unit/facter/apt_dist_package_updates_spec.rb @@ -26,10 +26,6 @@ describe 'apt_package_dist_updates fact' do "Conf planet.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').returns apt_output end - if Facter.version < '2.0.0' - it { is_expected.to eq('extremetuxracer,planet.rb') } - else - it { is_expected.to eq(['extremetuxracer', 'planet.rb']) } - end + it { is_expected.to eq(['extremetuxracer', 'planet.rb']) } 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 1bc1fda..913add0 100644 --- a/spec/unit/facter/apt_package_security_updates_spec.rb +++ b/spec/unit/facter/apt_package_security_updates_spec.rb @@ -31,11 +31,7 @@ describe 'apt_package_security_updates fact' do "Conf curl (7.52.1-5+deb9u2 Debian-Security:9/stable [amd64])\n" \ end - if Facter.version < '2.0.0' - it { is_expected.to eq('curl') } - else - it { is_expected.to eq(['curl']) } - end + it { is_expected.to eq(['curl']) } end describe 'on Ubuntu' do @@ -48,11 +44,7 @@ describe 'apt_package_security_updates fact' do "Conf procps (2:3.3.10-4ubuntu2.3 Ubuntu:16.04/xenial-updates [amd64])\n" end - if Facter.version < '2.0.0' - it { is_expected.to eq('tzdata,curl') } - else - it { is_expected.to eq(['tzdata', 'curl']) } - end + it { is_expected.to eq(['tzdata', 'curl']) } end end end diff --git a/spec/unit/facter/apt_package_updates_spec.rb b/spec/unit/facter/apt_package_updates_spec.rb index f24481a..3468691 100644 --- a/spec/unit/facter/apt_package_updates_spec.rb +++ b/spec/unit/facter/apt_package_updates_spec.rb @@ -24,10 +24,6 @@ describe 'apt_package_updates fact' do "Conf unhide.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').returns apt_output end - if Facter.version < '2.0.0' - it { is_expected.to eq('tzdata,unhide.rb') } - else - it { is_expected.to eq(['tzdata', 'unhide.rb']) } - end + it { is_expected.to eq(['tzdata', 'unhide.rb']) } end end -- 2.32.3