Convert spec testing to rspec-puppet-facts

Change-Id: I57fe44d8d6bc03d7560f68024c6af85a09936c92
This commit is contained in:
Tobias Urdin 2018-11-08 11:15:49 +01:00
parent 432c51e52a
commit ffc4e32f40
2 changed files with 49 additions and 22 deletions

View File

@ -3,7 +3,8 @@ require 'spec_helper'
describe 'heat::config' do
let :params do
{ :heat_config => {
{
:heat_config => {
'DEFAULT/foo' => { 'value' => 'fooValue' },
'DEFAULT/bar' => { 'value' => 'barValue' },
'DEFAULT/baz' => { 'ensure' => 'absent' }
@ -16,18 +17,31 @@ describe 'heat::config' do
}
end
it { is_expected.to contain_class('heat::deps') }
shared_examples 'heat::config' do
it { should contain_class('heat::deps') }
it 'configures arbitrary heat configurations' do
is_expected.to contain_heat_config('DEFAULT/foo').with_value('fooValue')
is_expected.to contain_heat_config('DEFAULT/bar').with_value('barValue')
is_expected.to contain_heat_config('DEFAULT/baz').with_ensure('absent')
it {
should contain_heat_config('DEFAULT/foo').with_value('fooValue')
should contain_heat_config('DEFAULT/bar').with_value('barValue')
should contain_heat_config('DEFAULT/baz').with_ensure('absent')
}
it {
should contain_heat_api_paste_ini('DEFAULT/foo2').with_value('fooValue')
should contain_heat_api_paste_ini('DEFAULT/bar2').with_value('barValue')
should contain_heat_api_paste_ini('DEFAULT/baz2').with_ensure('absent')
}
end
it 'configures arbitrary heat-api-paste configurations' do
is_expected.to contain_heat_api_paste_ini('DEFAULT/foo2').with_value('fooValue')
is_expected.to contain_heat_api_paste_ini('DEFAULT/bar2').with_value('barValue')
is_expected.to contain_heat_api_paste_ini('DEFAULT/baz2').with_ensure('absent')
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'heat::config'
end
end
end

View File

@ -1,17 +1,30 @@
require 'spec_helper'
describe 'heat::deps' do
shared_examples 'heat::deps' do
it {
should contain_anchor('heat::install::begin')
should contain_anchor('heat::install::end')
should contain_anchor('heat::config::begin')
should contain_anchor('heat::config::end')
should contain_anchor('heat::db::begin')
should contain_anchor('heat::db::end')
should contain_anchor('heat::dbsync::begin')
should contain_anchor('heat::dbsync::end')
should contain_anchor('heat::service::begin')
should contain_anchor('heat::service::end')
}
end
it 'set up the anchors' do
is_expected.to contain_anchor('heat::install::begin')
is_expected.to contain_anchor('heat::install::end')
is_expected.to contain_anchor('heat::config::begin')
is_expected.to contain_anchor('heat::config::end')
is_expected.to contain_anchor('heat::db::begin')
is_expected.to contain_anchor('heat::db::end')
is_expected.to contain_anchor('heat::dbsync::begin')
is_expected.to contain_anchor('heat::dbsync::end')
is_expected.to contain_anchor('heat::service::begin')
is_expected.to contain_anchor('heat::service::end')
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'heat::deps'
end
end
end