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 'displays a single warning' do
14 if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') < 0
15 expect(Puppet).to receive(:deprecation_warning).with('heelo at :', 'key')
16 expect(Puppet).to receive(:deprecation_warning).with("Modifying 'autosign' as a setting is deprecated.")
18 expect(Puppet).to receive(:warning).with(include('heelo')).once
20 is_expected.to run.with_params('key', 'heelo')
23 it 'displays a single warning, despite multiple calls' do
24 if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') < 0
25 expect(Puppet).to receive(:deprecation_warning).with('heelo at :', 'key').twice
26 expect(Puppet).to receive(:deprecation_warning).with("Modifying 'autosign' as a setting is deprecated.")
28 expect(Puppet).to receive(:warning).with(include('heelo')).once
31 is_expected.to run.with_params('key', 'heelo')
35 it 'fails twice with message, with multiple calls. when strict= :error' do
36 Puppet.settings[:strict] = :error
37 expect(Puppet).to receive(:warning).with(include('heelo')).never
39 is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, %r{deprecation. key. heelo})
43 it 'displays nothing, despite multiple calls. strict= :off' do
44 Puppet.settings[:strict] = :off
45 expect(Puppet).to receive(:warning).with(include('heelo')).never
47 is_expected.to run.with_params('key', 'heelo')
52 # this is to reset the strict variable to default
53 Puppet.settings[:strict] = :warning
56 elsif Puppet.version.to_f < 4.0
57 # Puppet version < 4 will use these tests.
58 describe 'deprecation' do
60 ENV.delete('STDLIB_LOG_DEPRECATIONS')
63 ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
65 it { is_expected.not_to eq(nil) }
66 it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
68 it 'displays a single warning' do
69 expect(scope).to receive(:warning).with(include('heelo'))
70 is_expected.to run.with_params('key', 'heelo')