Merge pull request #58 from nanliu/tb/ppa
[puppet-modules/puppetlabs-apt.git] / spec / defines / pin_spec.rb
index ac61864555170cd13cd634fab1a483f3c038a086..b5b10d702b9f32885540706a256c8b6b7b463444 100644 (file)
@@ -4,20 +4,32 @@ describe 'apt::pin', :type => :define do
 
   let :default_params do
     {
+      :ensure   => 'present',
       :packages => '*',
-      :priority => '0'
+      :priority => '0',
+      :release  => nil
     }
   end
 
-  [{},
-   {
+  [ {},
+    {
+      :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 +38,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/#{title}",
+          'owner'   => 'root',
+          'group'   => 'root',
+          'mode'    => '0644',
+          'content' => "# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{param_hash[:release] || title}\nPin-Priority: #{param_hash[:priority]}",
+        })
       }
     end
   end