Merge pull request #842 from tphoney/remove_unsupported_code
authorHelen <helen@puppetlabs.com>
Tue, 12 Feb 2019 16:02:52 +0000 (16:02 +0000)
committerGitHub <noreply@github.com>
Tue, 12 Feb 2019 16:02:52 +0000 (16:02 +0000)
(maint) Remove uneeded workarounds for ruby/facter

lib/facter/apt_updates.rb
lib/puppet/provider/apt_key/apt_key.rb
spec/spec_helper_acceptance.rb
spec/spec_helper_local.rb [new file with mode: 0644]
spec/unit/facter/apt_dist_package_updates_spec.rb
spec/unit/facter/apt_package_security_updates_spec.rb
spec/unit/facter/apt_package_updates_spec.rb

index 7a701c17a01f849ec05a4954c604be2e591d04d1..c2f38a8f73cae9dfb481db11b3bb4e22fbd69257 100644 (file)
@@ -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
 
index 2bcaf8d32ec87589e222da7356e1d49f18fad36c..494dd12d1e822de61e7053a90c6f7aa61f29d4df 100644 (file)
@@ -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
index a6f3d853b6115a6f0fbefc97307548f6d7f07607..91d1d02558d07fdcfdac7e06f5c5f95d62327389 100644 (file)
@@ -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 (file)
index 0000000..2e897cb
--- /dev/null
@@ -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
index 080e21f68326c5844e0bbedfed9ccb95a10a4577..1a7d8e9eaa32842ed5f7f9e7e62883dc11504d5b 100644 (file)
@@ -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
index 1bc1fda0483d7f40c9f4f1b7b26dd4beb5740266..913add03d34db519f3588d49c25cd31d457b1172 100644 (file)
@@ -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
index f24481a98239d593ea2d458b46e60433205b8a91..3468691f00f083f362865bc3ec15429c91c9e1d5 100644 (file)
@@ -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