From b51a559684d895a4a87dd405bb8fea8fa32ed26e Mon Sep 17 00:00:00 2001 From: Max Wilhelm Date: Mon, 14 Aug 2017 17:55:39 +0200 Subject: [PATCH] use rspec-puppet-facts for fluentd_config_spec --- spec/classes/fluentd_config_spec.rb | 61 +++++++++++------------------ 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/spec/classes/fluentd_config_spec.rb b/spec/classes/fluentd_config_spec.rb index aa4e1e3..cdbb578 100644 --- a/spec/classes/fluentd_config_spec.rb +++ b/spec/classes/fluentd_config_spec.rb @@ -1,46 +1,31 @@ require 'spec_helper' describe 'fluentd::config', :type => :class do - shared_examples 'when called with no parameters' do - it { - should contain_file('/etc/td-agent/td-agent.conf').with({ - 'ensure' => 'file', - 'owner' => 'root', - 'group' => 'root', - 'source' => 'puppet:///modules/fluentd/td-agent.conf', - 'notify' => 'Class[Fluentd::Service]' - }) + on_supported_os.each do |os, facts| + context "on #{os}" do + let :facts do + facts + end - should contain_file('/etc/td-agent/conf.d').with({ - 'ensure' => 'directory', - 'owner' => 'td-agent', - 'group' => 'td-agent', - 'mode' => '0750' - }) - } - end + describe 'when called with no parameters' do - context 'when osfamily is Debian' do - let(:facts) { - { - :osfamily => 'Debian', - :lsbdistid => 'Ubuntu', - :operatingsystem => 'Ubuntu', - :lsbdistcodename => 'precise', - :architecture => 'amd64', - } - } + it { + should contain_file('/etc/td-agent/td-agent.conf').with({ + 'ensure' => 'file', + 'owner' => 'root', + 'group' => 'root', + 'source' => 'puppet:///modules/fluentd/td-agent.conf', + 'notify' => 'Class[Fluentd::Service]' + }) - 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' + should contain_file('/etc/td-agent/conf.d').with({ + 'ensure' => 'directory', + 'owner' => 'td-agent', + 'group' => 'td-agent', + 'mode' => '0750' + }) + } + end + end end end