summaryrefslogtreecommitdiff
path: root/spec/classes
diff options
context:
space:
mode:
authorDavid Schmitt <david.schmitt@puppet.com>2016-09-06 11:18:48 +0100
committerDavid Schmitt <david.schmitt@puppet.com>2016-09-07 16:37:57 +0100
commitf1edd2715a755573d7578839a3efe8473b79b5c5 (patch)
treee223708e8404e6e52d4c2fafef3322bfea7f2ee7 /spec/classes
parent2b56ebd3e16112f8260519af0cd65a3d17fbfaeb (diff)
(MODULES-3737) validate_legacy: refactoring
* validate_legacy now accepts undef values * update the TypeMismatch message to include the original validate function name * only notice, not warn, on newly allowed values * changed previous_validation to function_name to avoid confusion with the function of the same name * use deprecation() instead of warn(), when hitting a deprecated value * prepare the tests and function for MODULES-3735 * rewrite validate_legacy tests to use new rspec-puppet * move validate_re deprecation to puppet4 only * adapt validate_re_spec
Diffstat (limited to 'spec/classes')
-rw-r--r--spec/classes/validate_legacy_spec.rb39
1 files changed, 0 insertions, 39 deletions
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