Skip to content

Commit

Permalink
Add spec tests for hiera_merge
Browse files Browse the repository at this point in the history
Test for hiera_merge set to an invalid type that is not checked in the
code's case statement. Also test for error message returned from
validate_re().
  • Loading branch information
ghoneycutt committed Jan 20, 2014
1 parent 8a8ffbe commit 0f4b832
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,8 @@
end

describe 'with hiera_merge parameter specified' do
context 'as a non-boolean' do
let(:params) { { :hiera_merge => 'not_a_boolean' } }
context 'as a non-boolean or non-string' do
let(:params) { { :hiera_merge => ['not_a_boolean','or_a_string'] } }
let(:facts) do
{ :osfamily => 'RedHat',
:lsbmajdistrelease => '6',
Expand All @@ -855,6 +855,19 @@
end
end

context 'as an invalid string' do
let(:params) { { :hiera_merge => 'invalid_string' } }
let(:facts) do
{ :osfamily => 'RedHat',
:lsbmajdistrelease => '6',
}
end

it 'should fail' do
expect { should raise_error(Puppet::Error,/^ssh::hiera_merge may be either 'true' or 'false' and is set to <invalid_string>./) }
end
end

['true',true].each do |value|
context "as #{value}" do
let(:params) { { :hiera_merge => value } }
Expand Down

0 comments on commit 0f4b832

Please sign in to comment.