try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / nova / spec / shared_examples.rb
1 shared_examples_for "a Puppet::Error" do |description|
2   it "with message matching #{description.inspect}" do
3     expect { should have_class_count(1) }.to raise_error(Puppet::Error, description)
4   end
5 end
6
7 shared_examples 'generic nova service' do |service|
8
9   context 'with default parameters' do
10     it 'installs package and service' do
11       should contain_package(service[:name]).with({
12         :name   => service[:package_name],
13         :ensure => 'present',
14         :notify => "Service[#{service[:name]}]",
15         :tag    => ['openstack', 'nova']
16       })
17       should contain_service(service[:name]).with({
18         :name      => service[:service_name],
19         :ensure    => 'stopped',
20         :hasstatus => true,
21         :enable    => false
22       })
23     end
24   end
25
26   context 'with overridden parameters' do
27     let :params do
28       { :enabled        => true,
29         :ensure_package => '2012.1-2' }
30     end
31
32     it 'installs package and service' do
33       should contain_package(service[:name]).with({
34         :name   => service[:package_name],
35         :ensure => '2012.1-2',
36         :notify => "Service[#{service[:name]}]"
37       })
38       should contain_service(service[:name]).with({
39         :name      => service[:service_name],
40         :ensure    => 'running',
41         :hasstatus => true,
42         :enable    => true
43       })
44     end
45   end
46
47   context 'while not managing service state' do
48     let :params do
49       { :enabled        => false,
50         :manage_service => false }
51     end
52
53     it 'does not control service state' do
54       should contain_service(service[:name]).without_ensure
55     end
56   end
57 end