272
|
1 require 'spec_helper'
|
|
2
|
|
3 if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
|
|
4 describe 'deprecation' do
|
|
5 before(:each) do
|
|
6 # this is to reset the strict variable to default
|
|
7 Puppet.settings[:strict] = :warning
|
|
8 end
|
|
9
|
|
10 it { is_expected.not_to eq(nil) }
|
|
11 it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
|
|
12
|
|
13 it 'displays a single warning' do
|
|
14 Puppet.expects(:warning).with(includes('heelo'))
|
|
15 is_expected.to run.with_params('key', 'heelo')
|
|
16 end
|
|
17
|
|
18 it 'displays a single warning, despite multiple calls' do
|
|
19 Puppet.expects(:warning).with(includes('heelo')).once
|
|
20 (0..1).each do |_i|
|
|
21 is_expected.to run.with_params('key', 'heelo')
|
|
22 end
|
|
23 end
|
|
24
|
|
25 it 'fails twice with message, with multiple calls. when strict= :error' do
|
|
26 Puppet.settings[:strict] = :error
|
|
27 Puppet.expects(:warning).with(includes('heelo')).never
|
|
28 (0..1).each do |_i|
|
|
29 is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, %r{deprecation. key. heelo})
|
|
30 end
|
|
31 end
|
|
32
|
|
33 it 'displays nothing, despite multiple calls. strict= :off' do
|
|
34 Puppet.settings[:strict] = :off
|
|
35 Puppet.expects(:warning).with(includes('heelo')).never
|
|
36 (0..1).each do |_i|
|
|
37 is_expected.to run.with_params('key', 'heelo')
|
|
38 end
|
|
39 end
|
|
40
|
|
41 after(:each) do
|
|
42 # this is to reset the strict variable to default
|
|
43 Puppet.settings[:strict] = :warning
|
|
44 end
|
|
45 end
|
|
46 elsif Puppet.version.to_f < 4.0
|
|
47 # Puppet version < 4 will use these tests.
|
|
48 describe 'deprecation' do
|
|
49 after(:each) do
|
|
50 ENV.delete('STDLIB_LOG_DEPRECATIONS')
|
|
51 end
|
|
52 before(:each) do
|
|
53 ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
|
|
54 end
|
|
55 it { is_expected.not_to eq(nil) }
|
|
56 it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
|
|
57
|
|
58 it 'displays a single warning' do
|
|
59 scope.expects(:warning).with(includes('heelo'))
|
|
60 is_expected.to run.with_params('key', 'heelo')
|
|
61 end
|
|
62 end
|
|
63 end
|