Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / deprecation_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'deprecation function' do
4   test_file = if fact('operatingsystem') == 'windows'
5                 'C:/deprecation'
6               else
7                 '/tmp/deprecation'
8               end
9
10   # It seems that Windows needs everything to be on one line when using puppet apply -e, otherwise the manifests would be in an easier format
11   add_file_manifest = "\"deprecation('key', 'message') file { '#{test_file}': ensure => present, content => 'test', }\""
12   remove_file_manifest = "file { '#{test_file}': ensure => absent }"
13
14   before :all do
15     apply_manifest(remove_file_manifest)
16   end
17
18   context 'with --strict=error', :if => return_puppet_version =~ %r{^4} do
19     let(:result) { on(default, puppet('apply', '--strict=error', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) }
20
21     after :all do
22       apply_manifest(remove_file_manifest)
23     end
24
25     it 'returns an error' do
26       expect(result.exit_code).to eq(1)
27     end
28
29     it 'shows the error message' do
30       expect(result.stderr).to match(%r{deprecation. key. message})
31     end
32
33     describe file(test_file.to_s) do
34       it { is_expected.not_to be_file }
35     end
36   end
37
38   context 'with --strict=warning', :if => return_puppet_version =~ %r{^4} do
39     let(:result) { on(default, puppet('apply', '--strict=warning', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) }
40
41     after :all do
42       apply_manifest(remove_file_manifest)
43     end
44
45     it 'does not return an error' do
46       expect(result.exit_code).to eq(0)
47     end
48
49     it 'shows the error message' do
50       expect(result.stderr).to match(%r{Warning: message})
51     end
52
53     describe file(test_file.to_s) do
54       it { is_expected.to be_file }
55     end
56   end
57
58   context 'with --strict=off', :if => return_puppet_version =~ %r{^4} do
59     let(:result) { on(default, puppet('apply', '--strict=off', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) }
60
61     after :all do
62       apply_manifest(remove_file_manifest)
63     end
64
65     it 'does not return an error' do
66       expect(result.exit_code).to eq(0)
67     end
68
69     it 'does not show the error message' do
70       expect(result.stderr).not_to match(%r{Warning: message})
71     end
72
73     describe file(test_file.to_s) do
74       it { is_expected.to be_file }
75     end
76   end
77
78   context 'puppet 3 test', :if => return_puppet_version =~ %r{^3} do
79     let(:result) { on(default, puppet('apply', '--parser=future', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) }
80
81     after :all do
82       apply_manifest(remove_file_manifest)
83     end
84
85     it 'returns a deprecation error' do
86       expect(result.stderr).to match(%r{Warning: message})
87     end
88     it 'passes without error' do
89       expect(result.exit_code).to eq(0)
90     end
91   end
92 end