Skip to content

Commit

Permalink
add class selenium::hub
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed Oct 2, 2013
1 parent 0904127 commit df6cc77
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 15 deletions.
33 changes: 33 additions & 0 deletions manifests/hub.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# == Class: selenium::hub
#
# simple template
#
#
# === Examples
#
# include selenium::hub
#
#
# === Authors
#
# Joshua Hoblitt <[email protected]>
#
#
class selenium::hub(
$options = $selenium::params::hub_options,
) inherits selenium::params {
validate_string($options)

include selenium

anchor { 'selenium::hub::begin': }
Class[ 'selenium' ] ->
selenium::config{ 'hub':
user => $selenium::user,
group => $selenium::group,
install_root => $selenium::install_root,
options => $options,
java => $selenium::java,
} ->
anchor { 'selenium::hub::end': }
}
46 changes: 46 additions & 0 deletions spec/classes/selenium_hub_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require 'spec_helper'

describe 'selenium::hub', :type => :class do

shared_examples 'hub' do |params|
p = {
:options => '-role hub'
}

p.merge!(params) if params

it do
should include_class('selenium')
should contain_selenium__config('hub').with({
'options' => p[:options],
})
should contain_class('selenium::hub')
end
end

context 'for osfamily RedHat' do
let(:facts) {{ :osfamily => 'RedHat' }}

context 'no params' do
it_behaves_like 'hub', {}
end

context 'options => -foo' do
p = { :options => '-foo' }
let(:params) { p }

it_behaves_like 'hub', p
end

context 'options => []' do
let(:params) {{ :options => [] }}

it 'should fail' do
expect {
should contain_class('selenium::hub')
}.to raise_error
end
end
end

end
55 changes: 40 additions & 15 deletions spec/defines/selenium_config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require 'spec_helper'

describe 'selenium::config', :type => :define do
let(:title) { 'server' }

shared_examples 'config' do |params|
let :pre_condition do
"include selenium"
Expand Down Expand Up @@ -47,23 +45,50 @@
context 'for osfamily RedHat' do
let(:facts) {{ :osfamily => 'RedHat' }}

context 'no params' do
it_behaves_like 'config', {}
context "server" do
let(:title) { 'server' }

context 'no params' do
it_behaves_like 'config', {}
end

context 'all params' do
params = {
:display => 'X:0',
:user => 'Xselenium',
:install_root => 'X/opt/selenium',
:jar_name => 'Xselenium-server-standalone-2.35.0.jar',
:options => 'X-Dwebdriver.enable.native.events=1',
:java => 'Xjava',
}

let(:params) { params }

it_behaves_like 'config', params
end
end

context 'all params' do
params = {
:display => 'X:0',
:user => 'Xselenium',
:install_root => 'X/opt/selenium',
:jar_name => 'Xselenium-server-standalone-2.35.0.jar',
:options => 'X-Dwebdriver.enable.native.events=1',
:java => 'Xjava',
}
context "hub" do
let(:title) { 'hub' }

context 'no params' do
it_behaves_like 'config', {}
end

context 'all params' do
params = {
:display => 'X:0',
:user => 'Xselenium',
:install_root => 'X/opt/selenium',
:jar_name => 'Xselenium-server-standalone-2.35.0.jar',
:options => 'X-Dwebdriver.enable.native.events=1',
:java => 'Xjava',
}

let(:params) { params }
let(:params) { params }

it_behaves_like 'config', params
it_behaves_like 'config', params
end
end
end

Expand Down

0 comments on commit df6cc77

Please sign in to comment.