From c5b1dd212e3b0fe3d42deb24e82be8b2532b542c Mon Sep 17 00:00:00 2001 From: zivan Date: Fri, 30 Jan 2015 07:38:44 +0600 Subject: [PATCH] add unit test for the param nocheckcertificate --- spec/unit/classes/selenium_spec.rb | 42 ++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/spec/unit/classes/selenium_spec.rb b/spec/unit/classes/selenium_spec.rb index 311d3e9..b27b182 100644 --- a/spec/unit/classes/selenium_spec.rb +++ b/spec/unit/classes/selenium_spec.rb @@ -5,13 +5,14 @@ shared_examples 'selenium' do |params| # XXX need to test $url p = { - :user => 'selenium', - :group => 'selenium', - :install_root => '/opt/selenium', - :java => 'java', - :version => DEFAULT_VERSION, - :url => '', - :download_timeout => '90', + :user => 'selenium', + :group => 'selenium', + :install_root => '/opt/selenium', + :java => 'java', + :version => DEFAULT_VERSION, + :url => '', + :download_timeout => '90', + :nocheckcertificate => false, } if params @@ -52,10 +53,11 @@ 'target' => "#{p[:install_root]}/log", }) should contain_wget__fetch('selenium-server-standalone').with({ - 'source' => "https://selenium-release.storage.googleapis.com/#{path_version}/selenium-server-standalone-#{p[:version]}.jar", - 'destination' => "#{p[:install_root]}/jars/selenium-server-standalone-#{p[:version]}.jar", - 'timeout' => p[:download_timeout], - 'execuser' => p[:user], + 'source' => "https://selenium-release.storage.googleapis.com/#{path_version}/selenium-server-standalone-#{p[:version]}.jar", + 'destination' => "#{p[:install_root]}/jars/selenium-server-standalone-#{p[:version]}.jar", + 'timeout' => p[:download_timeout], + 'nocheckcertificate' => p[:nocheckcertificate], + 'execuser' => p[:user], }) should contain_logrotate__rule('selenium').with({ :path => "#{p[:install_root]}/log", @@ -166,6 +168,24 @@ }.to raise_error end end + + context 'nocheckcertificate => true' do + p = { :nocheckcertificate => true } + let(:params) { p } + + it_behaves_like 'selenium', p + end + + context 'nocheckcertificate => []' do + p = { :nocheckcertificate => [] } + let(:params) { p } + + it 'should fail' do + expect { + should contain_class('selenium') + }.to raise_error + end + end end end