1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
4 describe 'deprecation function' do
6 if fact('operatingsystem') == 'windows'
7 test_file = 'C:/deprecation'
9 test_file = "/tmp/deprecation"
12 # 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
13 add_file_manifest = "\"deprecation('key', 'message') file { '#{test_file}': ensure => present, content => 'test', }\""
14 remove_file_manifest = "file { '#{test_file}': ensure => absent }"
17 apply_manifest(remove_file_manifest)
20 context 'with --strict=error', if: get_puppet_version =~ /^4/ do
22 @result = on(default, puppet('apply', '--strict=error', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
26 apply_manifest(remove_file_manifest)
29 it "should return an error" do
30 expect(@result.exit_code).to eq(1)
33 it "should show the error message" do
34 expect(@result.stderr).to match(/deprecation. key. message/)
37 describe file("#{test_file}") do
38 it { is_expected.not_to be_file }
42 context 'with --strict=warning', if: get_puppet_version =~ /^4/ do
44 @result = on(default, puppet('apply', '--strict=warning', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
48 apply_manifest(remove_file_manifest)
51 it "should not return an error" do
52 expect(@result.exit_code).to eq(0)
55 it "should show the error message" do
56 expect(@result.stderr).to match(/Warning: message/)
59 describe file("#{test_file}") do
60 it { is_expected.to be_file }
64 context 'with --strict=off', if: get_puppet_version =~ /^4/ do
66 @result = on(default, puppet('apply', '--strict=off', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
70 apply_manifest(remove_file_manifest)
73 it "should not return an error" do
74 expect(@result.exit_code).to eq(0)
77 it "should not show the error message" do
78 expect(@result.stderr).not_to match(/Warning: message/)
81 describe file("#{test_file}") do
82 it { is_expected.to be_file }
86 context 'puppet 3 test', if: get_puppet_version =~ /^3/ do
88 @result = on(default, puppet('apply', '--parser=future', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
91 apply_manifest(remove_file_manifest)
94 it "should return a deprecation error" do
95 expect(@result.stderr).to match(/Warning: message/)
97 it "should pass without error" do
98 expect(@result.exit_code).to eq(0)