Skip to content

Commit

Permalink
add class selenium::node
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed Oct 2, 2013
1 parent df6cc77 commit a4d77e7
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 0 deletions.
40 changes: 40 additions & 0 deletions manifests/node.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# == Class: selenium::node
#
# simple template
#
#
# === Examples
#
# include selenium::node
#
#
# === Authors
#
# Joshua Hoblitt <jhoblitt@cpan.org>
#
#
class selenium::node(
$display = $selenium::params::display,
$options = $selenium::params::node_options,
$hub = $selenium::params::default_hub,
) inherits selenium::params {
validate_string($display)
validate_string($options)
validate_string($hub)

include selenium

$safe_options = "${options} -hub ${hub}"

anchor { 'selenium::node::begin': }
Class[ 'selenium' ] ->
selenium::config{ 'node':
display => $display,
user => $selenium::user,
group => $selenium::group,
install_root => $selenium::install_root,
options => $safe_options,
java => $selenium::java,
} ->
anchor { 'selenium::node::end': }
}
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
$install_root = '/opt/selenium'
$server_options = '-Dwebdriver.enable.native.events=1'
$hub_options = '-role hub'
$node_options = '-role node'
$java = 'java'
$version = '2.35.0'
$default_hub = 'http://localhost:4444/grid/register'

case $::osfamily {
'redhat': {}
Expand Down
82 changes: 82 additions & 0 deletions spec/classes/selenium_node_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
require 'spec_helper'

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

shared_examples 'node' do |params|
p = {
:display => ':0',
:options => '-role node',
:hub => 'http://localhost:4444/grid/register',
}

p.merge!(params) if params

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

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

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

context 'display => :42' do
p = { :display => ':42' }
let(:params) { p }

it_behaves_like 'node', p
end

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

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

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

it_behaves_like 'node', p
end

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

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

context 'hub => http://foo' do
p = { :hub => 'http://foo' }
let(:params) { p }

it_behaves_like 'node', p
end

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

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

end

0 comments on commit a4d77e7

Please sign in to comment.