Don't stub puppetversion
[puppet-modules/puppetlabs-apt.git] / spec / defines / setting_spec.rb
index 19794115dd64991c4e3e27f458300d556551ac21..b109ea6b6b499834f0ac0a6ae7472f6f55136c2a 100644 (file)
@@ -2,7 +2,7 @@ require 'spec_helper'
 
 describe 'apt::setting' do
   let(:pre_condition) { 'class { "apt": }' }
-  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version, } }
   let(:title) { 'conf-teddybear' }
 
   let(:default_params) { { :content => 'di' } }
@@ -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
 
@@ -55,11 +55,26 @@ describe 'apt::setting' do
     end
   end
 
+  describe 'settings requiring settings, MODULES-769' do
+    let(:pre_condition) do
+      'class { "apt": }
+      apt::setting { "list-teddybear": content => "foo" }
+      '
+    end
+    let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version, } }
+    let(:title) { 'conf-teddybear' }
+    let(:default_params) { { :content => 'di' } }
+
+    let(:params) { default_params.merge({ :require => 'Apt::Setting[list-teddybear]' }) }
+
+    it { is_expected.to compile.with_all_deps }
+  end
+
   describe 'when trying to pull one over' 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
 
@@ -67,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