From 8ac1df022cdd59ba9dfeae80b4a09cbaf879b30d Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Thu, 16 Jan 2014 14:20:59 -0700 Subject: [PATCH] add validation + rspec of selenium class download_timeout param --- manifests/init.pp | 1 + spec/classes/selenium_spec.rb | 33 ++++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 5adfb5a..6f33ca8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -88,6 +88,7 @@ validate_string($java) validate_string($version) validate_string($url) + validate_string($download_timeout) include wget diff --git a/spec/classes/selenium_spec.rb b/spec/classes/selenium_spec.rb index 7d939f4..2ef4fb3 100644 --- a/spec/classes/selenium_spec.rb +++ b/spec/classes/selenium_spec.rb @@ -5,12 +5,13 @@ shared_examples 'selenium' do |params| # XXX need to test $url p = { - :user => 'selenium', - :group => 'selenium', - :install_root => '/opt/selenium', - :java => 'java', - :version => '2.39.0', - :url => '', + :user => 'selenium', + :group => 'selenium', + :install_root => '/opt/selenium', + :java => 'java', + :version => '2.39.0', + :url => '', + :download_timeout => '90', } if params @@ -46,7 +47,7 @@ should contain_wget__fetch('selenium-server-standalone').with({ 'source' => "https://selenium.googlecode.com/files/selenium-server-standalone-#{p[:version]}.jar", 'destination' => "#{p[:install_root]}/jars/selenium-server-standalone-#{p[:version]}.jar", - 'timeout' => '90', + 'timeout' => p[:download_timeout], 'execuser' => p[:user], }) should contain_logrotate__rule('selenium').with({ @@ -140,6 +141,24 @@ }.to raise_error end end + + context 'download_timeout => 42' do + p = { :download_timeout => '42' } + let(:params) { p } + + it_behaves_like 'selenium', p + end + + context 'download_timeout => []' do + p = { :download_timeout => [] } + let(:params) { p } + + it 'should fail' do + expect { + should contain_class('selenium') + }.to raise_error + end + end end end