diff --git a/spec/classes/puppet_agent_config_spec.rb b/spec/classes/puppet_agent_config_spec.rb index dbef7e11..bf1d97b8 100644 --- a/spec/classes/puppet_agent_config_spec.rb +++ b/spec/classes/puppet_agent_config_spec.rb @@ -2,17 +2,10 @@ describe 'puppet::agent::config' do - on_supported_os.each do |os, facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) + on_os_under_test.each do |os, facts| next if facts[:osfamily] == 'windows' # TODO, see https://github.com/fessyfoo/rspec-puppet-windows-issue context "on #{os}" do - let(:facts) do - facts.merge({ - :concat_basedir => '/foo/bar', - :puppetversion => Puppet.version, - }) - end + let(:facts) { facts } context 'with default parameters' do let :pre_condition do diff --git a/spec/classes/puppet_agent_install_spec.rb b/spec/classes/puppet_agent_install_spec.rb index 5766d05f..827b16ba 100644 --- a/spec/classes/puppet_agent_install_spec.rb +++ b/spec/classes/puppet_agent_install_spec.rb @@ -1,30 +1,22 @@ require 'spec_helper' describe 'puppet::agent::install' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) + on_os_under_test.each do |os, facts| context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :concat_basedir => '/nonexistant', - :puppetversion => Puppet.version, - }) end - if Puppet.version < '4.0' - if os_facts[:osfamily] == 'FreeBSD' + if facts[:osfamily] == 'FreeBSD' client_package = 'puppet38' else client_package = 'puppet' end additional_facts = {} else - if os_facts[:osfamily] == 'FreeBSD' + if facts[:osfamily] == 'FreeBSD' client_package = 'puppet4' additional_facts = {} else client_package = 'puppet-agent' - if os_facts[:osfamily] == 'windows' + if facts[:osfamily] == 'windows' additional_facts = {} else additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} @@ -33,7 +25,7 @@ end let (:facts) do - default_facts.merge(additional_facts) + facts.merge(additional_facts) end describe 'with default parameters' do @@ -41,7 +33,7 @@ 'include ::puppet' end - if os_facts[:osfamily] == 'windows' + if facts[:osfamily] == 'windows' it 'should define provider as chocolatey on Windows' do should contain_package(client_package).with_provider('chocolatey') end @@ -90,7 +82,7 @@ end end - if os_facts[:osfamily] == 'windows' + if facts[:osfamily] == 'windows' describe "when package_provider => 'msi'" do let :pre_condition do "class { 'puppet': package_provider => 'msi', }" diff --git a/spec/classes/puppet_agent_service_cron_spec.rb b/spec/classes/puppet_agent_service_cron_spec.rb index a61c712e..17d25f11 100644 --- a/spec/classes/puppet_agent_service_cron_spec.rb +++ b/spec/classes/puppet_agent_service_cron_spec.rb @@ -1,18 +1,8 @@ require 'spec_helper' describe 'puppet::agent::service::cron' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) + on_os_under_test.each do |os, facts| context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :clientcert => 'puppetmaster.example.com', - :concat_basedir => '/nonexistant', - :fqdn => 'puppetmaster.example.com', - :puppetversion => Puppet.version, - }) end - if Puppet.version < '4.0' confdir = '/etc/puppet' bindir = '/usr/bin' @@ -23,13 +13,13 @@ additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} end - if os_facts[:osfamily] == 'FreeBSD' + if facts[:osfamily] == 'FreeBSD' bindir = '/usr/local/bin' confdir = '/usr/local/etc/puppet' end let :facts do - default_facts.merge(additional_facts) + facts.merge(additional_facts) end describe 'when runmode is not cron' do @@ -52,7 +42,7 @@ it do case os when /\A(windows|archlinux)/ - should raise_error(Puppet::Error, /Runmode of cron not supported on #{os_facts[:kernel]} operating systems!/) + should raise_error(Puppet::Error, /Runmode of cron not supported on #{facts[:kernel]} operating systems!/) else should contain_cron('puppet').with({ :command => "#{bindir}/puppet agent --config #{confdir}/puppet.conf --onetime --no-daemonize", diff --git a/spec/classes/puppet_agent_service_daemon_spec.rb b/spec/classes/puppet_agent_service_daemon_spec.rb index 53d18e68..1407e3cb 100644 --- a/spec/classes/puppet_agent_service_daemon_spec.rb +++ b/spec/classes/puppet_agent_service_daemon_spec.rb @@ -1,18 +1,8 @@ require 'spec_helper' describe 'puppet::agent::service::daemon' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) + on_os_under_test.each do |os, facts| context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :clientcert => 'puppetmaster.example.com', - :concat_basedir => '/nonexistant', - :fqdn => 'puppetmaster.example.com', - :puppetversion => Puppet.version, - }) end - if Puppet.version < '4.0' confdir = '/etc/puppet' additional_facts = {} @@ -21,12 +11,12 @@ additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} end - if os_facts[:osfamily] == 'FreeBSD' + if facts[:osfamily] == 'FreeBSD' confdir = '/usr/local/etc/puppet' end let :facts do - default_facts.merge(additional_facts) + facts.merge(additional_facts) end describe 'when runmode => daemon' do @@ -51,7 +41,7 @@ it do case os when /\A(windows|archlinux)/ - should raise_error(Puppet::Error, /Runmode of cron not supported on #{os_facts[:kernel]} operating systems!/) + should raise_error(Puppet::Error, /Runmode of cron not supported on #{facts[:kernel]} operating systems!/) else should contain_service('puppet').with({ :ensure => 'stopped', diff --git a/spec/classes/puppet_agent_service_spec.rb b/spec/classes/puppet_agent_service_spec.rb index 2a6203d2..ffdfb744 100644 --- a/spec/classes/puppet_agent_service_spec.rb +++ b/spec/classes/puppet_agent_service_spec.rb @@ -1,18 +1,8 @@ require 'spec_helper' describe 'puppet::agent::service' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) + on_os_under_test.each do |os, facts| context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :clientcert => 'puppetmaster.example.com', - :concat_basedir => '/nonexistant', - :fqdn => 'puppetmaster.example.com', - :puppetversion => Puppet.version, - }) end - if Puppet.version < '4.0' confdir = '/etc/puppet' additional_facts = {} @@ -21,12 +11,12 @@ additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} end - if os_facts[:osfamily] == 'FreeBSD' + if facts[:osfamily] == 'FreeBSD' confdir = '/usr/local/etc/puppet' end let :facts do - default_facts.merge(additional_facts) + facts.merge(additional_facts) end describe 'with no custom parameters' do @@ -59,7 +49,7 @@ case os when /\A(windows|archlinux)/ it do - should raise_error(Puppet::Error, /Runmode of cron not supported on #{os_facts[:kernel]} operating systems!/) + should raise_error(Puppet::Error, /Runmode of cron not supported on #{facts[:kernel]} operating systems!/) end when /\Adebian-8/, /\A(redhat|centos|scientific)-7/, /\Afedora-/, /\Aubuntu-16/ it do @@ -91,7 +81,7 @@ should contain_service('puppet-run.timer').with(:ensure => :running) end else - it { should raise_error(Puppet::Error, /Runmode of systemd.timer not supported on #{os_facts[:kernel]} operating systems!/) } + it { should raise_error(Puppet::Error, /Runmode of systemd.timer not supported on #{facts[:kernel]} operating systems!/) } end end diff --git a/spec/classes/puppet_agent_service_systemd_spec.rb b/spec/classes/puppet_agent_service_systemd_spec.rb index 60a7ea2e..00cb203c 100644 --- a/spec/classes/puppet_agent_service_systemd_spec.rb +++ b/spec/classes/puppet_agent_service_systemd_spec.rb @@ -1,18 +1,8 @@ require 'spec_helper' describe 'puppet::agent::service::systemd' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) + on_os_under_test.each do |os, facts| context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :clientcert => 'puppetmaster.example.com', - :concat_basedir => '/nonexistant', - :fqdn => 'puppetmaster.example.com', - :puppetversion => Puppet.version, - }) end - if Puppet.version < '4.0' confdir = '/etc/puppet' additional_facts = {} @@ -21,16 +11,14 @@ additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} end - if os_facts[:osfamily] == 'FreeBSD' + if facts[:osfamily] == 'FreeBSD' confdir = '/usr/local/etc/puppet' - end - - if os_facts[:osfamily] == 'Archlinux' + elsif facts[:osfamily] == 'Archlinux' confdir = '/etc/puppetlabs/puppet' end let :facts do - default_facts.merge(additional_facts) + facts.merge(additional_facts) end describe 'when runmode is not systemd' do @@ -77,9 +65,9 @@ if Puppet.version < '4.0' bindir = '/usr/bin' - elsif os_facts[:osfamily] == 'FreeBSD' + elsif facts[:osfamily] == 'FreeBSD' bindir = '/usr/local/bin' - elsif os_facts[:osfamily] == 'Archlinux' + elsif facts[:osfamily] == 'Archlinux' bindir = '/usr/bin' else bindir = '/opt/puppetlabs/bin' @@ -111,7 +99,7 @@ }) end else - it { should raise_error(Puppet::Error, /Runmode of systemd.timer not supported on #{os_facts[:kernel]} operating systems!/) } + it { should raise_error(Puppet::Error, /Runmode of systemd.timer not supported on #{facts[:kernel]} operating systems!/) } end end end diff --git a/spec/classes/puppet_agent_spec.rb b/spec/classes/puppet_agent_spec.rb index 40d99efc..80b63bec 100644 --- a/spec/classes/puppet_agent_spec.rb +++ b/spec/classes/puppet_agent_spec.rb @@ -1,22 +1,12 @@ require 'spec_helper' describe 'puppet::agent' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) + on_os_under_test.each do |os, facts| context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :clientcert => 'puppetmaster.example.com', - :concat_basedir => '/nonexistant', - :fqdn => 'puppetmaster.example.com', - :puppetversion => Puppet.version, - }) end - if Puppet.version < '4.0' client_package = 'puppet' confdir = '/etc/puppet' - case os_facts[:osfamily] + case facts[:osfamily] when 'FreeBSD' client_package = 'puppet38' confdir = '/usr/local/etc/puppet' @@ -29,7 +19,7 @@ client_package = 'puppet-agent' confdir = '/etc/puppetlabs/puppet' additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} - case os_facts[:osfamily] + case facts[:osfamily] when 'FreeBSD' client_package = 'puppet4' confdir = '/usr/local/etc/puppet' @@ -42,7 +32,7 @@ end let :facts do - default_facts.merge(additional_facts) + facts.merge(additional_facts) end describe 'with no custom parameters' do @@ -62,7 +52,7 @@ end it do - should contain_puppet__config__agent('server').with({'value' => 'puppetmaster.example.com'}) + should contain_puppet__config__agent('server').with_value('foo.example.com') end it do @@ -84,7 +74,7 @@ describe 'global puppetmaster overrides fqdn' do let(:pre_condition) { "class {'puppet': agent => true}" } let :facts do - default_facts.merge({:puppetmaster => 'mymaster.example.com'}) + facts.merge({:puppetmaster => 'mymaster.example.com'}) end it do should contain_puppet__config__agent('server').with({'value' => 'mymaster.example.com'}) @@ -94,7 +84,7 @@ describe 'puppetmaster parameter overrides global puppetmaster' do let(:pre_condition) { "class {'puppet': agent => true, puppetmaster => 'mymaster.example.com'}" } let :facts do - default_facts.merge({:puppetmaster => 'global.example.com'}) + facts.merge({:puppetmaster => 'global.example.com'}) end it do should contain_puppet__config__agent('server').with({'value' => 'mymaster.example.com'}) diff --git a/spec/classes/puppet_config_spec.rb b/spec/classes/puppet_config_spec.rb index 5d882be3..a901569d 100644 --- a/spec/classes/puppet_config_spec.rb +++ b/spec/classes/puppet_config_spec.rb @@ -1,18 +1,8 @@ require 'spec_helper' describe 'puppet::config' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) + on_os_under_test.each do |os, facts| context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :concat_basedir => '/foo/bar', - :domain => 'example.org', - :fqdn => 'host.example.com', - :puppetversion => Puppet.version, - }) end - if Puppet.version < '4.0' codedir = '/etc/puppet' confdir = '/etc/puppet' @@ -33,7 +23,7 @@ additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} end - case os_facts[:osfamily] + case facts[:osfamily] when 'FreeBSD' codedir = '/usr/local/etc/puppet' confdir = '/usr/local/etc/puppet' @@ -53,7 +43,7 @@ end let :facts do - default_facts.merge(additional_facts) + facts.merge(additional_facts).merge({:domain => 'example.org'}) end describe 'with default parameters' do diff --git a/spec/classes/puppet_init_spec.rb b/spec/classes/puppet_init_spec.rb index 06381aa0..27a1081b 100644 --- a/spec/classes/puppet_init_spec.rb +++ b/spec/classes/puppet_init_spec.rb @@ -1,24 +1,14 @@ require 'spec_helper' describe 'puppet' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) + on_os_under_test.each do |os, facts| context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :clientcert => 'puppetmaster.example.com', - :concat_basedir => '/nonexistant', - :fqdn => 'puppetmaster.example.com', - :puppetversion => Puppet.version, - }) end - if Puppet.version < '4.0' puppet_concat = '/etc/puppet/puppet.conf' puppet_directory = '/etc/puppet' puppet_package = 'puppet' additional_facts = {} - case os_facts[:osfamily] + case facts[:osfamily] when 'FreeBSD' puppet_concat = '/usr/local/etc/puppet/puppet.conf' puppet_directory = '/usr/local/etc/puppet' @@ -33,7 +23,7 @@ puppet_directory = '/etc/puppetlabs/puppet' puppet_package = 'puppet-agent' additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} - case os_facts[:osfamily] + case facts[:osfamily] when 'FreeBSD' puppet_concat = '/usr/local/etc/puppet/puppet.conf' puppet_directory = '/usr/local/etc/puppet' @@ -48,11 +38,11 @@ end let :facts do - default_facts.merge(additional_facts) + facts.merge(additional_facts) end describe 'with no custom parameters' do - it { is_expected.to compile.with_all_deps unless os_facts[:osfamily] == 'windows' } + it { is_expected.to compile.with_all_deps unless facts[:osfamily] == 'windows' } it { should contain_class('puppet::agent') } it { should contain_class('puppet::config') } it { should_not contain_class('puppet::server') } @@ -67,7 +57,7 @@ end end - describe 'with server => true', :unless => (['windows', 'Archlinux'].include?(os_facts[:osfamily])) do + describe 'with server => true', :unless => (['windows', 'Archlinux'].include?(facts[:osfamily])) do let :params do { :server => true, } end diff --git a/spec/classes/puppet_server_config_spec.rb b/spec/classes/puppet_server_config_spec.rb index 5ed80295..1f7cd07f 100644 --- a/spec/classes/puppet_server_config_spec.rb +++ b/spec/classes/puppet_server_config_spec.rb @@ -1,20 +1,10 @@ require 'spec_helper' describe 'puppet::server::config' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) - next if os_facts[:osfamily] == 'windows' - next if os_facts[:osfamily] == 'Archlinux' + on_os_under_test.each do |os, facts| + next if facts[:osfamily] == 'windows' + next if facts[:osfamily] == 'Archlinux' context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :clientcert => 'puppetmaster.example.com', - :concat_basedir => '/nonexistant', - :fqdn => 'puppetmaster.example.com', - :puppetversion => Puppet.version, - }) end - if Puppet.version < '4.0' codedir = '/etc/puppet' confdir = '/etc/puppet' @@ -45,7 +35,7 @@ additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} end - if os_facts[:osfamily] == 'FreeBSD' + if facts[:osfamily] == 'FreeBSD' codedir = '/usr/local/etc/puppet' confdir = '/usr/local/etc/puppet' conf_file = '/usr/local/etc/puppet/puppet.conf' @@ -61,7 +51,9 @@ additional_facts = {} end - let(:facts) { default_facts.merge(additional_facts) } + let(:facts) do + facts.merge({:clientcert => 'puppetmaster.example.com'}).merge(additional_facts) + end describe 'with no custom parameters' do let :pre_condition do @@ -93,13 +85,13 @@ }) end - context 'with non-AIO packages', :if => (Puppet.version < '4.0' || os_facts[:osfamily] == 'FreeBSD') do + context 'with non-AIO packages', :if => (Puppet.version < '4.0' || facts[:osfamily] == 'FreeBSD') do it 'CA cert generation should notify the Apache service' do should contain_exec('puppet_server_config-generate_ca_cert').that_notifies('Service[httpd]') end end - context 'with AIO packages', :if => (Puppet.version > '4.0' && os_facts[:osfamily] != 'FreeBSD') do + context 'with AIO packages', :if => (Puppet.version > '4.0' && facts[:osfamily] != 'FreeBSD') do it 'CA cert generation should notify the puppetserver service' do should contain_exec('puppet_server_config-generate_ca_cert').that_notifies('Service[puppetserver]') end @@ -107,7 +99,7 @@ it 'should set up the ENC' do should contain_class('foreman::puppetmaster').with({ - :foreman_url => "https://puppetmaster.example.com", + :foreman_url => "https://foo.example.com", :receive_facts => true, :puppet_home => puppetserver_vardir, :puppet_etcdir => etcdir, diff --git a/spec/classes/puppet_server_passenger_spec.rb b/spec/classes/puppet_server_passenger_spec.rb index e8550066..15b4e232 100644 --- a/spec/classes/puppet_server_passenger_spec.rb +++ b/spec/classes/puppet_server_passenger_spec.rb @@ -1,19 +1,10 @@ require 'spec_helper' describe 'puppet::server::passenger' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) - next if os_facts[:osfamily] == 'windows' - next if os_facts[:osfamily] == 'Archlinux' + on_os_under_test.each do |os, facts| + next if facts[:osfamily] == 'windows' + next if facts[:osfamily] == 'Archlinux' context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :concat_basedir => '/foo/bar', - :puppetversion => Puppet.version, - :fqdn => 'puppet.example.com', - }) end - if Puppet.version < '4.0' additional_facts = {} else @@ -21,7 +12,7 @@ end let :facts do - default_facts.merge(additional_facts) + facts.merge(additional_facts) end let(:default_params) do { @@ -106,7 +97,7 @@ it 'should include the puppet https vhost' do should contain_apache__vhost('puppet').with({ :passenger_min_instances => 10, - :passenger_pre_start => 'https://puppet.example.com:8140', + :passenger_pre_start => 'https://foo.example.com:8140', :passenger_ruby => '/opt/ruby2.0/bin/ruby', :ssl_proxyengine => false, }) @@ -115,7 +106,7 @@ it 'should include the puppet http vhost' do should contain_apache__vhost('puppet-http').with({ :passenger_min_instances => 10, - :passenger_pre_start => 'http://puppet.example.com:8139', + :passenger_pre_start => 'http://foo.example.com:8139', :passenger_ruby => '/opt/ruby2.0/bin/ruby', :ssl_proxyengine => false, }) diff --git a/spec/classes/puppet_server_puppetserver_spec.rb b/spec/classes/puppet_server_puppetserver_spec.rb index c5a8f8e2..6279c786 100644 --- a/spec/classes/puppet_server_puppetserver_spec.rb +++ b/spec/classes/puppet_server_puppetserver_spec.rb @@ -1,20 +1,11 @@ require 'spec_helper' describe 'puppet::server::puppetserver' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) - next if os_facts[:osfamily] == 'windows' - next if os_facts[:osfamily] == 'FreeBSD' - next if os_facts[:osfamily] == 'Archlinux' + on_os_under_test.each do |os, facts| + next if facts[:osfamily] == 'windows' + next if facts[:osfamily] == 'FreeBSD' + next if facts[:osfamily] == 'Archlinux' context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :puppetversion => Puppet.version, - :ipaddress => '192.0.2.10', - :processorcount => 1, - }) end - let :pre_condition do "class {'puppet': server_implementation => 'puppetserver'}" end @@ -25,7 +16,9 @@ additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} end - let(:facts) { default_facts.merge(additional_facts) } + let(:facts) do + facts.merge(additional_facts) + end let(:default_params) do { :java_bin => '/usr/bin/java', diff --git a/spec/classes/puppet_server_rack_spec.rb b/spec/classes/puppet_server_rack_spec.rb index d08ab291..6d20a963 100644 --- a/spec/classes/puppet_server_rack_spec.rb +++ b/spec/classes/puppet_server_rack_spec.rb @@ -1,23 +1,18 @@ require 'spec_helper' describe 'puppet::server::rack' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) - next if os_facts[:osfamily] == 'windows' + on_os_under_test.each do |os, facts| + next if facts[:osfamily] == 'windows' context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :puppetversion => Puppet.version, - }) end - if Puppet.version < '4.0' additional_facts = {} else additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} end - let(:facts) { default_facts.merge(additional_facts) } + let(:facts) do + facts.merge(additional_facts) + end let(:default_params) do { :app_root => '/etc/puppet/rack', diff --git a/spec/classes/puppet_server_service_spec.rb b/spec/classes/puppet_server_service_spec.rb index 2ec40800..fb138448 100644 --- a/spec/classes/puppet_server_service_spec.rb +++ b/spec/classes/puppet_server_service_spec.rb @@ -1,30 +1,21 @@ require 'spec_helper' describe 'puppet::server::service' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) - next if os_facts[:osfamily] == 'windows' + on_os_under_test.each do |os, facts| + next if facts[:osfamily] == 'windows' context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :clientcert => 'puppetmaster.example.com', - :concat_basedir => '/nonexistant', - :fqdn => 'puppetmaster.example.com', - :puppetversion => Puppet.version, - }) end - + master_service = 'puppetmaster' if Puppet.version < '4.0' additional_facts = {} else additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} + if facts[:osfamily] == 'Debian' + master_service = 'puppet-master' + end end - let(:facts) { default_facts.merge(additional_facts) } - - master_service = 'puppetmaster' - if os_facts[:osfamily] == 'Debian' && os_facts[:puppetversion].to_f > 4.0 - master_service = 'puppet-master' + let(:facts) do + facts.merge(additional_facts) end describe 'default_parameters' do diff --git a/spec/classes/puppet_server_spec.rb b/spec/classes/puppet_server_spec.rb index 1c559396..ba93bcd8 100644 --- a/spec/classes/puppet_server_spec.rb +++ b/spec/classes/puppet_server_spec.rb @@ -1,35 +1,25 @@ require 'spec_helper' describe 'puppet::server' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) - next if os_facts[:osfamily] == 'windows' - next if os_facts[:osfamily] == 'Archlinux' + on_os_under_test.each do |os, facts| + next if facts[:osfamily] == 'windows' + next if facts[:osfamily] == 'Archlinux' context "on #{os}" do - let (:default_facts) do - os_facts.merge({ - :clientcert => 'puppetmaster.example.com', - :concat_basedir => '/nonexistant', - :fqdn => 'puppetmaster.example.com', - :puppetversion => Puppet.version, - }) end - - if os_facts[:osfamily] == 'FreeBSD' + if facts[:osfamily] == 'FreeBSD' ssldir = '/var/puppet/ssl' else ssldir = '/var/lib/puppet/ssl' end server_package = 'puppet-server' - if os_facts[:osfamily] == 'Debian' + if facts[:osfamily] == 'Debian' server_package = 'puppetmaster' - if os_facts[:puppetversion].to_f > 4.0 + if facts[:puppetversion].to_f > 4.0 server_package = 'puppet-master' end end - let(:facts) { default_facts } + let(:facts) { facts } describe 'basic case' do let :pre_condition do @@ -47,7 +37,7 @@ end it { should_not contain_notify('ip_not_supported') } # No server_package for FreeBSD - if not os_facts[:osfamily] == 'FreeBSD' + if not facts[:osfamily] == 'FreeBSD' it { should contain_package(server_package) } end end @@ -59,7 +49,7 @@ end let(:facts) do - super().merge({ + facts.merge({ :fqdn => 'PUPPETMASTER.example.com', # clientcert is always lowercase by Puppet design :clientcert => 'puppetmaster.example.com', @@ -89,7 +79,7 @@ end end - unless os_facts[:osfamily] == 'FreeBSD' + unless facts[:osfamily] == 'FreeBSD' describe 'with server_implementation => "puppetserver"' do let :pre_condition do "class {'puppet': server_ip => '127.0.0.1', server_implementation => 'puppetserver'}" @@ -127,7 +117,7 @@ end end - unless os_facts[:osfamily] == 'FreeBSD' + unless facts[:osfamily] == 'FreeBSD' describe 'with server_implementation => "puppetserver"' do let :pre_condition do "class {'puppet': server => true, server_implementation => 'puppetserver'}" @@ -185,12 +175,12 @@ it { should compile.with_all_deps } # Puppetmaster is not a separate package on FreeBSD - unless os_facts[:osfamily] == 'FreeBSD' + unless facts[:osfamily] == 'FreeBSD' it { should contain_package(server_package) } end end - unless os_facts[:osfamily] == 'FreeBSD' + unless facts[:osfamily] == 'FreeBSD' describe 'when an invalid jvm size value is given' do context "when server_jvm_min_heap_size => 'x4m'" do let :pre_condition do diff --git a/spec/defines/puppet_config_entry_spec.rb b/spec/defines/puppet_config_entry_spec.rb index 87603897..80412d94 100644 --- a/spec/defines/puppet_config_entry_spec.rb +++ b/spec/defines/puppet_config_entry_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' describe 'puppet::config::entry' do - on_supported_os.each do |os, os_facts| + on_supported_os.each do |os, facts| next if only_test_os() and not only_test_os.include?(os) next if exclude_test_os() and exclude_test_os.include?(os) context "on #{os}" do let(:default_facts) do - os_facts.merge({ + facts.merge({ :clientcert => 'puppetmaster.example.com', :concat_basedir => '/nonexistant', :fqdn => 'puppetmaster.example.com', @@ -35,7 +35,7 @@ additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} end - if os_facts[:osfamily] == 'FreeBSD' + if facts[:osfamily] == 'FreeBSD' codedir = '/usr/local/etc/puppet' confdir = '/usr/local/etc/puppet' logdir = '/var/log/puppet' diff --git a/spec/defines/puppet_server_env_spec.rb b/spec/defines/puppet_server_env_spec.rb index 5738b9c2..9a49c4d6 100644 --- a/spec/defines/puppet_server_env_spec.rb +++ b/spec/defines/puppet_server_env_spec.rb @@ -1,22 +1,10 @@ require 'spec_helper' describe 'puppet::server::env' do - on_supported_os.each do |os, os_facts| - next if only_test_os() and not only_test_os.include?(os) - next if exclude_test_os() and exclude_test_os.include?(os) - next if os_facts[:osfamily] == 'windows' - next if os_facts[:osfamily] == 'Archlinux' + on_os_under_test.each do |os, facts| + next if facts[:osfamily] == 'windows' + next if facts[:osfamily] == 'Archlinux' context "on #{os}" do - let(:default_facts) do - os_facts.merge({ - :clientcert => 'puppetmaster.example.com', - :concat_basedir => '/nonexistant', - :fqdn => 'puppetmaster.example.com', - :rubyversion => '1.9.3', - :puppetversion => Puppet.version, - }) - end - if Puppet.version < '4.0' codedir = '/etc/puppet' confdir = '/etc/puppet' @@ -37,7 +25,7 @@ additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} end - if os_facts[:osfamily] == 'FreeBSD' + if facts[:osfamily] == 'FreeBSD' codedir = '/usr/local/etc/puppet' confdir = '/usr/local/etc/puppet' logdir = '/var/log/puppet' @@ -48,7 +36,7 @@ additional_facts = {} end - let(:facts) { default_facts.merge(additional_facts) } + let(:facts) { facts.merge(additional_facts) } let(:title) { 'foo' }