forked from jhoblitt/puppet-selenium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joshua Hoblitt
committed
Oct 2, 2013
1 parent
df6cc77
commit a4d77e7
Showing
3 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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': } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |