forked from theforeman/puppet-foreman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforeman_plugin_spec.rb
82 lines (71 loc) · 2.3 KB
/
foreman_plugin_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require 'spec_helper'
describe 'foreman::plugin' do
let :title do 'myplugin' end
on_supported_os.each do |os, facts|
context "on #{os}" do
let :facts do facts end
let :pre_condition do
'include foreman'
end
context 'no parameters' do
package_name = case facts[:osfamily]
when 'RedHat'
facts[:os]['release']['major'] == '7' ? 'tfm-rubygem-foreman_myplugin' : 'rubygem-foreman_myplugin'
when 'Debian'
'ruby-foreman-myplugin'
end
it { should compile.with_all_deps }
it { should contain_package(package_name).with_ensure('present') }
it { should_not contain_file('/etc/foreman/plugins/foreman_myplugin.yaml') }
it do
should contain_foreman__plugin('myplugin')
.that_comes_before('Class[foreman::database]')
.that_notifies('Class[foreman::service]')
end
end
context 'with package parameter' do
let :params do
{
package: 'myplugin'
}
end
it 'should install the correct package' do
should contain_package('myplugin').with_ensure('present')
end
end
context 'when handling underscores' do
let :params do
{
package: 'my_fun_plugin'
}
end
package_name = case facts[:osfamily]
when 'RedHat'
'my_fun_plugin'
when 'Debian'
'my-fun-plugin'
end
it 'should use underscores' do
should contain_package(package_name).with_ensure('present')
end
end
context 'when specifying a config' do
let :params do
{
config: 'the config content',
package: 'myplugin'
}
end
it 'should contain the config file' do
should contain_file('/etc/foreman/plugins/foreman_myplugin.yaml')
.with_ensure('file')
.with_owner('root')
.with_group('foreman')
.with_mode('0640')
.with_content('the config content')
.that_requires('Package[myplugin]')
end
end
end
end
end