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) }
8 describe 'check for deprecation warning' do
10 ENV.delete('STDLIB_LOG_DEPRECATIONS')
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')
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') }
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}) }