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