Merge pull request #441 from mhaskel/use_setting
[puppet-modules/puppetlabs-apt.git] / spec / defines / key_spec.rb
index dbb67c4c57439beec2679ea7d2005448b74c9d55..c6f3752e809749b658151bf4caf7bef43d2e2e47 100644 (file)
@@ -1,8 +1,8 @@
 require 'spec_helper'
 
 describe 'apt::key', :type => :define do
-  let(:facts) { { :lsbdistid => 'Debian' } }
-  GPG_KEY_ID = '4BD6EC30'
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
+  GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
 
   let :title do
     GPG_KEY_ID
@@ -11,7 +11,7 @@ describe 'apt::key', :type => :define do
   describe 'normal operation' do
     describe 'default options' do
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
+        is_expected.to contain_apt_key(title).with({
           :id                => title,
           :ensure            => 'present',
           :source            => nil,
@@ -21,7 +21,7 @@ describe 'apt::key', :type => :define do
         })
       end
       it 'contains the apt_key present anchor' do
-        should contain_anchor("apt_key #{title} present")
+        is_expected.to contain_anchor("apt_key #{title} present")
       end
     end
 
@@ -35,7 +35,7 @@ describe 'apt::key', :type => :define do
       } end
 
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
+        is_expected.to contain_apt_key(title).with({
           :id                => GPG_KEY_ID,
           :ensure            => 'present',
           :source            => nil,
@@ -45,7 +45,7 @@ describe 'apt::key', :type => :define do
         })
       end
       it 'contains the apt_key present anchor' do
-        should contain_anchor("apt_key #{GPG_KEY_ID} present")
+        is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present")
       end
     end
 
@@ -55,7 +55,7 @@ describe 'apt::key', :type => :define do
       } end
 
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
+        is_expected.to contain_apt_key(title).with({
           :id                => title,
           :ensure            => 'absent',
           :source            => nil,
@@ -65,7 +65,7 @@ describe 'apt::key', :type => :define do
         })
       end
       it 'contains the apt_key absent anchor' do
-        should contain_anchor("apt_key #{title} absent")
+        is_expected.to contain_anchor("apt_key #{title} absent")
       end
     end
 
@@ -78,7 +78,7 @@ describe 'apt::key', :type => :define do
       } end
 
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
+        is_expected.to contain_apt_key(title).with({
           :id                => title,
           :ensure            => 'present',
           :source            => 'http://apt.puppetlabs.com/pubkey.gpg',
@@ -88,7 +88,7 @@ describe 'apt::key', :type => :define do
         })
       end
       it 'contains the apt_key present anchor' do
-        should contain_anchor("apt_key #{title} present")
+        is_expected.to contain_anchor("apt_key #{title} present")
       end
     end
 
@@ -97,7 +97,7 @@ describe 'apt::key', :type => :define do
         :key_server => 'p-gp.m-it.edu',
       } end
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
+        is_expected.to contain_apt_key(title).with({
           :id        => title,
           :server => 'p-gp.m-it.edu',
         })
@@ -111,7 +111,7 @@ describe 'apt::key', :type => :define do
         }
       end
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
+        is_expected.to contain_apt_key(title).with({
           :id        => title,
           :server => 'hkp://pgp.mit.edu',
         })
@@ -124,7 +124,7 @@ describe 'apt::key', :type => :define do
         }
       end
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
+        is_expected.to contain_apt_key(title).with({
           :id        => title,
           :server => 'hkp://pgp.mit.edu:80',
         })
@@ -276,22 +276,22 @@ describe 'apt::key', :type => :define do
     describe 'duplication' do
       context 'two apt::key resources for same key, different titles' do
         let :pre_condition do
-          "apt::key { 'duplicate': key => #{title}, }"
+          "apt::key { 'duplicate': key => '#{title}', }"
         end
 
         it 'contains two apt::key resources' do
-          should contain_apt__key('duplicate').with({
+          is_expected.to contain_apt__key('duplicate').with({
             :key    => title,
             :ensure => 'present',
           })
-          should contain_apt__key(title).with({
+          is_expected.to contain_apt__key(title).with({
             :key    => title,
             :ensure => 'present',
           })
         end
 
         it 'contains only a single apt_key' do
-          should contain_apt_key('duplicate').with({
+          is_expected.to contain_apt_key('duplicate').with({
             :id                => title,
             :ensure            => 'present',
             :source            => nil,
@@ -299,13 +299,13 @@ describe 'apt::key', :type => :define do
             :content           => nil,
             :keyserver_options => nil,
           })
-          should_not contain_apt_key(title)
+          is_expected.not_to contain_apt_key(title)
         end
       end
 
       context 'two apt::key resources, different ensure' do
         let :pre_condition do
-          "apt::key { 'duplicate': key => #{title}, ensure => 'absent', }"
+          "apt::key { 'duplicate': key => '#{title}', ensure => 'absent', }"
         end
         it 'informs the user of the impossibility' do
           expect { subject }.to raise_error(/already ensured as absent/)