diff --git a/manifests/config.pp b/manifests/config.pp index 0f8d8d3..eb99d17 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -18,7 +18,7 @@ # Joshua Hoblitt # # -class selenium::config inherits selenium::server { +class selenium::config { file { '/etc/init.d/selenium': ensure => 'file', diff --git a/manifests/install.pp b/manifests/install.pp index d5ea47a..15af89c 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -23,7 +23,7 @@ class selenium::install( $version = '2.35.0', $url = undef, -) inherits selenium::server { +) { validate_string($version) validate_string($url) diff --git a/manifests/server.pp b/manifests/server.pp index af14e50..ed9e1b3 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -11,12 +11,18 @@ $group = $selenium::params::group, $install_path = $selenium::params::install_path, ) inherits selenium::params { - validate_string($user) + validate_string($user) validate_string($group) + validate_string($install_path) user { $user: gid => [$group], } group { $group: } + class { 'selenium::install': } -> + class { 'selenium::config': } -> + class { 'selenium::service': } -> + Class[ 'selenium::server' ] + } diff --git a/manifests/service.pp b/manifests/service.pp index 372cc84..7a286f5 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -18,7 +18,7 @@ # Joshua Hoblitt # # -class selenium::service inherits selenium::server { +class selenium::service { service { 'selenium': ensure => running, diff --git a/spec/classes/selenium_server_spec.rb b/spec/classes/selenium_server_spec.rb index 026a5dd..99c16f9 100644 --- a/spec/classes/selenium_server_spec.rb +++ b/spec/classes/selenium_server_spec.rb @@ -2,14 +2,79 @@ describe 'selenium::server', :type => :class do - describe 'for osfamily RedHat' do - let :facts do - { - :osfamily => 'RedHat', - } + shared_examples 'server' do |user, group| + it do + should contain_class('selenium::server') + should contain_class('selenium::install') + should contain_class('selenium::config') + should contain_class('selenium::service') + should contain_user(user).with_gid(group) + should contain_group(group) end + end + + context 'for osfamily RedHat' do + let(:facts) {{ :osfamily => 'RedHat' }} + + context 'no params' do + it_behaves_like 'server', 'selenium', 'selenium' + end + + context 'user => foo' do + let(:params) {{ :user => 'foo' }} + + it_behaves_like 'server', 'foo', 'selenium' + end + + context 'user => []' do + let(:params) {{ :user => [] }} + + it 'should fail' do + expect { + should contain_class('selenium::server') + }.to raise_error + end + end + + context 'group => foo' do + let(:params) {{ :group => 'foo' }} - it { should contain_class('selenium::server') } + it_behaves_like 'server', 'selenium', 'foo' + end + + context 'group => []' do + let(:params) {{ :group => [] }} + + it 'should fail' do + expect { + should contain_class('selenium::server') + }.to raise_error + end + end + + context 'install_path => /foo/selenium' do + let(:params) {{ :install_path => '/foo/selenium' }} + + it_behaves_like 'server', 'selenium', 'selenium' + + it do + should contain_file('/foo/selenium').with({ + 'ensure' => 'directory', + 'owner' => 'selenium', + 'group' => 'selenium', + }) + end + end + + context 'install_path => []' do + let(:params) {{ :install_path => [] }} + + it 'should fail' do + expect { + should contain_class('selenium::server') + }.to raise_error + end + end end end