+ describe 'on Debian' do
+ default_facts = { :lsbdistid => 'Debian' }
+ context 'defaults' do
+ let :facts do default_facts end
+ it {
+ should contain_file(file_unattended).with_content(
+ /^Unattended-Upgrade::Origins-Pattern/
+ ).with_content(
+ /"origin=Debian,archive=stable,label=Debian-Security";/
+ )
+ }
+ end
+ context 'defaults with custom origin' do
+ let :facts do default_facts end
+ let :params do { :origins => ['bananana']} end
+ it {
+ should contain_file(file_unattended).with_content(
+ /^Unattended-Upgrade::Origins-Pattern/
+ ).with_content(
+ /"bananana";/
+ )
+ }
+ end
+ context 'defaults with invalid origin' do
+ let :facts do default_facts end
+ let :params do { :origins => 'bananana'} end
+ it {
+ expect {subject}.to raise_error(/is not an Array/)
+ }
+ end
+ context 'squeeze' do
+ let :facts do default_facts.merge({:lsbdistcodename => 'squeeze'}) end
+ it {
+ should contain_file(file_unattended).with_content(
+ /^Unattended-Upgrade::Allowed-Origins/
+ ).with_content(
+ /"\${distro_id} \${distro_codename}-security";/
+ ).with_content(
+ /"\${distro_id} oldstable";/
+ )
+ }
+ end
+ context 'wheezy' do
+ let :facts do default_facts.merge({:lsbdistcodename => 'wheezy'}) end
+ it {
+ should contain_file(file_unattended).with_content(
+ /^Unattended-Upgrade::Origins-Pattern/
+ ).with_content(
+ /"origin=Debian,archive=stable,label=Debian-Security";/
+ )
+ }
+ end