X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fdefines%2Fconf_spec.rb;h=e96f8bcd8299b9c2c3902f4603ba25ed802a6244;hb=fe609807819cbf8126c3ae43cd96da7a62bce9a7;hp=ec4e229c4449f5122f340ce61a16bc60cd82ff09;hpb=239232bbd44c6dabc3f305bd23b354481d9f8a71;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index ec4e229..e96f8bc 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -1,6 +1,9 @@ require 'spec_helper' describe 'apt::conf', :type => :define do - let(:facts) { { :lsbdistid => 'Debian' } } + let :pre_condition do + 'class { "apt": }' + end + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } let :title do 'norecommends' end @@ -17,9 +20,9 @@ describe 'apt::conf', :type => :define do "/etc/apt/apt.conf.d/00norecommends" end - it { should contain_file(filename).with({ + it { is_expected.to contain_file(filename).with({ 'ensure' => 'present', - 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", + 'content' => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/, 'owner' => 'root', 'group' => 'root', 'mode' => '0644', @@ -27,12 +30,23 @@ describe 'apt::conf', :type => :define do } end + describe "when creating a preference without content" do + let :params do + { + :priority => '00', + } + end + + it 'fails' do + expect { subject } .to raise_error(/pass in content/) + end + end + describe "when removing an apt preference" do let :params do { :ensure => 'absent', :priority => '00', - :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" } end @@ -40,9 +54,8 @@ describe 'apt::conf', :type => :define do "/etc/apt/apt.conf.d/00norecommends" end - it { should contain_file(filename).with({ + it { is_expected.to contain_file(filename).with({ 'ensure' => 'absent', - 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", 'owner' => 'root', 'group' => 'root', 'mode' => '0644',