Fixed tests for cf04f76
[puppet-modules/puppetlabs-apt.git] / spec / defines / ppa_spec.rb
index b768b25d3fbf9ca899b3c48a5c7b3c14f584666e..5b59f57776bc389e4f1c4bf7e9ef24ac09ab8e67 100644 (file)
@@ -20,6 +20,9 @@ describe 'apt::ppa', :type => :define do
       let :package do
         "#{platform[:package]}"
       end
+      let :options do
+        "-y"
+      end
       ['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t|
         describe "with title #{t}" do
           let :pre_condition do
@@ -41,8 +44,8 @@ describe 'apt::ppa', :type => :define do
           }
 
           it { should contain_exec("add-apt-repository-#{t}").with(
-            'command' => "/usr/bin/add-apt-repository #{t}",
-            'creates' => "/etc/apt/sources.list.d/#{filename}",
+            'command' => "/usr/bin/add-apt-repository #{options} #{t}",
+            'unless'  => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
             'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
             'notify'  => "Exec[apt_update]"
             )
@@ -64,14 +67,14 @@ describe 'apt::ppa', :type => :define do
              proxy_host => false
           }'
         end
-          let :filename do
-            "#{title}-#{release}.list"
-          end
+        let :filename do
+          "#{title}-#{release}.list"
+        end
 
         it { should contain_exec("add-apt-repository-#{title}").with(
           'environment' => [],
-          'command'     => "/usr/bin/add-apt-repository #{title}",
-          'creates'     => "/etc/apt/sources.list.d/#{filename}",
+          'command'     => "/usr/bin/add-apt-repository #{options} #{title}",
+          'unless'      => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
           'require'     => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
           'notify'      => "Exec[apt_update]"
           )
@@ -96,8 +99,8 @@ describe 'apt::ppa', :type => :define do
             "http_proxy=http://user:pass@proxy:8080",
             "https_proxy=http://user:pass@proxy:8080",
           ],
-          'command'     => "/usr/bin/add-apt-repository #{title}",
-          'creates'     => "/etc/apt/sources.list.d/#{filename}",
+          'command'     => "/usr/bin/add-apt-repository #{options} #{title}",
+          'unless'      => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
           'require'     => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
           'notify'      => "Exec[apt_update]"
           )