|
| 1 | +require 'spec_helper' |
| 2 | +require "puppet_x/puppetlabs/stdlib/deprecation_state" |
| 3 | + |
| 4 | +if ENV["FUTURE_PARSER"] == 'yes' |
| 5 | + describe 'deprecation' do |
| 6 | + pending 'teach rspec-puppet to load future-only functions under 3.7.5' do |
| 7 | + it { is_expected.not_to eq(nil) } |
| 8 | + end |
| 9 | + end |
| 10 | +end |
| 11 | + |
| 12 | +if Puppet.version.to_f >= 4.0 |
| 13 | + describe 'deprecation' do |
| 14 | + before(:each) { |
| 15 | + # this is to reset the deprecation warning track, and strict variable to default |
| 16 | + PuppetX::Puppetlabs::Stdlib::DeprecationState.class_variable_set :@@deprecation_warning_said, [] |
| 17 | + Puppet.settings[:strict] = :warning |
| 18 | + } |
| 19 | + |
| 20 | + it { is_expected.not_to eq(nil) } |
| 21 | + it { is_expected.to run.with_params().and_raise_error(ArgumentError) } |
| 22 | + |
| 23 | + it 'should display a single warning' do |
| 24 | + Puppet.expects(:warning).with(includes('heelo, called by')) |
| 25 | + is_expected.to run.with_params("heelo") |
| 26 | + end |
| 27 | + |
| 28 | + it 'should display a single warning, despite multiple calls' do |
| 29 | + Puppet.expects(:warning).with(includes('heelo, called by')).once |
| 30 | + is_expected.to run.with_params("heelo") |
| 31 | + is_expected.to run.with_params("heelo") |
| 32 | + end |
| 33 | + |
| 34 | + it 'should display a single error, despite multiple calls. strict= :error' do |
| 35 | + Puppet.settings[:strict] = :error |
| 36 | + Puppet.expects(:err).with(includes('heelo, called by')).once |
| 37 | + is_expected.to run.with_params("heelo") |
| 38 | + is_expected.to run.with_params("heelo") |
| 39 | + end |
| 40 | + |
| 41 | + it 'should display nothing, despite multiple calls. strict= :off' do |
| 42 | + Puppet.settings[:strict] = :off |
| 43 | + Puppet.expects(:warning).with(includes('heelo, called by')).never |
| 44 | + Puppet.expects(:err).with(includes('heelo, called by')).never |
| 45 | + is_expected.to run.with_params("heelo") |
| 46 | + is_expected.to run.with_params("heelo") |
| 47 | + end |
| 48 | + |
| 49 | + end |
| 50 | +end |
0 commit comments