Update tests to work with rspec-puppet 2.x
authorMorgan Haskel <morgan@puppetlabs.com>
Wed, 22 Apr 2015 23:31:47 +0000 (16:31 -0700)
committerMorgan Haskel <morgan@puppetlabs.com>
Wed, 22 Apr 2015 23:40:48 +0000 (16:40 -0700)
Also enable future parser testing. Need to allow failures with future
parser for now since none of the published gems have the fix for
PUP-4379

.travis.yml
Gemfile
spec/classes/apt_backports_spec.rb
spec/classes/apt_spec.rb
spec/classes/params_spec.rb
spec/defines/conf_spec.rb
spec/defines/key_spec.rb
spec/defines/pin_spec.rb
spec/defines/ppa_spec.rb
spec/defines/setting_spec.rb
spec/defines/source_spec.rb

index 8b374e9bb0c3322e6157a975c50f17aabaf95a5b..6ff1d8a2a6851f4b28ce0c7e4af0ceace91d5b69 100644 (file)
@@ -12,5 +12,16 @@ matrix:
     env: PUPPET_GEM_VERSION="~> 3.0"
   - rvm: 2.0.0
     env: PUPPET_GEM_VERSION="~> 3.0"
+  - rvm: 1.9.3
+    env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
+  - rvm: 2.0.0
+    env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
+  - rvm: 1.9.3
+    env: PUPPET_GEM_VERSION="~> 4.0"
+  - rvm: 2.0.0
+    env: PUPPET_GEM_VERSION="~> 4.0"
+  allow_failures:
+    - env: PUPPET_GEM_VERSION="~> 4.0"
+    - env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
 notifications:
   email: false
diff --git a/Gemfile b/Gemfile
index e1ae0fa56a1c98714c770d2a01fde60de0b50f75..64e206f18578f6ce61702272c003e62e54c7d0fe 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -13,7 +13,7 @@ end
 group :development, :unit_tests do
   gem 'rake',                    :require => false
   gem 'rspec-core', '3.1.7',     :require => false
-  gem 'rspec-puppet', '~> 1.0',  :require => false
+  gem 'rspec-puppet', '~> 2.0',  :require => false
   gem 'puppetlabs_spec_helper',  :require => false
   gem 'puppet-lint',             :require => false
   gem 'simplecov',               :require => false
index b9077a6bcd67775a51907f0cb77243f8acf2a7ee..1b596789e0d9f3c4eb3418403b3533492270e803 100644 (file)
@@ -142,7 +142,7 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/)
       end
     end
@@ -156,7 +156,7 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/)
       end
     end
@@ -170,7 +170,7 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/)
       end
     end
@@ -184,7 +184,7 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /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
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /is not a string/)
       end
     end
@@ -217,7 +217,7 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /is not a string/)
       end
     end
@@ -229,7 +229,7 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /is not a string/)
       end
     end
@@ -241,7 +241,7 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /is not a string/)
       end
     end
@@ -253,7 +253,7 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /pin must be either a string, number or hash/)
       end
     end
index ee7cd33a24e04610aef6a894d87e2c841dfb4d27..a470667b0dcaab0d3296b09960de8aadab0df2e5 100644 (file)
@@ -101,8 +101,8 @@ describe 'apt' do
       }
     end
 
-    it { is_expected.to contain_file('sources.list').without({
-      :content => "# Repos managed by puppet.\n",
+    it { is_expected.to contain_file('sources.list').with({
+      :content => nil,
     })}
 
     it { is_expected.to contain_file('sources.list.d').with({
@@ -230,7 +230,7 @@ describe 'apt' do
       let(:params) { { :purge => { 'sources.list' => 'banana' }, } }
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error)
       end
     end
@@ -239,7 +239,7 @@ describe 'apt' do
       let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } }
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error)
       end
     end
@@ -248,7 +248,7 @@ describe 'apt' do
       let(:params) { { :purge => { 'preferences' => 'banana' }, } }
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error)
       end
     end
@@ -257,7 +257,7 @@ describe 'apt' do
       let(:params) { { :purge => { 'preferences.d' => 'banana' }, } }
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error)
       end
     end
@@ -269,7 +269,7 @@ describe 'apt' do
 
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)
       end
     end
index f8599b36998d0fb3f6629c8118f6d6ee5dc5bca6..d90ae7e993a54648a28bf389bc7c9721cfd53c4b 100644 (file)
@@ -9,16 +9,16 @@ describe 'apt::params', :type => :class do
   # there should not be any more resources because it is a params class
   # The resources are class[apt::params], class[main], class[settings], stage[main]
   it "Should not contain any resources" do
-    expect(subject.resources.size).to eq(4)
+    expect(subject.call.resources.size).to eq(4)
   end
 
   describe "With lsb-release not installed" do
-    let(:facts) { { :lsbdistid => '', :osfamily => 'Debian' } }
+    let(:facts) { { :osfamily => 'Debian' } }
     let (:title) { 'my_package' }
 
     it do
       expect {
-        is_expected.to compile
+        subject.call
       }.to raise_error(Puppet::Error, /Unable to determine lsbdistid, is lsb-release installed/)
     end
   end
index e96f8bcd8299b9c2c3902f4603ba25ed802a6244..d0c5ed976dc7e94eea280364236a42e919c6df92 100644 (file)
@@ -38,7 +38,7 @@ describe 'apt::conf', :type => :define do
     end
 
     it 'fails' do
-      expect { subject } .to raise_error(/pass in content/)
+      expect { subject.call } .to raise_error(/pass in content/)
     end
   end
 
index b9bcea845a7916e67dabd750ba1658b76eb9743b..6725dc8f25e9533268a53639c3e7d8b1ad70eab7 100644 (file)
@@ -143,7 +143,7 @@ describe 'apt::key' do
         :server => '-pgp.mit.edu',
       } end
       it 'fails' do
-        expect { subject } .to raise_error(/does not match/)
+        expect { subject.call } .to raise_error(/does not match/)
       end
     end
 
@@ -152,7 +152,7 @@ describe 'apt::key' do
         :server => '.pgp.mit.edu',
       } end
       it 'fails' do
-        expect { subject } .to raise_error(/does not match/)
+        expect { subject.call } .to raise_error(/does not match/)
       end
     end
 
@@ -161,7 +161,7 @@ describe 'apt::key' do
         :server => "pgp.mit.edu.",
       } end
       it 'fails' do
-        expect { subject } .to raise_error(/does not match/)
+        expect { subject.call } .to raise_error(/does not match/)
       end
     end
     context "exceed character url" do
@@ -171,7 +171,7 @@ describe 'apt::key' do
         }
       end
       it 'fails' do
-        expect { subject }.to raise_error(/does not match/)
+        expect { subject.call }.to raise_error(/does not match/)
       end
     end
     context "incorrect port number url" do
@@ -181,7 +181,7 @@ describe 'apt::key' do
         }
       end
       it 'fails' do
-        expect { subject }.to raise_error(/does not match/)
+        expect { subject.call }.to raise_error(/does not match/)
       end
     end
     context "incorrect protocol for  url" do
@@ -191,7 +191,7 @@ describe 'apt::key' do
         }
       end
       it 'fails' do
-        expect { subject }.to raise_error(/does not match/)
+        expect { subject.call }.to raise_error(/does not match/)
       end
     end
     context "missing port number url" do
@@ -201,7 +201,7 @@ describe 'apt::key' do
         }
       end
       it 'fails' do
-        expect { subject }.to raise_error(/does not match/)
+        expect { subject.call }.to raise_error(/does not match/)
       end
     end
     context "url ending with a dot" do
@@ -211,7 +211,7 @@ describe 'apt::key' do
         }
       end
       it 'fails' do
-        expect { subject }.to raise_error(/does not match/)
+        expect { subject.call }.to raise_error(/does not match/)
       end
     end
     context "url begin with a dash" do
@@ -219,7 +219,7 @@ describe 'apt::key' do
         :server => "hkp://-pgp.mit.edu",
       } end
       it 'fails' do
-        expect { subject }.to raise_error(/does not match/)
+        expect { subject.call }.to raise_error(/does not match/)
       end
     end
     context 'invalid key' do
@@ -227,7 +227,7 @@ describe 'apt::key' do
         'Out of rum. Why? Why are we out of rum?'
       end
       it 'fails' do
-        expect { subject }.to raise_error(/does not match/)
+        expect { subject.call }.to raise_error(/does not match/)
       end
     end
 
@@ -236,7 +236,7 @@ describe 'apt::key' do
         :source => 'afp://puppetlabs.com/key.gpg',
       } end
       it 'fails' do
-        expect { subject }.to raise_error(/does not match/)
+        expect { subject.call }.to raise_error(/does not match/)
       end
     end
 
@@ -245,7 +245,7 @@ describe 'apt::key' do
         :content => [],
       } end
       it 'fails' do
-        expect { subject }.to raise_error(/is not a string/)
+        expect { subject.call }.to raise_error(/is not a string/)
       end
     end
 
@@ -254,7 +254,7 @@ describe 'apt::key' do
         :server => 'two bottles of rum',
       } end
       it 'fails' do
-        expect { subject }.to raise_error(/does not match/)
+        expect { subject.call }.to raise_error(/does not match/)
       end
     end
 
@@ -263,7 +263,7 @@ describe 'apt::key' do
         :options => {},
       } end
       it 'fails' do
-        expect { subject }.to raise_error(/is not a string/)
+        expect { subject.call }.to raise_error(/is not a string/)
       end
     end
 
@@ -274,7 +274,7 @@ describe 'apt::key' do
         }
       end
       it 'fails' do
-        expect { subject }.to raise_error(/does not match/)
+        expect { subject.call }.to raise_error(/does not match/)
       end
     end
 
@@ -315,7 +315,7 @@ describe 'apt::key' do
           apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
         end
         it 'informs the user of the impossibility' do
-          expect { subject }.to raise_error(/already ensured as absent/)
+          expect { subject.call }.to raise_error(/already ensured as absent/)
         end
       end
     end
index a11c3b5c253156dcae5b2866286932918f7c99ef..c77bb6ba6e5a5d8c12cf8686cf9398fe7529fff0 100644 (file)
@@ -80,7 +80,7 @@ describe 'apt::pin', :type => :define do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /Only integers are allowed/)
       end
     end
@@ -93,7 +93,7 @@ describe 'apt::pin', :type => :define do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/)
       end
     end
@@ -107,7 +107,7 @@ describe 'apt::pin', :type => :define do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
       end
     end
@@ -122,7 +122,7 @@ describe 'apt::pin', :type => :define do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
       end
     end
@@ -137,7 +137,7 @@ describe 'apt::pin', :type => :define do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
       end
     end
index 521b42ba2b47897fc99b9c8b59f5769b73dfac59..7046475736e9b4d58f3e7e8961a3a265a5b7fbff 100644 (file)
@@ -279,7 +279,7 @@ describe 'apt::ppa' do
       let(:title) { 'ppa:foo' }
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
       end
     end
@@ -297,7 +297,7 @@ describe 'apt::ppa' do
       let(:title) { 'ppa:foo' }
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /not currently supported on Debian/)
       end
     end
index 6f09f9ccf084447a62838f3544eefcc4e265f587..16c80163aa960af0f151585f19e64331baa1daec 100644 (file)
@@ -10,7 +10,7 @@ describe 'apt::setting' do
   describe 'when using the defaults' do
     context 'without source or content' do
       it do
-        expect { is_expected.to compile }.to raise_error(Puppet::Error, /needs either of /)
+        expect { subject.call }.to raise_error(Puppet::Error, /needs either of /)
       end
     end
 
@@ -74,7 +74,7 @@ describe 'apt::setting' do
     context 'with source and content' do
       let(:params) { default_params.merge({ :source => 'la' }) }
       it do
-        expect { is_expected.to compile }.to raise_error(Puppet::Error, /cannot have both /)
+        expect { subject.call }.to raise_error(Puppet::Error, /cannot have both /)
       end
     end
 
@@ -82,21 +82,21 @@ describe 'apt::setting' do
       let(:title) { 'ext-teddybear' }
       let(:params) { default_params }
       it do
-        expect { is_expected.to compile }.to raise_error(Puppet::Error, /must start with /)
+        expect { subject.call }.to raise_error(Puppet::Error, /must start with /)
       end
     end
 
     context 'with ensure=banana' do
       let(:params) { default_params.merge({ :ensure => 'banana' }) }
       it do
-        expect { is_expected.to compile }.to raise_error(Puppet::Error, /"banana" does not /)
+        expect { subject.call }.to raise_error(Puppet::Error, /"banana" does not /)
       end
     end
 
     context 'with priority=1.2' do
       let(:params) { default_params.merge({ :priority => 1.2 }) }
       it do
-        expect { is_expected.to compile }.to raise_error(Puppet::Error, /be an integer /)
+        expect { subject.call }.to raise_error(Puppet::Error, /be an integer /)
       end
     end
   end
index 3900158a1612cc48b8995195c40e5dae655515d0..24f50f79633389ecfa66b7586e264079bc1d5e7e 100644 (file)
@@ -22,7 +22,7 @@ describe 'apt::source' do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /source entry without specifying a location/)
       end
     end
@@ -256,7 +256,7 @@ describe 'apt::source' do
 
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
       end
     end
@@ -278,7 +278,7 @@ describe 'apt::source' do
 
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /invalid value for pin/)
       end
     end