summaryrefslogtreecommitdiff
path: root/spec/functions
diff options
context:
space:
mode:
authortphoney <tp@puppet.com>2016-08-03 17:06:25 +0100
committertphoney <tp@puppet.com>2016-08-08 15:02:25 +0100
commit6e7e69fe203e042b28aacb01301c338d55448c5f (patch)
tree8250e2fed853d18036e9e3121454a7c1362b2064 /spec/functions
parent16a26f6ab40a4b1d7e6836ff6de24850f0b8fb35 (diff)
(modules-3533) deprecation for 3.x number function
Diffstat (limited to 'spec/functions')
-rw-r--r--spec/functions/deprecation_spec.rb18
-rwxr-xr-xspec/functions/is_float_spec.rb7
-rwxr-xr-xspec/functions/is_integer_spec.rb7
-rwxr-xr-xspec/functions/is_numeric_spec.rb7
-rwxr-xr-xspec/functions/validate_integer_spec.rb6
-rwxr-xr-xspec/functions/validate_numeric_spec.rb6
6 files changed, 43 insertions, 8 deletions
diff --git a/spec/functions/deprecation_spec.rb b/spec/functions/deprecation_spec.rb
index bbabe48..a596e24 100644
--- a/spec/functions/deprecation_spec.rb
+++ b/spec/functions/deprecation_spec.rb
@@ -1,13 +1,5 @@
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) {
@@ -48,4 +40,14 @@ if Puppet.version.to_f >= 4.0
Puppet.settings[:strict] = :warning
}
end
+else
+ describe 'deprecation' do
+ 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(:warn).with(includes('heelo'))
+ is_expected.to run.with_params('key', 'heelo')
+ end
+ end
end
diff --git a/spec/functions/is_float_spec.rb b/spec/functions/is_float_spec.rb
index ffff971..267d9c6 100755
--- a/spec/functions/is_float_spec.rb
+++ b/spec/functions/is_float_spec.rb
@@ -2,6 +2,13 @@ require 'spec_helper'
describe 'is_float' do
it { is_expected.not_to eq(nil) }
+
+ # Checking for deprecation warning
+ it 'should display a single deprecation' do
+ scope.expects(:warn).with(includes('This method is deprecated'))
+ is_expected.to run.with_params(3)
+ end
+
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
it { is_expected.to run.with_params(0.1, 0.2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
diff --git a/spec/functions/is_integer_spec.rb b/spec/functions/is_integer_spec.rb
index 67263c1..49550c7 100755
--- a/spec/functions/is_integer_spec.rb
+++ b/spec/functions/is_integer_spec.rb
@@ -2,6 +2,13 @@ require 'spec_helper'
describe 'is_integer' do
it { is_expected.not_to eq(nil) }
+
+ # Checking for deprecation warning
+ it 'should display a single deprecation' do
+ scope.expects(:warn).with(includes('This method is deprecated'))
+ is_expected.to run.with_params(3)
+ end
+
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
diff --git a/spec/functions/is_numeric_spec.rb b/spec/functions/is_numeric_spec.rb
index d0f5a6e..b7de051 100755
--- a/spec/functions/is_numeric_spec.rb
+++ b/spec/functions/is_numeric_spec.rb
@@ -2,6 +2,13 @@ require 'spec_helper'
describe 'is_numeric' do
it { is_expected.not_to eq(nil) }
+
+ # Checking for deprecation warning
+ it 'should display a single deprecation' do
+ scope.expects(:warn).with(includes('This method is deprecated'))
+ is_expected.to run.with_params(3)
+ end
+
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
diff --git a/spec/functions/validate_integer_spec.rb b/spec/functions/validate_integer_spec.rb
index 4c0a9d7..0eeab1e 100755
--- a/spec/functions/validate_integer_spec.rb
+++ b/spec/functions/validate_integer_spec.rb
@@ -1,6 +1,12 @@
require 'spec_helper'
describe 'validate_integer' do
+ # Checking for deprecation warning
+ it 'should display a single deprecation' do
+ scope.expects(:warn).with(includes('This method is deprecated'))
+ is_expected.to run.with_params(3)
+ end
+
describe 'signature validation' do
it { is_expected.not_to eq(nil) }
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
diff --git a/spec/functions/validate_numeric_spec.rb b/spec/functions/validate_numeric_spec.rb
index 9b8eb0e..2e5561e 100755
--- a/spec/functions/validate_numeric_spec.rb
+++ b/spec/functions/validate_numeric_spec.rb
@@ -1,6 +1,12 @@
require 'spec_helper'
describe 'validate_numeric' do
+ # Checking for deprecation warning
+ it 'should display a single deprecation' do
+ scope.expects(:warn).with(includes('This method is deprecated'))
+ is_expected.to run.with_params(3)
+ end
+
describe 'signature validation' do
it { is_expected.not_to eq(nil) }
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }