From 0b21f0e75155da2cf7762c75a74b95436e2c9e3a Mon Sep 17 00:00:00 2001 From: Norbert Varzariu Date: Mon, 18 Jan 2016 19:54:53 +0100 Subject: [PATCH] remove class inheritance in install.pp --- Gemfile | 37 ++++++------------------------------- manifests/config.pp | 6 +++--- manifests/init.pp | 2 +- manifests/install.pp | 2 +- spec/classes/init_spec.rb | 38 ++++---------------------------------- 5 files changed, 15 insertions(+), 70 deletions(-) diff --git a/Gemfile b/Gemfile index 9016155..5ce94b0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,32 +1,7 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' +source 'https://rubygems.org' -group :development, :unit_tests do - gem 'rspec-core', '~> 3.1.7', :require => false - gem 'rspec-puppet', '~> 2.1', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'simplecov', :require => false - gem 'puppet_facts', :require => false - gem 'json', :require => false - gem 'metadata-json-lint', :require => false - gem 'puppet-lint', '< 1.1.0', :require => false -end - -group :system_tests do - gem 'beaker-rspec', :require => false - gem 'serverspec', :require => false - gem 'beaker-puppet_install_helper', :require => false -end - -if facterversion = ENV['FACTER_GEM_VERSION'] - gem 'facter', facterversion, :require => false -else - gem 'facter', :require => false -end - -if puppetversion = ENV['PUPPET_GEM_VERSION'] - gem 'puppet', puppetversion, :require => false -else - gem 'puppet', :require => false -end - -# vim:ft=ruby +puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['>= 4.0'] +gem 'puppet', puppetversion +gem 'puppetlabs_spec_helper', '>= 0.8.2' +gem 'puppet-lint', '>= 1.0.0' +gem 'facter', '>= 1.7.0' diff --git a/manifests/config.pp b/manifests/config.pp index 6223b20..4854a42 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -7,9 +7,9 @@ class rsnapshot::config ( ) { # these are global settings, no point in setting them per host $config_version = $rsnapshot::params::config_version - $lockpath = pick($rsnapshot::lockpath, $rsnapshot::params::config_lockpath) - $conf_d = pick($rsnapshot::conf_d, $rsnapshot::params::conf_d) - $snapshot_root = pick($hosts['snapshot_root'], $rsnapshot::params::config_snapshot_root) + $lockpath = pick($rsnapshot::lockpath, $rsnapshot::params::config_lockpath, '/var/run/rsnapshot') + $conf_d = pick($rsnapshot::conf_d, $rsnapshot::params::conf_d, '/etc/rsnapshot') + $snapshot_root = pick($hosts['snapshot_root'], $rsnapshot::params::config_snapshot_root, '/backup') $default_cron = assert_empty_hash($::rsnapshot::cron) # make sure lock path and conf path exist file { $conf_d: diff --git a/manifests/init.pp b/manifests/init.pp index c883966..d798bc3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -14,7 +14,7 @@ class rsnapshot ( $package_ensure = $rsnapshot::params::package_ensure, $cron = $rsnapshot::params::cron, ) inherits rsnapshot::params { - if $::puppetversion =~ /^(1|2|3)/ { + if $puppetversion =~ /^(1|2|3)/ { fail('This module requires Puppet 4') } if $hosts { diff --git a/manifests/install.pp b/manifests/install.pp index 0758784..c291606 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,7 +1,7 @@ # == Class: rsnapshot::install # # Installs the rsnapshot package. -class rsnapshot::install inherits rsnapshot { +class rsnapshot::install { case $::operatingsystem { /^CentOS$/: { include epel } default: {} diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index d4615d2..9707e8c 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,37 +1,7 @@ require 'spec_helper' describe 'rsnapshot' do - - {'Ubuntu' => 'Debian', 'Debian' => 'Debian'}.each do |system, family| - context "when on system #{system} no lvm" do - let :facts do - { - :osfamily => family, - :operatingsystem => system, - } - end - - it { should contain_class('rsnapshot') } - it { should contain_class('rsnapshot::install') } - it { should contain_class('rsnapshot::config') } - end - - context "when on system #{system} with lvm" do - let :facts do - { - :osfamily => family, - :operatingsystem => system, - } - end - - let(:params) { {:use_lvm => true} } - - it { should contain_class('rsnapshot') } - it { should contain_class('rsnapshot::install') } - it { should contain_class('rsnapshot::config') } - - it { - should contain_file('/etc/rsnapshot.conf').with_content(/^linux_lvm_((\w|_)+)\t(.*)$/) - } - end - end + it { should contain_class('rsnapshot::params') } + it { is_expected.to compile } + it { is_expected.to contain_class('rsnapshot::config') } + it { is_expected.to contain_class('rsnapshot::install') } end