summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/acceptance/deprecation_spec.rb58
-rw-r--r--spec/classes/validate_legacy_spec.rb39
-rw-r--r--spec/fixtures/test/manifests/validate_legacy.pp18
-rwxr-xr-xspec/functions/assert_private_spec.rb30
-rw-r--r--spec/functions/deprecation_spec.rb4
-rwxr-xr-xspec/functions/is_array_spec.rb22
-rwxr-xr-xspec/functions/is_bool_spec.rb23
-rwxr-xr-xspec/functions/is_float_spec.rb25
-rwxr-xr-xspec/functions/is_integer_spec.rb27
-rwxr-xr-xspec/functions/is_ip_address_spec.rb20
-rw-r--r--spec/functions/is_ipv4_address_spec.rb21
-rw-r--r--spec/functions/is_ipv6_address_spec.rb21
-rwxr-xr-xspec/functions/is_numeric_spec.rb25
-rwxr-xr-xspec/functions/is_string_spec.rb24
-rwxr-xr-xspec/functions/validate_absolute_path_spec.rb5
-rwxr-xr-xspec/functions/validate_array_spec.rb5
-rwxr-xr-xspec/functions/validate_bool_spec.rb5
-rwxr-xr-xspec/functions/validate_integer_spec.rb5
-rw-r--r--spec/functions/validate_ip_address_spec.rb21
-rwxr-xr-xspec/functions/validate_ipv4_address_spec.rb73
-rwxr-xr-xspec/functions/validate_ipv6_address_spec.rb62
-rw-r--r--spec/functions/validate_legacy_spec.rb68
-rwxr-xr-xspec/functions/validate_numeric_spec.rb5
-rwxr-xr-xspec/functions/validate_re_spec.rb21
-rwxr-xr-xspec/functions/validate_string_spec.rb5
25 files changed, 414 insertions, 218 deletions
diff --git a/spec/acceptance/deprecation_spec.rb b/spec/acceptance/deprecation_spec.rb
index d0d7fed..ea13700 100644
--- a/spec/acceptance/deprecation_spec.rb
+++ b/spec/acceptance/deprecation_spec.rb
@@ -1,19 +1,29 @@
#! /usr/bin/env ruby -S rspec
require 'spec_helper_acceptance'
-require 'shellwords'
describe 'deprecation function' do
- before :each do
- FileUtils.rm_rf '/tmp/deprecation'
+
+ if fact('operatingsystem') == 'windows'
+ test_file = 'C:/deprecation'
+ else
+ test_file = "/tmp/deprecation"
+ end
+
+ # 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
+ add_file_manifest = "\"deprecation('key', 'message') file { '#{test_file}': ensure => present, content => 'test', }\""
+ remove_file_manifest = "file { '#{test_file}': ensure => absent }"
+
+ before :all do
+ apply_manifest(remove_file_manifest)
end
context 'with --strict=error', if: get_puppet_version =~ /^4/ do
before :all do
- pp = <<-EOS
- deprecation('key', 'message')
- file { '/tmp/deprecation': ensure => present }
- EOS
- @result = on(default, puppet('apply', '--strict=error', '-e', Shellwords.shellescape(pp)), acceptable_exit_codes: (0...256))
+ @result = on(default, puppet('apply', '--strict=error', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
+ end
+
+ after :all do
+ apply_manifest(remove_file_manifest)
end
it "should return an error" do
@@ -24,18 +34,18 @@ describe 'deprecation function' do
expect(@result.stderr).to match(/deprecation. key. message/)
end
- describe file('/tmp/deprecation') do
- it { is_expected.not_to exist }
+ describe file("#{test_file}") do
+ it { is_expected.not_to be_file }
end
end
context 'with --strict=warning', if: get_puppet_version =~ /^4/ do
before :all do
- pp = <<-EOS
- deprecation('key', 'message')
- file { '/tmp/deprecation': ensure => present }
- EOS
- @result = on(default, puppet('apply', '--strict=warning', '-e', Shellwords.shellescape(pp)), acceptable_exit_codes: (0...256))
+ @result = on(default, puppet('apply', '--strict=warning', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
+ end
+
+ after :all do
+ apply_manifest(remove_file_manifest)
end
it "should not return an error" do
@@ -46,18 +56,18 @@ describe 'deprecation function' do
expect(@result.stderr).to match(/Warning: message/)
end
- describe file('/tmp/deprecation') do
- it { is_expected.to exist }
+ describe file("#{test_file}") do
+ it { is_expected.to be_file }
end
end
context 'with --strict=off', if: get_puppet_version =~ /^4/ do
before :all do
- pp = <<-EOS
- deprecation('key', 'message')
- file { '/tmp/deprecation': ensure => present }
- EOS
- @result = on(default, puppet('apply', '--strict=off', '-e', Shellwords.shellescape(pp)), acceptable_exit_codes: (0...256))
+ @result = on(default, puppet('apply', '--strict=off', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
+ end
+
+ after :all do
+ apply_manifest(remove_file_manifest)
end
it "should not return an error" do
@@ -68,8 +78,8 @@ describe 'deprecation function' do
expect(@result.stderr).not_to match(/Warning: message/)
end
- describe file('/tmp/deprecation') do
- it { is_expected.to exist }
+ describe file("#{test_file}") do
+ it { is_expected.to be_file }
end
end
end
diff --git a/spec/classes/validate_legacy_spec.rb b/spec/classes/validate_legacy_spec.rb
deleted file mode 100644
index ded6890..0000000
--- a/spec/classes/validate_legacy_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require 'spec_helper'
-
-if Puppet.version.to_f >= 4.0
- # validate_legacy requires a proper scope to run, so we have to trigger a true compilation here,
- # instead of being able to leverage the function test group.
- describe 'test::validate_legacy', type: :class do
-
- describe 'validate_legacy passes assertion of type but not previous validation' do
- let(:params) {{ type: "Optional[Integer]", prev_validation: "validate_re", value: 5, previous_arg1: ["^\\d+$", ""] }}
- it {
- Puppet.expects(:warn).with(includes('Accepting previously invalid value for target_type'))
- is_expected.to compile
- }
- end
-
- describe 'validate_legacy passes assertion of type and previous validation' do
- let(:params) {{ type: "Optional[String]", prev_validation: "validate_re", value: "5", previous_arg1: ["."] }}
- it { is_expected.to compile }
- end
-
- describe 'validate_legacy fails assertion of type and passes previous validation' do
- let(:params) {{ type: "Optional[Integer]", prev_validation: "validate_re", value: "5", previous_arg1: ["."] }}
- it {
- Puppet.expects(:warn).with(includes('expected'))
- is_expected.to compile
- }
- end
-
- describe 'validate_legacy fails assertion and fails previous validation' do
- let(:params) {{ type: "Optional[Integer]", prev_validation: "validate_re", value: "5", previous_arg1: ["thisisnotright"] }}
- it { is_expected.to compile.and_raise_error(/Error while evaluating a Function Call, \w* expected an \w* value, got \w*/) }
- end
-
- describe 'validate_legacy works with multi-argument validate_ functions' do
- let(:params) {{ type: "Integer", prev_validation: "validate_integer", value: 10, previous_arg1: 100, previous_arg2: 0 }}
- it { is_expected.to compile }
- end
- end
-end
diff --git a/spec/fixtures/test/manifests/validate_legacy.pp b/spec/fixtures/test/manifests/validate_legacy.pp
deleted file mode 100644
index 706df88..0000000
--- a/spec/fixtures/test/manifests/validate_legacy.pp
+++ /dev/null
@@ -1,18 +0,0 @@
-# Class to test stdlib validate_legacy function
-
-class test::validate_legacy(
- $type,
- $prev_validation,
- $value,
- $previous_arg1,
- $previous_arg2 = undef,
- ) {
-
- if $previous_arg2 == undef {
- validate_legacy( $type, $prev_validation, $value, $previous_arg1 )
- } else {
- validate_legacy( $type, $prev_validation, $value, $previous_arg1, $previous_arg2 )
- }
- notice("Success")
-
-}
diff --git a/spec/functions/assert_private_spec.rb b/spec/functions/assert_private_spec.rb
index 98f2598..355e0dd 100755
--- a/spec/functions/assert_private_spec.rb
+++ b/spec/functions/assert_private_spec.rb
@@ -5,31 +5,26 @@ describe 'assert_private' do
it "should not fail" do
scope.expects(:lookupvar).with('module_name').returns('foo')
scope.expects(:lookupvar).with('caller_module_name').returns('foo')
- expect {
- subject.call []
- }.not_to raise_error
+
+ is_expected.to run.with_params()
end
end
- context "with an explicit failure message" do
- it "prints the failure message on error" do
+ context "when called from private class" do
+ before :each do
scope.expects(:lookupvar).with('module_name').returns('foo')
scope.expects(:lookupvar).with('caller_module_name').returns('bar')
- expect {
- subject.call ['failure message!']
- }.to raise_error Puppet::ParseError, /failure message!/
end
- end
- context "when called from private class" do
it "should fail with a class error message" do
- scope.expects(:lookupvar).with('module_name').returns('foo')
- scope.expects(:lookupvar).with('caller_module_name').returns('bar')
scope.source.expects(:name).returns('foo::baz')
scope.source.expects(:type).returns('hostclass')
- expect {
- subject.call []
- }.to raise_error Puppet::ParseError, /Class foo::baz is private/
+
+ is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Class foo::baz is private/)
+ end
+
+ context "with an explicit failure message" do
+ it { is_expected.to run.with_params('failure message!').and_raise_error(Puppet::ParseError, /failure message!/) }
end
end
@@ -39,9 +34,8 @@ describe 'assert_private' do
scope.expects(:lookupvar).with('caller_module_name').returns('bar')
scope.source.expects(:name).returns('foo::baz')
scope.source.expects(:type).returns('definition')
- expect {
- subject.call []
- }.to raise_error Puppet::ParseError, /Definition foo::baz is private/
+
+ is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Definition foo::baz is private/)
end
end
end
diff --git a/spec/functions/deprecation_spec.rb b/spec/functions/deprecation_spec.rb
index c213190..4321c3d 100644
--- a/spec/functions/deprecation_spec.rb
+++ b/spec/functions/deprecation_spec.rb
@@ -42,6 +42,10 @@ if Puppet.version.to_f >= 4.0
end
else
describe 'deprecation' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
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/is_array_spec.rb b/spec/functions/is_array_spec.rb
index 0a8070b..2350b7f 100755
--- a/spec/functions/is_array_spec.rb
+++ b/spec/functions/is_array_spec.rb
@@ -1,12 +1,8 @@
require 'spec_helper'
describe 'is_array' do
+
it { is_expected.not_to eq(nil) }
- # Checking for deprecation warning
- it 'should display a single deprecation' do
- scope.expects(:warning).with(includes('This method is deprecated'))
- is_expected.to run.with_params([])
- end
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
it {
pending("Current implementation ignores parameters after the first.")
@@ -21,4 +17,20 @@ describe 'is_array' do
it { is_expected.to run.with_params('one').and_return(false) }
it { is_expected.to run.with_params(1).and_return(false) }
it { is_expected.to run.with_params({}).and_return(false) }
+ context 'Checking for deprecation warning' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params(['1.2.3.4']).and_return(true)
+ end
+ it 'should display no warning for deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+ scope.expects(:warning).with(includes('This method is deprecated')).never
+ is_expected.to run.with_params(['1.2.3.4']).and_return(true)
+ end
+ end
end
diff --git a/spec/functions/is_bool_spec.rb b/spec/functions/is_bool_spec.rb
index 4550e61..7b2173e 100755
--- a/spec/functions/is_bool_spec.rb
+++ b/spec/functions/is_bool_spec.rb
@@ -1,12 +1,8 @@
require 'spec_helper'
describe 'is_bool' do
+
it { is_expected.not_to eq(nil) }
- # Checking for deprecation warning
- it 'should display a single deprecation' do
- scope.expects(:warning).with(includes('This method is deprecated'))
- is_expected.to run.with_params(true)
- 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(true, false).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
it { is_expected.to run.with_params(true).and_return(true) }
@@ -17,4 +13,21 @@ describe 'is_bool' do
it { is_expected.to run.with_params([true]).and_return(false) }
it { is_expected.to run.with_params('true').and_return(false) }
it { is_expected.to run.with_params('false').and_return(false) }
+ context 'Checking for deprecation warning' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params(true).and_return(true)
+ end
+ it 'should display no warning for deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+ scope.expects(:warning).with(includes('This method is deprecated')).never
+ is_expected.to run.with_params(false).and_return(true)
+ end
+ end
end
+
diff --git a/spec/functions/is_float_spec.rb b/spec/functions/is_float_spec.rb
index cb7e148..44bdc48 100755
--- a/spec/functions/is_float_spec.rb
+++ b/spec/functions/is_float_spec.rb
@@ -1,13 +1,8 @@
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(:warning).with(includes('This method is deprecated'))
- is_expected.to run.with_params(3)
- 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 { is_expected.to run.with_params(0.1, 0.2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
@@ -26,4 +21,22 @@ describe 'is_float' do
it { is_expected.to run.with_params(1.0).and_return(true) }
it { is_expected.to run.with_params(1).and_return(false) }
end
+
+ context 'Checking for deprecation warning' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params(2.2).and_return(true)
+ end
+ it 'should display no warning for deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+ scope.expects(:warning).with(includes('This method is deprecated')).never
+ is_expected.to run.with_params(1.0).and_return(true)
+ end
+ end
+
end
diff --git a/spec/functions/is_integer_spec.rb b/spec/functions/is_integer_spec.rb
index 2d68731..4b5dd21 100755
--- a/spec/functions/is_integer_spec.rb
+++ b/spec/functions/is_integer_spec.rb
@@ -1,14 +1,9 @@
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(:warning).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) }
@@ -16,7 +11,7 @@ describe 'is_integer' do
it { is_expected.to run.with_params('3').and_return(true) }
it { is_expected.to run.with_params(-3).and_return(true) }
it { is_expected.to run.with_params('-3').and_return(true) }
-
+
it { is_expected.to run.with_params(3.7).and_return(false) }
it { is_expected.to run.with_params('3.7').and_return(false) }
it { is_expected.to run.with_params(-3.7).and_return(false) }
@@ -29,4 +24,22 @@ describe 'is_integer' do
it { is_expected.to run.with_params(true).and_return(false) }
it { is_expected.to run.with_params(false).and_return(false) }
it { is_expected.to run.with_params('0001234').and_return(false) }
+
+ context 'Checking for deprecation warning' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params(50).and_return(true)
+ end
+ it 'should display no warning for deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+ scope.expects(:warning).with(includes('This method is deprecated')).never
+ is_expected.to run.with_params(50).and_return(true)
+ end
+ end
+
end
diff --git a/spec/functions/is_ip_address_spec.rb b/spec/functions/is_ip_address_spec.rb
index 9386ca9..fc8af60 100755
--- a/spec/functions/is_ip_address_spec.rb
+++ b/spec/functions/is_ip_address_spec.rb
@@ -20,9 +20,21 @@ describe 'is_ip_address' do
it { is_expected.to run.with_params(1).and_return(false) }
it { is_expected.to run.with_params({}).and_return(false) }
it { is_expected.to run.with_params([]).and_return(false) }
- # Checking for deprecation warning
- it 'should display a single deprecation' do
- scope.expects(:warning).with(includes('This method is deprecated'))
- is_expected.to run.with_params('1.1.1.1')
+
+ context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
+ # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params('1.2.3.4').and_return(true)
+ end
+ it 'should display no warning for deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+ scope.expects(:warning).with(includes('This method is deprecated')).never
+ is_expected.to run.with_params('1.2.3.4').and_return(true)
+ end
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
end
end
diff --git a/spec/functions/is_ipv4_address_spec.rb b/spec/functions/is_ipv4_address_spec.rb
index 2b9fc49..9d53a9d 100644
--- a/spec/functions/is_ipv4_address_spec.rb
+++ b/spec/functions/is_ipv4_address_spec.rb
@@ -1,6 +1,7 @@
require 'spec_helper'
describe 'is_ipv4_address' 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 { is_expected.to run.with_params('1.2.3.4').and_return(true) }
@@ -9,9 +10,21 @@ describe 'is_ipv4_address' do
it { is_expected.to run.with_params('1.2.3.4.5').and_return(false) }
it { is_expected.to run.with_params('').and_return(false) }
it { is_expected.to run.with_params('one').and_return(false) }
- # Checking for deprecation warning
- it 'should display a single deprecation' do
- scope.expects(:warning).with(includes('This method is deprecated'))
- is_expected.to run.with_params('1.1.1.1')
+
+ context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params('1.2.3.4').and_return(true)
+ end
+ it 'should display no warning for deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+ scope.expects(:warning).with(includes('This method is deprecated')).never
+ is_expected.to run.with_params('1.2.3.4').and_return(true)
+ end
end
end
diff --git a/spec/functions/is_ipv6_address_spec.rb b/spec/functions/is_ipv6_address_spec.rb
index e3e4734..4449fea 100644
--- a/spec/functions/is_ipv6_address_spec.rb
+++ b/spec/functions/is_ipv6_address_spec.rb
@@ -1,6 +1,7 @@
require 'spec_helper'
describe 'is_ipv6_address' 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 { is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true) }
@@ -9,9 +10,21 @@ describe 'is_ipv6_address' do
it { is_expected.to run.with_params('1.2.3.4.5').and_return(false) }
it { is_expected.to run.with_params('').and_return(false) }
it { is_expected.to run.with_params('one').and_return(false) }
- # Checking for deprecation warning
- it 'should display a single deprecation' do
- scope.expects(:warning).with(includes('This method is deprecated'))
- is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334')
+
+ context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true)
+ end
+ it 'should display no warning for deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+ scope.expects(:warning).with(includes('This method is deprecated')).never
+ is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true)
+ end
end
end
diff --git a/spec/functions/is_numeric_spec.rb b/spec/functions/is_numeric_spec.rb
index f4ead56..ccfb9d8 100755
--- a/spec/functions/is_numeric_spec.rb
+++ b/spec/functions/is_numeric_spec.rb
@@ -1,14 +1,9 @@
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(:warning).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) }
@@ -32,4 +27,22 @@ describe 'is_numeric' do
it { is_expected.to run.with_params(false).and_return(false) }
it { is_expected.to run.with_params('0001234').and_return(false) }
it { is_expected.to run.with_params(' - 1234').and_return(false) }
+
+ context 'Checking for deprecation warning' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params(7).and_return(true)
+ end
+ it 'should display no warning for deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+ scope.expects(:warning).with(includes('This method is deprecated')).never
+ is_expected.to run.with_params(7).and_return(true)
+ end
+ end
+
end
diff --git a/spec/functions/is_string_spec.rb b/spec/functions/is_string_spec.rb
index 4f59b63..460d6e0 100755
--- a/spec/functions/is_string_spec.rb
+++ b/spec/functions/is_string_spec.rb
@@ -1,12 +1,8 @@
require 'spec_helper'
describe 'is_string' do
+
it { is_expected.not_to eq(nil) }
- # Checking for deprecation warning
- it 'should display a single deprecation' do
- scope.expects(:warning).with(includes('This method is deprecated'))
- is_expected.to run.with_params('ha')
- end
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
it {
pending("Current implementation ignores parameters after the first.")
@@ -30,4 +26,22 @@ describe 'is_string' do
it { is_expected.to run.with_params(false).and_return(false) }
it { is_expected.to run.with_params('one').and_return(true) }
it { is_expected.to run.with_params('0001234').and_return(true) }
+
+ context 'Checking for deprecation warning' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params('sponge').and_return(true)
+ end
+ it 'should display no warning for deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+ scope.expects(:warning).with(includes('This method is deprecated')).never
+ is_expected.to run.with_params('bob').and_return(true)
+ end
+ end
+
end
diff --git a/spec/functions/validate_absolute_path_spec.rb b/spec/functions/validate_absolute_path_spec.rb
index dbac88f..75df6bc 100755
--- a/spec/functions/validate_absolute_path_spec.rb
+++ b/spec/functions/validate_absolute_path_spec.rb
@@ -1,9 +1,14 @@
require 'spec_helper'
describe 'validate_absolute_path' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+
# Checking for deprecation warning
it 'should display a single deprecation' do
# called twice because validate_absolute_path calls is_absolute_path
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
scope.expects(:warning).with(includes('This method is deprecated')).twice
is_expected.to run.with_params('c:/')
end
diff --git a/spec/functions/validate_array_spec.rb b/spec/functions/validate_array_spec.rb
index 9f2e210..f395d16 100755
--- a/spec/functions/validate_array_spec.rb
+++ b/spec/functions/validate_array_spec.rb
@@ -1,10 +1,15 @@
require 'spec_helper'
describe 'validate_array' do
+
describe 'signature validation' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
it { is_expected.not_to eq(nil) }
# Checking for deprecation warning
it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
scope.expects(:warning).with(includes('This method is deprecated'))
is_expected.to run.with_params([])
end
diff --git a/spec/functions/validate_bool_spec.rb b/spec/functions/validate_bool_spec.rb
index 724e31f..4bd1453 100755
--- a/spec/functions/validate_bool_spec.rb
+++ b/spec/functions/validate_bool_spec.rb
@@ -1,9 +1,14 @@
require 'spec_helper'
describe 'validate_bool' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+
# Checking for deprecation warning
it 'should display a single deprecation' do
#called twice, because validate_bool calls is_bool
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
scope.expects(:warning).with(includes('This method is deprecated')).twice
is_expected.to run.with_params(true)
end
diff --git a/spec/functions/validate_integer_spec.rb b/spec/functions/validate_integer_spec.rb
index 3ca50b2..ffc59f8 100755
--- a/spec/functions/validate_integer_spec.rb
+++ b/spec/functions/validate_integer_spec.rb
@@ -1,8 +1,13 @@
require 'spec_helper'
describe 'validate_integer' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+
# Checking for deprecation warning
it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
scope.expects(:warning).with(includes('This method is deprecated'))
is_expected.to run.with_params(3)
end
diff --git a/spec/functions/validate_ip_address_spec.rb b/spec/functions/validate_ip_address_spec.rb
index 10f6c37..7040a8d 100644
--- a/spec/functions/validate_ip_address_spec.rb
+++ b/spec/functions/validate_ip_address_spec.rb
@@ -1,6 +1,7 @@
require 'spec_helper'
describe 'validate_ip_address' do
+
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) }
@@ -19,10 +20,24 @@ describe 'validate_ip_address' do
it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') }
it { is_expected.to run.with_params('::1/64') }
it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') }
- it 'should display a single deprecation' do
- scope.expects(:warning).with(includes('This method is deprecated'))
- is_expected.to run.with_params('1.1.1.1')
+
+ context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params('1.2.3.4')
+ end
+ it 'should display no warning for deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+ scope.expects(:warning).with(includes('This method is deprecated')).never
+ is_expected.to run.with_params('1.2.3.4')
+ end
end
+
context 'with netmasks' do
it { is_expected.to run.with_params('8.8.8.8/0') }
it { is_expected.to run.with_params('8.8.8.8/16') }
diff --git a/spec/functions/validate_ipv4_address_spec.rb b/spec/functions/validate_ipv4_address_spec.rb
index b67bf6f..b60dc8e 100755
--- a/spec/functions/validate_ipv4_address_spec.rb
+++ b/spec/functions/validate_ipv4_address_spec.rb
@@ -1,45 +1,58 @@
require 'spec_helper'
describe 'validate_ipv4_address' do
+
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) }
+ end
+ context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
scope.expects(:warning).with(includes('This method is deprecated'))
- is_expected.to run.with_params('1.1.1.1')
+ is_expected.to run.with_params('1.2.3.4')
end
-
- describe 'valid inputs' do
- it { is_expected.to run.with_params('0.0.0.0') }
- it { is_expected.to run.with_params('8.8.8.8') }
- it { is_expected.to run.with_params('127.0.0.1') }
- it { is_expected.to run.with_params('10.10.10.10') }
- it { is_expected.to run.with_params('194.232.104.150') }
- it { is_expected.to run.with_params('244.24.24.24') }
- it { is_expected.to run.with_params('255.255.255.255') }
- it { is_expected.to run.with_params('1.2.3.4', '5.6.7.8') }
- context 'with netmasks' do
- it { is_expected.to run.with_params('8.8.8.8/0') }
- it { is_expected.to run.with_params('8.8.8.8/16') }
- it { is_expected.to run.with_params('8.8.8.8/32') }
- it { is_expected.to run.with_params('8.8.8.8/255.255.0.0') }
- end
+ it 'should display no warning for deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+ scope.expects(:warning).with(includes('This method is deprecated')).never
+ is_expected.to run.with_params('1.2.3.4')
end
+ end
- describe 'invalid inputs' do
- it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
- it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
- it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
- it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
- it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
- it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
- it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
- it { is_expected.to run.with_params('affe::beef').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
- it { is_expected.to run.with_params('1.2.3.4', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
- it { is_expected.to run.with_params('1.2.3.4', 1).and_raise_error(Puppet::ParseError, /is not a string/) }
- it { is_expected.to run.with_params('1.2.3.4', true).and_raise_error(Puppet::ParseError, /is not a string/) }
- it { is_expected.to run.with_params('1.2.3.4', 'one').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+ describe 'valid inputs' do
+ it { is_expected.to run.with_params('0.0.0.0') }
+ it { is_expected.to run.with_params('8.8.8.8') }
+ it { is_expected.to run.with_params('127.0.0.1') }
+ it { is_expected.to run.with_params('10.10.10.10') }
+ it { is_expected.to run.with_params('194.232.104.150') }
+ it { is_expected.to run.with_params('244.24.24.24') }
+ it { is_expected.to run.with_params('255.255.255.255') }
+ it { is_expected.to run.with_params('1.2.3.4', '5.6.7.8') }
+ context 'with netmasks' do
+ it { is_expected.to run.with_params('8.8.8.8/0') }
+ it { is_expected.to run.with_params('8.8.8.8/16') }
+ it { is_expected.to run.with_params('8.8.8.8/32') }
+ it { is_expected.to run.with_params('8.8.8.8/255.255.0.0') }
end
end
+
+ describe 'invalid inputs' do
+ it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
+ it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
+ it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
+ it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+ it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+ it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+ it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+ it { is_expected.to run.with_params('affe::beef').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+ it { is_expected.to run.with_params('1.2.3.4', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
+ it { is_expected.to run.with_params('1.2.3.4', 1).and_raise_error(Puppet::ParseError, /is not a string/) }
+ it { is_expected.to run.with_params('1.2.3.4', true).and_raise_error(Puppet::ParseError, /is not a string/) }
+ it { is_expected.to run.with_params('1.2.3.4', 'one').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+ end
end
diff --git a/spec/functions/validate_ipv6_address_spec.rb b/spec/functions/validate_ipv6_address_spec.rb
index 3afab56..87b535e 100755
--- a/spec/functions/validate_ipv6_address_spec.rb
+++ b/spec/functions/validate_ipv6_address_spec.rb
@@ -1,36 +1,50 @@
require 'spec_helper'
describe 'validate_ipv6_address' do
+
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) }
+ end
- describe 'valid inputs' do
- it { is_expected.to run.with_params('3ffe:0505:0002::') }
- it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') }
- it { is_expected.to run.with_params('::1/64') }
- it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') }
- it 'should display a single deprecation' do
- scope.expects(:warning).with(includes('This method is deprecated'))
- is_expected.to run.with_params('3ffe:0505:0002::')
- end
+ context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params('3ffe:0505:0002::')
+ end
+ it 'should display no warning for deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+ scope.expects(:warning).with(includes('This method is deprecated')).never
+ is_expected.to run.with_params('3ffe:0505:0002::')
end
+ end
+
+ describe 'valid inputs' do
+ it { is_expected.to run.with_params('3ffe:0505:0002::') }
+ it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') }
+ it { is_expected.to run.with_params('::1/64') }
+ it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') }
+ end
- describe 'invalid inputs' do
- it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
- it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
- it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
- it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
- it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
- it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
- it { is_expected.to run.with_params('affe:beef').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
- it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
- it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, /is not a string/) }
- it { is_expected.to run.with_params('::1', 'one').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
- context 'unless running on ruby 1.8.7', :if => RUBY_VERSION != '1.8.7' do
- it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
- it { is_expected.to run.with_params('::1', 1).and_raise_error(Puppet::ParseError, /is not a string/) }
- end
+ describe 'invalid inputs' do
+ it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
+ it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
+ it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+ it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+ it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+ it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+ it { is_expected.to run.with_params('affe:beef').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+ it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
+ it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, /is not a string/) }
+ it { is_expected.to run.with_params('::1', 'one').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+ context 'unless running on ruby 1.8.7', :if => RUBY_VERSION != '1.8.7' do
+ it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
+ it { is_expected.to run.with_params('::1', 1).and_raise_error(Puppet::ParseError, /is not a string/) }
end
end
end
diff --git a/spec/functions/validate_legacy_spec.rb b/spec/functions/validate_legacy_spec.rb
new file mode 100644
index 0000000..45089ef
--- /dev/null
+++ b/spec/functions/validate_legacy_spec.rb
@@ -0,0 +1,68 @@
+require 'spec_helper'
+
+if Puppet.version.to_f >= 4.0
+ describe 'validate_legacy' do
+ it { is_expected.not_to eq(nil) }
+ it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
+
+ describe 'when passing the type assertion and passing the previous validation' do
+ before do
+ scope.expects(:function_validate_foo).with([5]).once
+ Puppet.expects(:notice).never
+ end
+ it 'passes without notice' do
+ is_expected.to run.with_params('Integer', 'validate_foo', 5)
+ end
+ end
+
+ describe 'when passing the type assertion and failing the previous validation' do
+ before do
+ scope.expects(:function_validate_foo).with([5]).raises(Puppet::ParseError, 'foo').once
+ Puppet.expects(:notice).with(includes('Accepting previously invalid value for target type'))
+ end
+ it 'passes with a notice about newly accepted value' do
+ is_expected.to run.with_params('Integer', 'validate_foo', 5)
+ end
+ end
+
+ describe 'when failing the type assertion and passing the previous validation' do
+ before do
+ scope.expects(:function_validate_foo).with(['5']).once
+ subject.func.expects(:call_function).with('deprecation', 'validate_legacy', includes('expected an Integer value')).once
+ end
+ it 'passes with a deprecation message' do
+ is_expected.to run.with_params('Integer', 'validate_foo', '5')
+ end
+ end
+
+ describe 'when failing the type assertion and failing the previous validation' do
+ before do
+ scope.expects(:function_validate_foo).with(['5']).raises(Puppet::ParseError, 'foo').once
+ subject.func.expects(:call_function).with('fail', includes('expected an Integer value')).once
+ end
+ it 'fails with a helpful message' do
+ is_expected.to run.with_params('Integer', 'validate_foo', '5')
+ end
+ end
+
+ describe 'when passing in undef' do
+ before do
+ scope.expects(:function_validate_foo).with([:undef]).once
+ Puppet.expects(:notice).never
+ end
+ it 'works' do
+ is_expected.to run.with_params('Optional[Integer]', 'validate_foo', :undef)
+ end
+ end
+
+ describe 'when passing in multiple arguments' do
+ before do
+ scope.expects(:function_validate_foo).with([:undef, 1, 'foo']).once
+ Puppet.expects(:notice).never
+ end
+ it 'passes with a deprecation message' do
+ is_expected.to run.with_params('Optional[Integer]', 'validate_foo', :undef, 1, 'foo')
+ end
+ end
+ end
+end
diff --git a/spec/functions/validate_numeric_spec.rb b/spec/functions/validate_numeric_spec.rb
index 2869e5f..4a65649 100755
--- a/spec/functions/validate_numeric_spec.rb
+++ b/spec/functions/validate_numeric_spec.rb
@@ -1,8 +1,13 @@
require 'spec_helper'
describe 'validate_numeric' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+
# Checking for deprecation warning
it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
scope.expects(:warning).with(includes('This method is deprecated'))
is_expected.to run.with_params(3)
end
diff --git a/spec/functions/validate_re_spec.rb b/spec/functions/validate_re_spec.rb
index 4b78a2e..2fa9ddd 100755
--- a/spec/functions/validate_re_spec.rb
+++ b/spec/functions/validate_re_spec.rb
@@ -1,8 +1,13 @@
require 'spec_helper'
describe 'validate_re' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+
# Checking for deprecation warning
it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
scope.expects(:warning).with(includes('This method is deprecated'))
is_expected.to run.with_params('', '')
end
@@ -23,22 +28,6 @@ describe 'validate_re' do
end
describe 'invalid inputs' do
- it {
- pending('should implement stricter type checking')
- is_expected.to run.with_params([], '').and_raise_error(Puppet::ParseError, /is not a String/)
- }
- it {
- pending('should implement stricter type checking')
- is_expected.to run.with_params('', {}).and_raise_error(Puppet::ParseError, /is not an Array/)
- }
- it {
- pending('should implement stricter type checking')
- is_expected.to run.with_params('', '', []).and_raise_error(Puppet::ParseError, /is not a String/)
- }
- it {
- pending('should implement stricter type checking')
- is_expected.to run.with_params(nil, nil).and_raise_error(Puppet::ParseError, /is not a String/)
- }
it { is_expected.to run.with_params('', []).and_raise_error(Puppet::ParseError, /does not match/) }
it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /does not match/) }
it { is_expected.to run.with_params('', 'two').and_raise_error(Puppet::ParseError, /does not match/) }
diff --git a/spec/functions/validate_string_spec.rb b/spec/functions/validate_string_spec.rb
index ef7a1b4..45d6ffc 100755
--- a/spec/functions/validate_string_spec.rb
+++ b/spec/functions/validate_string_spec.rb
@@ -1,8 +1,13 @@
require 'spec_helper'
describe 'validate_string' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+
# Checking for deprecation warning
it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
scope.expects(:warning).with(includes('This method is deprecated'))
is_expected.to run.with_params('', '')
end