fixed test for changing aptitude to apt-get
[puppet-modules/puppetlabs-apt.git] / spec / defines / pin_spec.rb
index ac61864555170cd13cd634fab1a483f3c038a086..3aaf49cef494e79f3b4fce0c2e2e02ba91d7915d 100644 (file)
@@ -4,20 +4,38 @@ describe 'apt::pin', :type => :define do
 
   let :default_params do
     {
+      :ensure   => 'present',
+      :order    => '',
       :packages => '*',
-      :priority => '0'
+      :priority => '0',
+      :release  => nil
     }
   end
 
-  [{},
-   {
+  [ {},
+    {
       :packages  => 'apache',
       :priority  => '1'
+    },
+    {
+      :order     => 50,
+      :packages  => 'apache',
+      :priority  => '1'
+    },
+    {
+      :ensure    => 'absent',
+      :packages  => 'apache',
+      :priority  => '1'
+    },
+    {
+      :packages  => 'apache',
+      :priority  => '1',
+      :release   => 'my_newpin'
     }
   ].each do |param_set|
     describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
       let :param_hash do
-        param_set == {} ? default_params : params
+        default_params.merge(param_set)
       end
 
       let :params do
@@ -26,13 +44,14 @@ describe 'apt::pin', :type => :define do
 
       it { should include_class("apt::params") }
 
-      it { should create_file("#{title}.pref")\
-        .with_path("/etc/apt/preferences.d/#{title}")\
-        .with_ensure("file")\
-        .with_owner("root")\
-        .with_group("root")\
-        .with_mode("644")\
-        .with_content("# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{title}\nPin-Priority: #{param_hash[:priority]}")
+      it { should contain_file("#{title}.pref").with({
+          'ensure'  => param_hash[:ensure],
+          'path'    => "/etc/apt/preferences.d/#{param_hash[:order] == '' ? "" : "#{param_hash[:order]}-"}#{title}.pref",
+          'owner'   => 'root',
+          'group'   => 'root',
+          'mode'    => '0644',
+          'content' => "# #{title}\nExplanation: : #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{param_hash[:release] || title}\nPin-Priority: #{param_hash[:priority]}\n",
+        })
       }
     end
   end