Skip to content

Commit

Permalink
tie selenium::{install,config,service} together in selenium::server
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed Oct 1, 2013
1 parent e0bc408 commit 45c06af
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 10 deletions.
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Joshua Hoblitt <[email protected]>
#
#
class selenium::config inherits selenium::server {
class selenium::config {

file { '/etc/init.d/selenium':
ensure => 'file',
Expand Down
2 changes: 1 addition & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class selenium::install(
$version = '2.35.0',
$url = undef,
) inherits selenium::server {
) {
validate_string($version)
validate_string($url)

Expand Down
8 changes: 7 additions & 1 deletion manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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' ]

}
2 changes: 1 addition & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Joshua Hoblitt <[email protected]>
#
#
class selenium::service inherits selenium::server {
class selenium::service {

service { 'selenium':
ensure => running,
Expand Down
77 changes: 71 additions & 6 deletions spec/classes/selenium_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 45c06af

Please sign in to comment.