1 | require 'spec_helper'
|
---|
2 |
|
---|
3 | if Puppet.version.to_f >= 4.0
|
---|
4 | describe 'deprecation' do
|
---|
5 | before(:each) {
|
---|
6 | # this is to reset the strict variable to default
|
---|
7 | Puppet.settings[:strict] = :warning
|
---|
8 | }
|
---|
9 |
|
---|
10 | it { is_expected.not_to eq(nil) }
|
---|
11 | it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
|
---|
12 |
|
---|
13 | it 'should display 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 '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')
|
---|
22 | end
|
---|
23 |
|
---|
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/)
|
---|
29 | end
|
---|
30 |
|
---|
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')
|
---|
36 | end
|
---|
37 |
|
---|
38 | after(:all) {
|
---|
39 | # this is to reset the strict variable to default
|
---|
40 | Puppet.settings[:strict] = :warning
|
---|
41 | }
|
---|
42 | end
|
---|
43 | else
|
---|
44 | describe 'deprecation' do
|
---|
45 | after(:all) do
|
---|
46 | ENV.delete('STDLIB_LOG_DEPRECATIONS')
|
---|
47 | end
|
---|
48 | ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
|
---|
49 | it { is_expected.not_to eq(nil) }
|
---|
50 | it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
|
---|
51 |
|
---|
52 | it 'should display a single warning' do
|
---|
53 | scope.expects(:warning).with(includes('heelo'))
|
---|
54 | is_expected.to run.with_params('key', 'heelo')
|
---|
55 | end
|
---|
56 | end
|
---|
57 | end
|
---|