Merge pull request #9 from bodepd/10451_fix_apt_update_refresh
[puppet-modules/puppetlabs-apt.git] / spec / defines / ppa_spec.rb
1 require 'spec_helper'
2 describe 'apt::ppa', :type => :define do
3   ['ppa:dans_ppa', 'dans_ppa'].each do |t|
4     describe "with title #{t}" do
5       let :pre_condition do
6         'class { "apt": }'
7       end
8       let :title do
9         t
10       end
11       let :unless_statement do
12         if t =~ /ppa:(.*)/
13           /^[^#].*ppa.*#{$1}.*$/
14         else
15           /^[^#].*#{t}.*$/
16         end
17       end
18       it { should contain_exec("add-apt-repository-#{t}").with(
19         'command' => "/usr/bin/add-apt-repository #{t}",
20         'notify'  => "Exec[apt-update-#{t}]"
21         )
22       }
23       it { should contain_exec("add-apt-repository-#{t}").with_unless(unless_statement) }
24       it { should contain_exec("apt-update-#{t}").with(
25         'command'     => '/usr/bin/aptitude update',
26         'refreshonly' => true
27         )
28       }
29       it { should contain_exec("apt-update-#{t}").without_unless }
30     end
31   end
32 end