Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / validate_hash_spec.rb
1 require 'spec_helper'
2
3 describe 'validate_hash' do
4   describe 'signature validation' do
5     it { is_expected.not_to eq(nil) }
6     it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
7
8     describe 'check for deprecation warning' do
9       after(:each) do
10         ENV.delete('STDLIB_LOG_DEPRECATIONS')
11       end
12       # Checking for deprecation warning
13       it 'displays a single deprecation' do
14         ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
15         expect(scope).to receive(:warning).with(include('This method is deprecated'))
16         is_expected.to run.with_params('key' => 'value')
17       end
18     end
19
20     describe 'valid inputs' do
21       it { is_expected.to run.with_params({}) }
22       it { is_expected.to run.with_params('key' => 'value') }
23       it { is_expected.to run.with_params({}, 'key' => 'value') }
24       it { is_expected.to run.with_params({ 'key1' => 'value1' }, 'key2' => 'value2') }
25     end
26
27     describe 'invalid inputs' do
28       it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
29       it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
30       it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
31       it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
32       it { is_expected.to run.with_params({}, []).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
33       it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
34       it { is_expected.to run.with_params({}, true).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
35       it { is_expected.to run.with_params({}, 'one').and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
36       it { is_expected.to run.with_params("{ 'number' => 'one' }").and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
37     end
38   end
39 end