From 6e97016aace7838180ac3c4b51ef04e5951d4681 Mon Sep 17 00:00:00 2001 From: Max Wilhelm Date: Thu, 17 Aug 2017 13:26:03 +0200 Subject: [PATCH] use rspec-puppet-facts for fluentd_service_spec --- spec/classes/fluentd_repo_yum_spec.rb | 1 - spec/classes/fluentd_service_spec.rb | 50 +++++++++------------------ 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/spec/classes/fluentd_repo_yum_spec.rb b/spec/classes/fluentd_repo_yum_spec.rb index 7bcd865..6c854c7 100644 --- a/spec/classes/fluentd_repo_yum_spec.rb +++ b/spec/classes/fluentd_repo_yum_spec.rb @@ -7,7 +7,6 @@ describe 'fluentd::repo::yum', :type => :class do facts end - describe 'when called with no parameters' do case facts[:osfamily] when 'RedHat' diff --git a/spec/classes/fluentd_service_spec.rb b/spec/classes/fluentd_service_spec.rb index 16c00a3..c0da9fd 100644 --- a/spec/classes/fluentd_service_spec.rb +++ b/spec/classes/fluentd_service_spec.rb @@ -1,39 +1,23 @@ require 'spec_helper' describe 'fluentd::config', :type => :class do - shared_examples 'when called with no parameters' do - it { - should contain_service('fluentd').with({ - 'name' => 'td-agent', - 'ensure' => 'running', - 'enable' => 'true', - 'hasstatus' => 'true', - 'hasrestart' => 'true' - }) - } - end + on_supported_os.each do |os, facts| + context "on #{os}" do + let :facts do + facts + end - context 'when osfamily is Debian' do - let(:facts) { - { - :osfamily => 'Debian', - :lsbdistid => 'Ubuntu', - :operatingsystem => 'Ubuntu', - :lsbdistcodename => 'precise', - :architecture => 'amd64', - } - } - - include_examples 'when called with no parameters' - end - - context 'when osfamily is RedHat' do - let(:facts) { - { - :osfamily => 'RedHat', - } - } - - include_examples 'when called with no parameters' + describe 'when called with no parameters' do + it { + should contain_service('fluentd').with({ + 'name' => 'td-agent', + 'ensure' => 'running', + 'enable' => 'true', + 'hasstatus' => 'true', + 'hasrestart' => 'true' + }) + } + end + end end end