From 4c5f1e3b2a803e847d09aa8bffbcf2aeafe5c7f0 Mon Sep 17 00:00:00 2001 From: James Fryman Date: Sat, 20 Sep 2014 18:25:24 -0500 Subject: [PATCH] pass one of spec cleanup --- manifests/resource/geo.pp | 3 +- manifests/resource/location.pp | 3 +- manifests/resource/mailhost.pp | 3 +- manifests/resource/map.pp | 3 +- spec/classes/config_spec.rb | 54 +++++++++++++------------- spec/classes/package_spec.rb | 2 +- spec/classes/params_spec.rb | 15 ------- spec/classes/service_spec.rb | 4 +- spec/defines/resource_geo_spec.rb | 1 - spec/defines/resource_location_spec.rb | 4 +- spec/defines/resource_mailhost_spec.rb | 4 +- spec/defines/resource_upstream_spec.rb | 3 -- spec/defines/resource_vhost_spec.rb | 2 - spec/spec_helper.rb | 3 ++ 14 files changed, 39 insertions(+), 65 deletions(-) delete mode 100644 spec/classes/params_spec.rb diff --git a/manifests/resource/geo.pp b/manifests/resource/geo.pp index 859b0b2..5db1dd8 100644 --- a/manifests/resource/geo.pp +++ b/manifests/resource/geo.pp @@ -73,8 +73,7 @@ define nginx::resource::geo ( if ($proxies != undef) { validate_array($proxies) } if ($proxy_recursive != undef) { validate_bool($proxy_recursive) } - include nginx::params - $root_group = $nginx::params::root_group + $root_group = $nginx::config::root_group $ensure_real = $ensure ? { 'absent' => 'absent', diff --git a/manifests/resource/location.pp b/manifests/resource/location.pp index 1f44fba..3884cb2 100644 --- a/manifests/resource/location.pp +++ b/manifests/resource/location.pp @@ -172,8 +172,7 @@ define nginx::resource::location ( $flv = false, ) { - include nginx::params - $root_group = $nginx::params::root_group + $root_group = $nginx::config::root_group File { owner => 'root', diff --git a/manifests/resource/mailhost.pp b/manifests/resource/mailhost.pp index 37b48bf..f812d6a 100644 --- a/manifests/resource/mailhost.pp +++ b/manifests/resource/mailhost.pp @@ -61,8 +61,7 @@ define nginx::resource::mailhost ( $server_name = [$name] ) { - include nginx::params - $root_group = $nginx::params::root_group + $root_group = $nginx::config::root_group File { owner => 'root', diff --git a/manifests/resource/map.pp b/manifests/resource/map.pp index 1c7aa32..1217df3 100644 --- a/manifests/resource/map.pp +++ b/manifests/resource/map.pp @@ -57,8 +57,7 @@ define nginx::resource::map ( "Invalid ensure value '${ensure}'. Expected 'present' or 'absent'") if ($default != undef) { validate_string($default) } - include nginx::params - $root_group = $nginx::params::root_group + $root_group = $nginx::config::root_group $ensure_real = $ensure ? { 'absent' => absent, diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index 34ba4a6..7222a25 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -3,18 +3,18 @@ describe 'nginx::config' do describe 'with defaults' do [ - { :osfamily => 'debian', :operatingsystem => 'debian', }, - { :osfamily => 'debian', :operatingsystem => 'ubuntu', }, - { :osfamily => 'redhat', :operatingsystem => 'fedora', }, - { :osfamily => 'redhat', :operatingsystem => 'rhel', }, - { :osfamily => 'redhat', :operatingsystem => 'redhat', }, - { :osfamily => 'redhat', :operatingsystem => 'centos', }, - { :osfamily => 'redhat', :operatingsystem => 'scientific', }, - { :osfamily => 'redhat', :operatingsystem => 'amazon', }, - { :osfamily => 'suse', :operatingsystem => 'suse', }, - { :osfamily => 'suse', :operatingsystem => 'opensuse', }, - { :osfamily => 'gentoo', :operatingsystem => 'gentoo', }, - { :osfamily => 'linux', :operatingsystem => 'gentoo', }, + { :osfamily => 'Debian', :operatingsystem => 'Debian', }, + { :osfamily => 'Debian', :operatingsystem => 'Ubuntu', }, + { :osfamily => 'Redhat', :operatingsystem => 'Fedora', }, + { :osfamily => 'Redhat', :operatingsystem => 'RedHat', }, + { :osfamily => 'Redhat', :operatingsystem => 'OracleLinux', }, + { :osfamily => 'Redhat', :operatingsystem => 'CentOS', }, + { :osfamily => 'Redhat', :operatingsystem => 'Scientific', }, + { :osfamily => 'Redhat', :operatingsystem => 'Amazon', }, + { :osfamily => 'SuSE', :operatingsystem => 'SuSE', }, + { :osfamily => 'SuSE', :operatingsystem => 'OpenSuSE', }, + { :osfamily => 'Gentoo', :operatingsystem => 'Gentoo', }, + { :osfamily => 'Linux', :operatingsystem => 'Gentoo', }, ].each do |facts| context "when osfamily/operatingsystem is #{facts[:osfamily]}/#{facts[:operatingsystem]}" do @@ -26,8 +26,6 @@ describe 'nginx::config' do } end - it { is_expected.to contain_class("nginx::params") } - it { is_expected.to contain_file("/etc/nginx").only_with( :path => "/etc/nginx", :ensure => 'directory', @@ -96,8 +94,8 @@ describe 'nginx::config' do describe 'with defaults' do [ - { :osfamily => 'debian', :operatingsystem => 'debian', }, - { :osfamily => 'debian', :operatingsystem => 'ubuntu', }, + { :osfamily => 'Debian', :operatingsystem => 'Debian', }, + { :osfamily => 'Debian', :operatingsystem => 'Ubuntu', }, ].each do |facts| context "when osfamily/operatingsystem is #{facts[:osfamily]}/#{facts[:operatingsystem]}" do @@ -117,16 +115,16 @@ describe 'nginx::config' do describe 'with defaults' do [ - { :osfamily => 'redhat', :operatingsystem => 'fedora', }, - { :osfamily => 'redhat', :operatingsystem => 'rhel', }, - { :osfamily => 'redhat', :operatingsystem => 'redhat', }, - { :osfamily => 'redhat', :operatingsystem => 'centos', }, - { :osfamily => 'redhat', :operatingsystem => 'scientific', }, - { :osfamily => 'redhat', :operatingsystem => 'amazon', }, - { :osfamily => 'suse', :operatingsystem => 'suse', }, - { :osfamily => 'suse', :operatingsystem => 'opensuse', }, - { :osfamily => 'gentoo', :operatingsystem => 'gentoo', }, - { :osfamily => 'linux', :operatingsystem => 'gentoo', }, + { :osfamily => 'RedHat', :operatingsystem => 'Fedora', }, + { :osfamily => 'RedHat', :operatingsystem => 'RedHat', }, + { :osfamily => 'RedHat', :operatingsystem => 'OracleLinux', }, + { :osfamily => 'RedHat', :operatingsystem => 'CentOS', }, + { :osfamily => 'RedHat', :operatingsystem => 'Scientific', }, + { :osfamily => 'RedHat', :operatingsystem => 'Amazon', }, + { :osfamily => 'SuSE', :operatingsystem => 'SuSE', }, + { :osfamily => 'SuSE', :operatingsystem => 'openSuSE', }, + { :osfamily => 'Gentoo', :operatingsystem => 'Gentoo', }, + { :osfamily => 'Linux', :operatingsystem => 'Gentoo', }, ].each do |facts| context "when osfamily/operatingsystem is #{facts[:osfamily]}/#{facts[:operatingsystem]}" do @@ -148,8 +146,8 @@ describe 'nginx::config' do let :facts do { - :osfamily => 'debian', - :operatingsystem => 'debian', + :osfamily => 'Debian', + :operatingsystem => 'Debian', } end diff --git a/spec/classes/package_spec.rb b/spec/classes/package_spec.rb index c44ba30..808820c 100644 --- a/spec/classes/package_spec.rb +++ b/spec/classes/package_spec.rb @@ -4,7 +4,7 @@ describe 'nginx::package' do shared_examples 'redhat' do |operatingsystem| let(:facts) {{ :operatingsystem => operatingsystem, :osfamily => 'RedHat' }} - +spec/classes/package_spec.rb context "using defaults" do it { is_expected.to contain_package('nginx') } it { is_expected.to contain_yumrepo('nginx-release').with( diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb deleted file mode 100644 index 175f8e9..0000000 --- a/spec/classes/params_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe 'nginx::params' do - context "On a Debian OS" do - let :facts do { - :osfamily => 'debian', - :operatingsystem => 'debian', - } end - - it { is_expected.to contain_nginx__params } - it { is_expected.to have_class_count(1) } #only nginx::params itself - it { is_expected.to have_resource_count(0) } #params class should never declare resources - - end -end diff --git a/spec/classes/service_spec.rb b/spec/classes/service_spec.rb index f717991..d6005d5 100644 --- a/spec/classes/service_spec.rb +++ b/spec/classes/service_spec.rb @@ -3,14 +3,14 @@ describe 'nginx::service' do let :facts do { :osfamily => 'Debian', - :operatingsystem => 'debian', + :operatingsystem => 'Debian', } end let :params do { :configtest_enable => false, :service_restart => '/etc/init.d/nginx configtest && /etc/init.d/nginx restart', :service_ensure => 'running', - } end + } end context "using default parameters" do diff --git a/spec/defines/resource_geo_spec.rb b/spec/defines/resource_geo_spec.rb index cceff06..94958f6 100644 --- a/spec/defines/resource_geo_spec.rb +++ b/spec/defines/resource_geo_spec.rb @@ -26,7 +26,6 @@ describe 'nginx::resource::geo' do let :pre_condition do [ - 'include ::nginx::params', 'include ::nginx::config', ] end diff --git a/spec/defines/resource_location_spec.rb b/spec/defines/resource_location_spec.rb index 9fc3989..a81d9b5 100644 --- a/spec/defines/resource_location_spec.rb +++ b/spec/defines/resource_location_spec.rb @@ -8,12 +8,11 @@ describe 'nginx::resource::location' do let :facts do { :osfamily => 'Debian', - :operatingsystem => 'debian', + :operatingsystem => 'Debian', } end let :pre_condition do [ - 'include ::nginx::params', 'include ::nginx::config', ] end @@ -26,7 +25,6 @@ describe 'nginx::resource::location' do :vhost => 'vhost1', } end - it { is_expected.to contain_class("nginx::params") } it { is_expected.to contain_class("nginx::config") } it { is_expected.to contain_concat__fragment("f25e14942fb58942ee13b1465a4e1719").with_content(/location rspec-test/) } it { is_expected.not_to contain_file('/etc/nginx/fastcgi_params') } diff --git a/spec/defines/resource_mailhost_spec.rb b/spec/defines/resource_mailhost_spec.rb index bf808a4..36237cf 100644 --- a/spec/defines/resource_mailhost_spec.rb +++ b/spec/defines/resource_mailhost_spec.rb @@ -6,8 +6,8 @@ describe 'nginx::resource::mailhost' do end let :facts do { - :osfamily => 'debian', - :operatingsystem => 'debian', + :osfamily => 'Debian', + :operatingsystem => 'Debian', :ipaddress6 => '::', } end diff --git a/spec/defines/resource_upstream_spec.rb b/spec/defines/resource_upstream_spec.rb index d81eb9c..148d8da 100644 --- a/spec/defines/resource_upstream_spec.rb +++ b/spec/defines/resource_upstream_spec.rb @@ -13,7 +13,6 @@ describe 'nginx::resource::upstream' do let :pre_condition do [ - 'include ::nginx::params', 'include ::nginx::config', ] end @@ -28,7 +27,6 @@ describe 'nginx::resource::upstream' do let :pre_condition do [ - 'include ::nginx::params', 'include ::nginx::config', ] end @@ -39,7 +37,6 @@ describe 'nginx::resource::upstream' do describe 'basic assumptions' do let :params do default_params end - it { is_expected.to contain_class("nginx::params") } it { is_expected.to contain_class('concat::setup') } it { is_expected.to contain_file("/etc/nginx/conf.d/#{title}-upstream.conf") } it { is_expected.to contain_concat__fragment("#{title}_upstream_header").with_content(/upstream #{title}/) } diff --git a/spec/defines/resource_vhost_spec.rb b/spec/defines/resource_vhost_spec.rb index 9408b08..08a0b01 100644 --- a/spec/defines/resource_vhost_spec.rb +++ b/spec/defines/resource_vhost_spec.rb @@ -19,7 +19,6 @@ describe 'nginx::resource::vhost' do end let :pre_condition do [ - 'include ::nginx::params', 'include ::nginx::config', ] end @@ -28,7 +27,6 @@ describe 'nginx::resource::vhost' do describe 'basic assumptions' do let :params do default_params end - it { is_expected.to contain_class("nginx::params") } it { is_expected.to contain_class("nginx::config") } it { is_expected.to contain_concat("/etc/nginx/sites-available/#{title}.conf").with({ 'owner' => 'root', diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a987b6e..730b53d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,9 @@ require 'puppetlabs_spec_helper/module_spec_helper' +require 'fixtures/modules/module_data/lib/hiera/backend/module_data_backend.rb' RSpec.configure do |c| + c.hiera_config = File.join('spec', 'fixtures', 'hiera', 'hiera.yaml') + c.default_facts = { :kernel => 'Linux', :concat_basedir => '/var/lib/puppet/concat',