3 if Puppet::Util::Package.versioncmp(Puppet.version, '4.4.0') >= 0
4 describe 'validate_legacy' do
5 it { is_expected.not_to eq(nil) }
6 it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
8 describe 'when passing the type assertion and passing the previous validation' do
9 it 'passes without notice' do
10 expect(scope).to receive(:function_validate_foo).with([5]).once
11 expect(Puppet).to receive(:notice).never
12 is_expected.to run.with_params('Integer', 'validate_foo', 5)
16 describe 'when passing the type assertion and failing the previous validation' do
17 it 'passes with a notice about newly accepted value' do
18 expect(scope).to receive(:function_validate_foo).with([5]).and_raise(Puppet::ParseError, 'foo').once
19 expect(Puppet).to receive(:notice).with(include('Accepting previously invalid value for target type'))
20 is_expected.to run.with_params('Integer', 'validate_foo', 5)
24 describe 'when failing the type assertion and passing the previous validation' do
25 it 'passes with a deprecation message' do
26 expect(scope).to receive(:function_validate_foo).with(['5']).once
27 expect(subject.func).to receive(:call_function).with('deprecation', 'validate_legacy', include('Integer')).once
28 is_expected.to run.with_params('Integer', 'validate_foo', '5')
32 describe 'when failing the type assertion and failing the previous validation' do
33 it 'fails with a helpful message' do
34 expect(scope).to receive(:function_validate_foo).with(['5']).and_raise(Puppet::ParseError, 'foo').once
35 expect(subject.func).to receive(:call_function).with('fail', include('Integer')).once
36 is_expected.to run.with_params('Integer', 'validate_foo', '5')
40 describe 'when passing in undef' do
42 expect(scope).to receive(:function_validate_foo).with([:undef]).once
43 expect(Puppet).to receive(:notice).never
44 is_expected.to run.with_params('Optional[Integer]', 'validate_foo', :undef)
48 describe 'when passing in multiple arguments' do
49 it 'passes with a deprecation message' do
50 expect(scope).to receive(:function_validate_foo).with([:undef, 1, 'foo']).once
51 expect(Puppet).to receive(:notice).never
52 is_expected.to run.with_params('Optional[Integer]', 'validate_foo', :undef, 1, 'foo')