3 if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
4 describe 'deprecation' do
6 # this is to reset the strict variable to default
7 Puppet.settings[:strict] = :warning
10 it { is_expected.not_to eq(nil) }
11 it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
13 it 'should display a single warning' do
14 Puppet.expects(:warning).with(includes('heelo'))
15 is_expected.to run.with_params('key', 'heelo')
18 it 'should display a single warning, despite multiple calls' do
19 Puppet.expects(:warning).with(includes('heelo')).once
20 is_expected.to run.with_params('key', 'heelo')
21 is_expected.to run.with_params('key', 'heelo')
24 it 'should fail twice with message, with multiple calls. when strict= :error' do
25 Puppet.settings[:strict] = :error
26 Puppet.expects(:warning).with(includes('heelo')).never
27 is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, /deprecation. key. heelo/)
28 is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, /deprecation. key. heelo/)
31 it 'should display nothing, despite multiple calls. strict= :off' do
32 Puppet.settings[:strict] = :off
33 Puppet.expects(:warning).with(includes('heelo')).never
34 is_expected.to run.with_params('key', 'heelo')
35 is_expected.to run.with_params('key', 'heelo')
39 # this is to reset the strict variable to default
40 Puppet.settings[:strict] = :warning
43 elsif Puppet.version.to_f < 4.0
44 # Puppet version < 4 will use these tests.
45 describe 'deprecation' do
47 ENV.delete('STDLIB_LOG_DEPRECATIONS')
50 ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
52 it { is_expected.not_to eq(nil) }
53 it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
55 it 'should display a single warning' do
56 scope.expects(:warning).with(includes('heelo'))
57 is_expected.to run.with_params('key', 'heelo')