summaryrefslogtreecommitdiff
path: root/spec/functions/deprecation_spec.rb
diff options
context:
space:
mode:
authorDavid Schmitt <david.schmitt@puppet.com>2016-07-18 13:27:49 +0100
committerGitHub <noreply@github.com>2016-07-18 13:27:49 +0100
commit01bc41e73621fa07d0b14b3b3fa8a75e666a7df5 (patch)
tree82a2087cd945247dfadee41dcd8f8cd5bec84ab6 /spec/functions/deprecation_spec.rb
parent9224143da2195c57ce814e837f722348c2038ecb (diff)
parent72d23659513517389880ba13663a1d6380d538ca (diff)
Merge pull request #617 from tphoney/add_deprecate_function
(MODULES-3529) add deprecation function
Diffstat (limited to 'spec/functions/deprecation_spec.rb')
-rw-r--r--spec/functions/deprecation_spec.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/functions/deprecation_spec.rb b/spec/functions/deprecation_spec.rb
new file mode 100644
index 0000000..bbabe48
--- /dev/null
+++ b/spec/functions/deprecation_spec.rb
@@ -0,0 +1,51 @@
+require 'spec_helper'
+
+if ENV["FUTURE_PARSER"] == 'yes'
+ describe 'deprecation' do
+ pending 'teach rspec-puppet to load future-only functions under 3.7.5' do
+ it { is_expected.not_to eq(nil) }
+ end
+ end
+end
+
+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
+end