|
2 | 2 |
|
3 | 3 | require 'spec_helper'
|
4 | 4 |
|
5 |
| -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 |
6 |
| - describe 'deprecation' do |
7 |
| - before(:each) do |
8 |
| - # this is to reset the strict variable to default |
9 |
| - Puppet.settings[:strict] = :warning |
10 |
| - end |
| 5 | +describe 'deprecation' do |
| 6 | + before(:each) do |
| 7 | + # this is to reset the strict variable to default |
| 8 | + Puppet.settings[:strict] = :warning |
| 9 | + end |
11 | 10 |
|
12 |
| - after(:each) do |
13 |
| - # this is to reset the strict variable to default |
14 |
| - Puppet.settings[:strict] = :warning |
15 |
| - end |
| 11 | + after(:each) do |
| 12 | + # this is to reset the strict variable to default |
| 13 | + Puppet.settings[:strict] = :warning |
| 14 | + end |
16 | 15 |
|
17 |
| - it { is_expected.not_to be_nil } |
18 |
| - it { is_expected.to run.with_params.and_raise_error(ArgumentError) } |
| 16 | + it { is_expected.not_to be_nil } |
| 17 | + it { is_expected.to run.with_params.and_raise_error(ArgumentError) } |
19 | 18 |
|
20 |
| - it 'displays a single warning' do |
21 |
| - if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') < 0 |
22 |
| - expect(Puppet).to receive(:deprecation_warning).with('heelo at :', 'key') |
23 |
| - expect(Puppet).to receive(:deprecation_warning).with("Modifying 'autosign' as a setting is deprecated.") |
24 |
| - else |
25 |
| - expect(Puppet).to receive(:warning).with(include('heelo')).once |
26 |
| - end |
27 |
| - expect(subject).to run.with_params('key', 'heelo') |
| 19 | + it 'displays a single warning' do |
| 20 | + if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') < 0 |
| 21 | + expect(Puppet).to receive(:deprecation_warning).with('heelo at :', 'key') |
| 22 | + expect(Puppet).to receive(:deprecation_warning).with("Modifying 'autosign' as a setting is deprecated.") |
| 23 | + else |
| 24 | + expect(Puppet).to receive(:warning).with(include('heelo')).once |
28 | 25 | end
|
| 26 | + expect(subject).to run.with_params('key', 'heelo') |
| 27 | + end |
29 | 28 |
|
30 |
| - it 'displays a single warning, despite multiple calls' do |
31 |
| - if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') < 0 |
32 |
| - expect(Puppet).to receive(:deprecation_warning).with('heelo at :', 'key').twice |
33 |
| - expect(Puppet).to receive(:deprecation_warning).with("Modifying 'autosign' as a setting is deprecated.") |
34 |
| - else |
35 |
| - expect(Puppet).to receive(:warning).with(include('heelo')).once |
36 |
| - end |
37 |
| - 2.times do |_i| |
38 |
| - expect(subject).to run.with_params('key', 'heelo') |
39 |
| - end |
| 29 | + it 'displays a single warning, despite multiple calls' do |
| 30 | + if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') < 0 |
| 31 | + expect(Puppet).to receive(:deprecation_warning).with('heelo at :', 'key').twice |
| 32 | + expect(Puppet).to receive(:deprecation_warning).with("Modifying 'autosign' as a setting is deprecated.") |
| 33 | + else |
| 34 | + expect(Puppet).to receive(:warning).with(include('heelo')).once |
40 | 35 | end
|
41 |
| - |
42 |
| - it 'fails twice with message, with multiple calls. when strict= :error' do |
43 |
| - Puppet.settings[:strict] = :error |
44 |
| - expect(Puppet).not_to receive(:warning).with(include('heelo')) |
45 |
| - 2.times do |_i| |
46 |
| - expect(subject).to run.with_params('key', 'heelo').and_raise_error(RuntimeError, %r{deprecation. key. heelo}) |
47 |
| - end |
| 36 | + 2.times do |_i| |
| 37 | + expect(subject).to run.with_params('key', 'heelo') |
48 | 38 | end
|
| 39 | + end |
49 | 40 |
|
50 |
| - it 'displays nothing, despite multiple calls. strict= :off' do |
51 |
| - Puppet.settings[:strict] = :off |
52 |
| - expect(Puppet).not_to receive(:warning).with(include('heelo')) |
53 |
| - 2.times do |_i| |
54 |
| - expect(subject).to run.with_params('key', 'heelo') |
55 |
| - end |
| 41 | + it 'fails twice with message, with multiple calls. when strict= :error' do |
| 42 | + Puppet.settings[:strict] = :error |
| 43 | + expect(Puppet).not_to receive(:warning).with(include('heelo')) |
| 44 | + 2.times do |_i| |
| 45 | + expect(subject).to run.with_params('key', 'heelo').and_raise_error(RuntimeError, %r{deprecation. key. heelo}) |
56 | 46 | end
|
57 | 47 | end
|
58 |
| -elsif Puppet.version.to_f < 4.0 |
59 |
| - # Puppet version < 4 will use these tests. |
60 |
| - describe 'deprecation' do |
61 |
| - after(:each) do |
62 |
| - ENV.delete('STDLIB_LOG_DEPRECATIONS') |
63 |
| - end |
64 | 48 |
|
65 |
| - before(:each) do |
66 |
| - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' |
| 49 | + it 'displays nothing, despite multiple calls. strict= :off' do |
| 50 | + Puppet.settings[:strict] = :off |
| 51 | + expect(Puppet).not_to receive(:warning).with(include('heelo')) |
| 52 | + 2.times do |_i| |
| 53 | + expect(subject).to run.with_params('key', 'heelo') |
67 | 54 | end
|
| 55 | + end |
68 | 56 |
|
69 |
| - it { is_expected.not_to be_nil } |
70 |
| - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } |
| 57 | + context 'with `use_strict_setting` `false`' do |
| 58 | + let(:params) { ['key', 'heelo', false] } |
71 | 59 |
|
72 |
| - it 'displays a single warning' do |
73 |
| - expect(scope).to receive(:warning).with(include('heelo')) |
74 |
| - expect(subject).to run.with_params('key', 'heelo') |
| 60 | + context 'and `strict` setting set to `error`' do |
| 61 | + it 'displays a warning' do |
| 62 | + Puppet.settings[:strict] = :error |
| 63 | + expect(Puppet).to receive(:warning).with(include('heelo')).once |
| 64 | + expect(subject).to run.with_params(*params) |
| 65 | + end |
| 66 | + end |
| 67 | + |
| 68 | + context 'and `strict` setting set to `off`' do |
| 69 | + it 'displays a warning' do |
| 70 | + Puppet.settings[:strict] = :off |
| 71 | + expect(Puppet).to receive(:warning).with(include('heelo')).once |
| 72 | + expect(subject).to run.with_params(*params) |
| 73 | + end |
75 | 74 | end
|
76 | 75 | end
|
77 | 76 | end
|
0 commit comments