X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fdefines%2Fpin_spec.rb;h=1421d68fbdefc96c05b968a71e57e3ed197e30bd;hb=351c8d5941f6bd02304df6b4185dea8c8104aefa;hp=206dbf1e011e4a6b336826d63bc9528319177713;hpb=61080fb6760e3d28b04158a3a2e1f3a055a2854e;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 206dbf1..1421d68 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -1,16 +1,16 @@ require 'spec_helper' describe 'apt::pin', :type => :define do + let :pre_condition do + 'class { "apt": }' + end let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let(:title) { 'my_pin' } context 'defaults' do - it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)} - it { is_expected.to contain_file("my_pin.pref").with({ - 'ensure' => 'present', - 'path' => '/etc/apt/preferences.d/my_pin.pref', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', + it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)} + it { is_expected.to contain_apt__setting("pref-my_pin").with({ + 'setting_type' => 'pref', + 'base_name' => 'my_pin', }) } end @@ -22,13 +22,10 @@ describe 'apt::pin', :type => :define do 'version' => '1', } end - it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)} - it { is_expected.to contain_file("my_pin.pref").with({ - 'ensure' => 'present', - 'path' => '/etc/apt/preferences.d/my_pin.pref', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', + it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)} + it { is_expected.to contain_apt__setting("pref-my_pin").with({ + 'setting_type' => 'pref', + 'base_name' => 'my_pin', }) } end @@ -40,13 +37,10 @@ describe 'apt::pin', :type => :define do 'origin' => 'test', } end - it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)} - it { is_expected.to contain_file("my_pin.pref").with({ - 'ensure' => 'present', - 'path' => '/etc/apt/preferences.d/my_pin.pref', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', + it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)} + it { is_expected.to contain_apt__setting("pref-my_pin").with({ + 'setting_type' => 'pref', + 'base_name' => 'my_pin', }) } end @@ -65,13 +59,11 @@ describe 'apt::pin', :type => :define do 'priority' => 10, } end - it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) } - it { is_expected.to contain_file("my_pin.pref").with({ - 'ensure' => 'present', - 'path' => '/etc/apt/preferences.d/99-my_pin.pref', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', + it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) } + it { is_expected.to contain_apt__setting("pref-my_pin").with({ + 'setting_type' => 'pref', + 'base_name' => 'my_pin', + 'priority' => 99, }) } end @@ -82,7 +74,7 @@ describe 'apt::pin', :type => :define do 'ensure' => 'absent' } end - it { is_expected.to contain_file("my_pin.pref").with({ + it { is_expected.to contain_apt__setting("pref-my_pin").with({ 'ensure' => 'absent', }) } @@ -90,7 +82,7 @@ describe 'apt::pin', :type => :define do context 'bad characters' do let(:title) { 'such bad && wow!' } - it { is_expected.to contain_file("such__bad____wow_.pref") } + it { is_expected.to contain_apt__setting("pref-such__bad____wow_") } end describe 'validation' do @@ -102,7 +94,7 @@ describe 'apt::pin', :type => :define do end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /Only integers are allowed/) end end @@ -115,7 +107,7 @@ describe 'apt::pin', :type => :define do end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/) end end @@ -129,7 +121,7 @@ describe 'apt::pin', :type => :define do end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/) end end @@ -144,7 +136,7 @@ describe 'apt::pin', :type => :define do end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/) end end @@ -159,7 +151,7 @@ describe 'apt::pin', :type => :define do end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/) end end