summaryrefslogtreecommitdiff
path: root/spec/functions/deprecation_spec.rb
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2017-01-13 12:41:58 +0100
committervarac <varacanero@zeromail.org>2017-01-13 12:41:58 +0100
commit066c08f8362d53f0f30897cb8710d11260c726ea (patch)
treea6369eecd88bb731fe413d0bbc8af73d74d1f447 /spec/functions/deprecation_spec.rb
parent71123634744b9fe2ec7d6a3e38e9789fd84801e3 (diff)
parentb65dd1f45d10e10e45455358aeabb29167990e2c (diff)
Merge remote-tracking branch 'origin/master' into leap_master
Diffstat (limited to 'spec/functions/deprecation_spec.rb')
-rw-r--r--spec/functions/deprecation_spec.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/functions/deprecation_spec.rb b/spec/functions/deprecation_spec.rb
new file mode 100644
index 0000000..cee4f1c
--- /dev/null
+++ b/spec/functions/deprecation_spec.rb
@@ -0,0 +1,60 @@
+require 'spec_helper'
+
+if Puppet.version.to_f >= 4.0
+ describe 'deprecation' do
+ before(:each) {
+ # this is to reset the strict variable to default
+ Puppet.settings[:strict] = :warning
+ }
+
+ it { is_expected.not_to eq(nil) }
+ it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+
+ it 'should display a single warning' do
+ Puppet.expects(:warning).with(includes('heelo'))
+ is_expected.to run.with_params('key', 'heelo')
+ end
+
+ it 'should display a single warning, despite multiple calls' do
+ Puppet.expects(:warning).with(includes('heelo')).once
+ is_expected.to run.with_params('key', 'heelo')
+ is_expected.to run.with_params('key', 'heelo')
+ end
+
+ it 'should fail twice with message, with multiple calls. when strict= :error' do
+ Puppet.settings[:strict] = :error
+ Puppet.expects(:warning).with(includes('heelo')).never
+ is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, /deprecation. key. heelo/)
+ is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, /deprecation. key. heelo/)
+ end
+
+ it 'should display nothing, despite multiple calls. strict= :off' do
+ Puppet.settings[:strict] = :off
+ Puppet.expects(:warning).with(includes('heelo')).never
+ is_expected.to run.with_params('key', 'heelo')
+ is_expected.to run.with_params('key', 'heelo')
+ end
+
+ after(:all) {
+ # this is to reset the strict variable to default
+ Puppet.settings[:strict] = :warning
+ }
+ end
+else
+ # Puppet version < 4 will use these tests.
+ describe 'deprecation' do
+ after(:all) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ before(:all) 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, /wrong number of arguments/i) }
+
+ it 'should display a single warning' do
+ scope.expects(:warning).with(includes('heelo'))
+ is_expected.to run.with_params('key', 'heelo')
+ end
+ end
+end