From f9e16972dae866d4bec25dbc5ac1db92a8188e1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?F=E1=B4=80=CA=99=C9=AA=E1=B4=87=C9=B4=20W=E1=B4=87=CA=80?=
 =?UTF-8?q?=C9=B4=CA=9F=C9=AA?= <wernli@in2p3.fr>
Date: Wed, 19 Feb 2020 09:35:42 +0100
Subject: [PATCH] minimal test case for
 https://github.com/rodjek/rspec-puppet/issues/785#issuecomment-587964926

---
 spec/classes/config_spec.rb  | 147 -----------------------------------
 spec/classes/cpan_spec.rb    |  39 ----------
 spec/classes/install_spec.rb |  52 -------------
 spec/types/cpan_spec.rb      |  75 ------------------
 4 files changed, 313 deletions(-)
 delete mode 100644 spec/classes/config_spec.rb
 delete mode 100644 spec/classes/cpan_spec.rb
 delete mode 100644 spec/classes/install_spec.rb
 delete mode 100644 spec/types/cpan_spec.rb

diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb
deleted file mode 100644
index f002bd5..0000000
--- a/spec/classes/config_spec.rb
+++ /dev/null
@@ -1,147 +0,0 @@
-require 'spec_helper'
-
-describe 'cpan::config' do
-  on_supported_os.each do |os, os_facts|
-    context "On #{os}" do
-      let(:facts) { os_facts }
-
-      context 'With default ::cpan parameters' do
-        let(:pre_condition) do
-          [
-            'include cpan',
-          ]
-        end
-
-        case os_facts[:osfamily]
-        when 'Debian'
-          it { is_expected.to contain_file('/etc/perl/CPAN/Config.pm').with_owner('root') }
-          it { is_expected.to contain_file('/etc/perl/CPAN/Config.pm').with_group('root') }
-          it { is_expected.to contain_file('/etc/perl/CPAN/Config.pm').with_mode('0644') }
-        when 'RedHat'
-          case os_facts[:os]['release']['major']
-          when '5'
-            it {
-              is_expected.to contain_file('/usr/lib/perl5/5.8.8/CPAN/Config.pm').with_owner('root')
-              is_expected.to contain_file('/usr/lib/perl5/5.8.8/CPAN/Config.pm').with_group('root')
-              is_expected.to contain_file('/usr/lib/perl5/5.8.8/CPAN/Config.pm').with_mode('0644')
-            }
-          when '6'
-            it {
-              is_expected.to contain_file('/usr/share/perl5/CPAN/Config.pm').with_owner('root')
-              is_expected.to contain_file('/usr/share/perl5/CPAN/Config.pm').with_group('root')
-              is_expected.to contain_file('/usr/share/perl5/CPAN/Config.pm').with_mode('0644')
-            }
-          when '7'
-            it {
-              is_expected.to contain_file('/usr/share/perl5/CPAN/Config.pm').with_owner('root')
-              is_expected.to contain_file('/usr/share/perl5/CPAN/Config.pm').with_group('root')
-              is_expected.to contain_file('/usr/share/perl5/CPAN/Config.pm').with_mode('0644')
-              is_expected.to contain_file('/usr/share/perl5/CPAN/Config.pm').with_content(%r{^  'http_proxy' => q\[\],$})
-              is_expected.to contain_file('/usr/share/perl5/CPAN/Config.pm').with_content(%r{^  'ftp_proxy' => q\[\],$})
-            }
-            it 'has empty urlist' do
-              verify_contents(catalogue, '/usr/share/perl5/CPAN/Config.pm', [
-                                "  'urllist' => [",
-                                '  ],',
-                              ])
-            end
-          when '8'
-            it {
-              is_expected.to contain_file('/usr/share/perl5/vendor_perl/CPAN/Config.pm').with_owner('root')
-              is_expected.to contain_file('/usr/share/perl5/vendor_perl/CPAN/Config.pm').with_group('root')
-              is_expected.to contain_file('/usr/share/perl5/vendor_perl/CPAN/Config.pm').with_mode('0644')
-            }
-          end
-        end
-      end
-      context 'With custom ::cpan parameters' do
-        case os_facts[:osfamily]
-        when 'RedHat'
-          case os_facts[:os]['release']['major']
-          when '7'
-            context 'with proxies set' do
-              let(:pre_condition) do
-                [
-                  'class { "cpan":
-                     ftp_proxy  => "http://your_ftp_proxy.com",
-                     http_proxy => "http://your_http_proxy.com",
-                   }
-                  ',
-                ]
-              end
-
-              it { is_expected.to contain_file('/usr/share/perl5/CPAN/Config.pm').with_content(%r{^  'ftp_proxy' => q\[http://your_ftp_proxy\.com\],$}) }
-              it { is_expected.to contain_file('/usr/share/perl5/CPAN/Config.pm').with_content(%r{^  'http_proxy' => q\[http://your_http_proxy\.com\],$}) }
-            end
-            context 'with custom param set' do
-              describe 'string' do
-                let(:pre_condition) do
-                  [
-                    'class { "cpan":
-                      config_hash  => { "foo" => "bar" }
-                    }',
-                  ]
-                end
-
-                it { is_expected.to contain_file('/usr/share/perl5/CPAN/Config.pm').with_content(%r{^  'foo' => q\[bar],$}) }
-              end
-              describe 'array' do
-                let(:pre_condition) do
-                  [
-                    'class {"cpan":
-                      config_hash  => { "foo" => ["baz","bar"] }
-                    }',
-                  ]
-                end
-
-                it do
-                  verify_contents(catalogue, '/usr/share/perl5/CPAN/Config.pm', [
-                                    "  'foo' => [",
-                                    '    q[baz],',
-                                    '    q[bar]',
-                                  ])
-                end
-              end
-            end
-            context 'with urllist set' do
-              describe 'single url' do
-                let(:pre_condition) do
-                  'class { "cpan":
-                    urllist => ["http://httpupdate3.cpanel.net/CPAN/"],
-                  }'
-                end
-
-                it do
-                  verify_contents(catalogue, '/usr/share/perl5/CPAN/Config.pm', [
-                                    "  'urllist' => [",
-                                    '    q[http://httpupdate3.cpanel.net/CPAN/]',
-                                    '  ],',
-                                  ])
-                end
-              end
-              describe 'two urls' do
-                let(:pre_condition) do
-                  'class { "::cpan":
-                    urllist => [
-                      "http://httpupdate3.cpanel.net/CPAN/",
-                      "ftp://cpan.cse.msu.edu/"
-                    ],
-                  }'
-                end
-
-                it do
-                  verify_contents(catalogue, '/usr/share/perl5/CPAN/Config.pm', [
-                                    "  'urllist' => [",
-                                    '    q[http://httpupdate3.cpanel.net/CPAN/],',
-                                    '    q[ftp://cpan.cse.msu.edu/]',
-                                    '  ],',
-                                  ])
-                end
-              end
-            end
-          end
-        end
-      end
-    end
-  end
-end
diff --git a/spec/classes/cpan_spec.rb b/spec/classes/cpan_spec.rb
deleted file mode 100644
index 6cdd07b..0000000
--- a/spec/classes/cpan_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require 'spec_helper'
-
-describe 'cpan' do
-  on_supported_os.each do |os, os_facts|
-    context "On #{os}" do
-      let(:facts) { os_facts }
-
-      it { is_expected.to contain_class('cpan::install') }
-      it { is_expected.to contain_class('cpan::config') }
-
-      describe 'cpan::install' do
-        let(:params) { { package_ensure: 'present', manage_package: true, local_lib: false } }
-
-        it { is_expected.to contain_package('gcc').with(ensure: 'present') }
-        it { is_expected.to contain_package('make').with(ensure: 'present') }
-
-        case os_facts[:osfamily]
-        when 'Debian'
-          it { is_expected.to contain_package('perl').with(ensure: 'present') }
-        when 'RedHat'
-          it { is_expected.to contain_package('perl-CPAN').with(ensure: 'present') }
-        end
-
-        describe 'should allow package ensure to be overridden' do
-          let(:params) { { package_ensure: 'latest', manage_package: true } }
-
-          it { is_expected.to contain_package('gcc').with_ensure('latest') }
-          it { is_expected.to contain_package('make').with_ensure('latest') }
-          case os_facts[:osfamily]
-          when 'Debian'
-            it { is_expected.to contain_package('perl').with(ensure: 'latest') }
-          when 'RedHat'
-            it { is_expected.to contain_package('perl-CPAN').with(ensure: 'latest') }
-          end
-        end
-      end
-    end
-  end
-end
diff --git a/spec/classes/install_spec.rb b/spec/classes/install_spec.rb
deleted file mode 100644
index 243e04e..0000000
--- a/spec/classes/install_spec.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require 'spec_helper'
-
-describe 'cpan::install' do
-  on_supported_os.each do |os, os_facts|
-    context "On #{os}" do
-      let(:facts) { os_facts }
-
-      describe 'package_ensure and manage_package' do
-        let(:pre_condition) do
-          [
-            'class { "cpan":
-               package_ensure => "present",
-               manage_package => true,
-               local_lib      => false,
-            }
-            ',
-          ]
-        end
-
-        it { is_expected.to contain_package('gcc').with(ensure: 'present') }
-        it { is_expected.to contain_package('make').with(ensure: 'present') }
-
-        case os_facts[:osfamily]
-        when 'Debian'
-          it { is_expected.to contain_package('perl').with(ensure: 'present') }
-        when 'RedHat'
-          it { is_expected.to contain_package('perl-CPAN').with(ensure: 'present') }
-        end
-      end
-      describe 'should allow package ensure to be overridden' do
-        let(:pre_condition) do
-          [
-            'class { "cpan":
-               package_ensure => "latest",
-               manage_package => true,
-            }
-            ',
-          ]
-        end
-
-        it { is_expected.to contain_package('gcc').with_ensure('latest') }
-        it { is_expected.to contain_package('make').with_ensure('latest') }
-        case os_facts[:osfamily]
-        when 'Debian'
-          it { is_expected.to contain_package('perl').with(ensure: 'latest') }
-        when 'RedHat'
-          it { is_expected.to contain_package('perl-CPAN').with(ensure: 'latest') }
-        end
-      end
-    end
-  end
-end
diff --git a/spec/types/cpan_spec.rb b/spec/types/cpan_spec.rb
deleted file mode 100644
index 1324828..0000000
--- a/spec/types/cpan_spec.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-require 'spec_helper'
-
-described_type = Puppet::Type.type(:cpan)
-
-describe 'cpan' do
-  let(:title) { 'baz' }
-
-  describe 'valid type' do
-    it { is_expected.to be_valid_type }
-  end
-  describe 'ensure' do
-    [:present, :absent, :installed, :latest].each do |value|
-      it "accepts #{value} as a value" do
-        is_expected.to be_valid_type.with_set_attributes(ensure: value)
-      end
-    end
-    it 'rejects other values' do
-      expect { described_type.new(name: 'test', ensure: 'foo') }.to raise_error(Puppet::Error)
-    end
-  end
-
-  describe 'name' do
-    it 'is the namevar' do
-      expect(described_type.key_attributes).to eq([:name])
-    end
-  end
-
-  describe 'local_lib' do
-    it 'accepts an absolute path' do
-      is_expected.to be_valid_type.with_set_attributes(local_lib: '/path/to/file')
-    end
-    it 'accepts false' do
-      is_expected.to be_valid_type.with_set_attributes(local_lib: false)
-    end
-  end
-
-  describe 'force' do
-    [true, false, 'true', 'false', 'no', 'yes'].each do |value|
-      it "accepts #{value}" do
-        is_expected.to be_valid_type.with_set_attributes(force: value)
-      end
-    end
-    it 'rejects other values' do
-      # for some reason expect { be_valid_type.with_set_attributes({:force => 'nope'})}.to raise_error doesn't raise
-      # expect {be_valid_type.with_set_attributes({:force => 'nope'})}.to raise_error(Puppet::ResourceError)
-      expect { described_type.new(name: 'test', force: 'nope') }.to raise_error(Puppet::Error)
-    end
-    it 'defaults to false' do
-      expect(described_type.new(name: 'test')[:force]).to eq(false)
-    end
-    it 'munges \'false\' to false' do
-      expect(described_type.new(name: 'test', force: 'false')[:force]).to eq(false)
-    end
-    it 'munges \'true\' to true' do
-      expect(described_type.new(name: 'test', force: 'true')[:force]).to eq(true)
-    end
-  end
-
-  describe 'umask' do
-    describe 'valid values' do
-      ['0022', '022', '0027', '027'].each do |value|
-        it "accepts #{value}" do
-          is_expected.to be_valid_type.with_set_attributes(umask: value)
-        end
-      end
-    end
-    describe 'invalid values' do
-      [true, false, 220, '0', '888', 'invalid'].each do |value|
-        it "rejects #{value}" do
-          expect { described_type.new(name: 'test', umask: value) }.to raise_error(Puppet::Error)
-        end
-      end
-    end
-  end
-end