require 'spec_helper'
describe 'apt::key', :type => :define do
- let(:facts) { { :lsbdistid => 'Debian' } }
+ let(:facts) { {
+ :lsbdistid => 'Debian',
+ :osfamily => 'Debian',
+ } }
GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
let :title do
GPG_KEY_ID
end
+ let :pre_condition do
+ 'include apt'
+ end
+
describe 'normal operation' do
describe 'default options' do
- it 'contains the apt_key' do
- should contain_apt_key(title).with({
+ it {
+ is_expected.to contain_apt_key(title).with({
:id => title,
:ensure => 'present',
:source => nil,
- :server => nil,
+ :server => 'keyserver.ubuntu.com',
:content => nil,
:keyserver_options => nil,
})
- 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
} 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,
- :server => nil,
+ :server => 'keyserver.ubuntu.com',
:content => nil,
:keyserver_options => nil,
})
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
} 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,
- :server => nil,
+ :server => 'keyserver.ubuntu.com',
:content => nil,
:keyserver_options => nil,
})
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
} 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',
})
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
: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',
})
}
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',
})
}
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',
})
describe 'duplication' do
context 'two apt::key resources for same key, different titles' do
let :pre_condition do
- "apt::key { 'duplicate': key => '#{title}', }"
+ "#{super()}\napt::key { 'duplicate': key => '#{title}', }"
end
- it 'contains two apt::key resources' do
- should contain_apt__key('duplicate').with({
+ it 'contains the duplicate apt::key resource' do
+ is_expected.to contain_apt__key('duplicate').with({
:key => title,
:ensure => 'present',
})
- should contain_apt__key(title).with({
+ end
+
+ it 'contains the original apt::key resource' do
+ is_expected.to contain_apt__key(title).with({
:id => title,
:ensure => 'present',
})
end
- it 'contains only a single apt_key' do
- should contain_apt_key('duplicate').with({
+ it 'contains the native apt_key' do
+ is_expected.to contain_apt_key('duplicate').with({
:id => title,
:ensure => 'present',
:source => nil,
- :server => nil,
+ :server => 'keyserver.ubuntu.com',
:content => nil,
:keyserver_options => nil,
})
- should_not contain_apt_key(title)
+ end
+
+ it 'does not contain the original apt_key' do
+ 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', }"
+ "#{super()}\napt::key { 'duplicate': key => '#{title}', ensure => 'absent', }"
end
it 'informs the user of the impossibility' do
expect { subject.call }.to raise_error(/already ensured as absent/)