Improved rspec tests for server class - with defaults
diff --git a/spec/classes/backuppc_server_spec.rb b/spec/classes/backuppc_server_spec.rb index afea41a..01bb2c3 100644 --- a/spec/classes/backuppc_server_spec.rb +++ b/spec/classes/backuppc_server_spec.rb
@@ -13,9 +13,31 @@ let(:params) { { 'backuppc_password' => 'test_password' } } options = os_specific_options(facts) - it { is_expected.to contain_class('backuppc::params') } - it { is_expected.to contain_package(options[:package]) } - it { is_expected.to compile.with_all_deps } + context 'with defaults' do + it { is_expected.to contain_class('backuppc::server') } + it { is_expected.to contain_class('backuppc::params') } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_package('backuppc') } + it do + is_expected.to contain_file('config_directory').with( + ensure: 'directory', + group: options[:group_apache], + ) + end + it do + is_expected.to contain_file('config.pl').with( + ensure: 'present', + group: options[:group_apache], + mode: '0640', + ) + end + it { is_expected.to contain_file('pc_directory_symlink').with_ensure('link') } + it { is_expected.to contain_service('backuppc').with_ensure(true) } + it { is_expected.to contain_file('topdir').with_ensure('directory') } + it { is_expected.to contain_file('topdir_ssh').with_ensure('directory') } + it { is_expected.to contain_file('apache_config').with_ensure('present') } + it { is_expected.to contain_backuppc__server__user('backuppc').with_password('test_password') } + end end end end
diff --git a/spec/spec_helper_methods.rb b/spec/spec_helper_methods.rb index 2061c34..36167ca 100644 --- a/spec/spec_helper_methods.rb +++ b/spec/spec_helper_methods.rb
@@ -1,8 +1,8 @@ def os_specific_options(facts) case facts[:os]['family'] when 'RedHat' - { package: 'BackupPC', service: 'backuppc', topdir: '/var/lib/BackupPC' } + { group_apache: 'apache', topdir: '/var/lib/BackupPC' } when 'Debian' - { package: 'backuppc', service: 'backuppc', topdir: '/var/lib/backuppc' } + { group_apache: 'www-data', topdir: '/var/lib/backuppc' } end end