From ffc4e32f400693ff32350c14949a9b0d2e1373a0 Mon Sep 17 00:00:00 2001 From: Tobias Urdin Date: Thu, 8 Nov 2018 11:15:49 +0100 Subject: [PATCH] Convert spec testing to rspec-puppet-facts Change-Id: I57fe44d8d6bc03d7560f68024c6af85a09936c92 --- spec/classes/heat_config_spec.rb | 36 ++++++++++++++++++++++---------- spec/classes/heat_deps_spec.rb | 35 +++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 22 deletions(-) diff --git a/spec/classes/heat_config_spec.rb b/spec/classes/heat_config_spec.rb index c2091eef..c6a0fc63 100644 --- a/spec/classes/heat_config_spec.rb +++ b/spec/classes/heat_config_spec.rb @@ -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 diff --git a/spec/classes/heat_deps_spec.rb b/spec/classes/heat_deps_spec.rb index 11bb63d2..9b132f48 100644 --- a/spec/classes/heat_deps_spec.rb +++ b/spec/classes/heat_deps_spec.rb @@ -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