1 require 'spec_helper_acceptance'
3 describe 'deprecation function' do
4 test_file = if fact('operatingsystem') == 'windows'
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 }"
15 apply_manifest(remove_file_manifest)
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)) }
22 apply_manifest(remove_file_manifest)
25 it 'returns an error' do
26 expect(result.exit_code).to eq(1)
29 it 'shows the error message' do
30 expect(result.stderr).to match(%r{deprecation. key. message})
33 describe file(test_file.to_s) do
34 it { is_expected.not_to be_file }
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)) }
42 apply_manifest(remove_file_manifest)
45 it 'does not return an error' do
46 expect(result.exit_code).to eq(0)
49 it 'shows the error message' do
50 expect(result.stderr).to match(%r{Warning: message})
53 describe file(test_file.to_s) do
54 it { is_expected.to be_file }
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)) }
62 apply_manifest(remove_file_manifest)
65 it 'does not return an error' do
66 expect(result.exit_code).to eq(0)
69 it 'does not show the error message' do
70 expect(result.stderr).not_to match(%r{Warning: message})
73 describe file(test_file.to_s) do
74 it { is_expected.to be_file }
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)) }
82 apply_manifest(remove_file_manifest)
85 it 'returns a deprecation error' do
86 expect(result.stderr).to match(%r{Warning: message})
88 it 'passes without error' do
89 expect(result.exit_code).to eq(0)