|
7 | 7 | it { is_expected.not_to eq(nil) }
|
8 | 8 | it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
|
9 | 9 |
|
10 |
| - describe 'when passing the type assertion and passing the previous validation' do |
11 |
| - it 'passes without notice' do |
12 |
| - expect(scope).to receive(:function_validate_foo).with([5]).once |
| 10 | + describe 'when passing the type assertion' do |
| 11 | + it 'passes with a deprecation warning' do |
| 12 | + expect(subject.func).to receive(:call_function).with('deprecation', 'validate_legacy', include('deprecated')).once |
| 13 | + expect(scope).to receive(:function_validate_foo).never |
13 | 14 | expect(Puppet).to receive(:notice).never
|
14 | 15 | is_expected.to run.with_params('Integer', 'validate_foo', 5)
|
15 | 16 | end
|
16 | 17 | end
|
17 | 18 |
|
18 |
| - describe 'when passing the type assertion and failing the previous validation' do |
19 |
| - it 'passes with a notice about newly accepted value' do |
20 |
| - expect(scope).to receive(:function_validate_foo).with([5]).and_raise(Puppet::ParseError, 'foo').once |
21 |
| - expect(Puppet).to receive(:notice).with(include('Accepting previously invalid value for target type')) |
22 |
| - is_expected.to run.with_params('Integer', 'validate_foo', 5) |
23 |
| - end |
24 |
| - end |
25 |
| - |
26 |
| - describe 'when failing the type assertion and passing the previous validation' do |
27 |
| - it 'passes with a deprecation message' do |
28 |
| - expect(scope).to receive(:function_validate_foo).with(['5']).once |
29 |
| - expect(subject.func).to receive(:call_function).with('deprecation', 'validate_legacy', include('Integer')).once |
30 |
| - is_expected.to run.with_params('Integer', 'validate_foo', '5') |
31 |
| - end |
32 |
| - end |
33 |
| - |
34 |
| - describe 'when failing the type assertion and failing the previous validation' do |
| 19 | + describe 'when failing the type assertion' do |
35 | 20 | it 'fails with a helpful message' do
|
36 |
| - expect(scope).to receive(:function_validate_foo).with(['5']).and_raise(Puppet::ParseError, 'foo').once |
37 |
| - expect(subject.func).to receive(:call_function).with('fail', include('Integer')).once |
| 21 | + expect(subject.func).to receive(:call_function).with('deprecation', 'validate_legacy', include('deprecated')).once |
| 22 | + expect(scope).to receive(:function_validate_foo).never |
| 23 | + expect(subject.func).to receive(:call_function).with('fail', 'validate_legacy(Integer, ...) expects an Integer value, got String').once |
38 | 24 | is_expected.to run.with_params('Integer', 'validate_foo', '5')
|
39 | 25 | end
|
40 | 26 | end
|
41 | 27 |
|
42 | 28 | describe 'when passing in undef' do
|
43 | 29 | it 'works' do
|
44 |
| - expect(scope).to receive(:function_validate_foo).with([:undef]).once |
| 30 | + expect(subject.func).to receive(:call_function).with('deprecation', 'validate_legacy', include('deprecated')).once |
| 31 | + expect(scope).to receive(:function_validate_foo).never |
45 | 32 | expect(Puppet).to receive(:notice).never
|
46 | 33 | is_expected.to run.with_params('Optional[Integer]', 'validate_foo', :undef)
|
47 | 34 | end
|
48 | 35 | end
|
49 | 36 |
|
50 | 37 | describe 'when passing in multiple arguments' do
|
51 | 38 | it 'passes with a deprecation message' do
|
52 |
| - expect(scope).to receive(:function_validate_foo).with([:undef, 1, 'foo']).once |
| 39 | + expect(subject.func).to receive(:call_function).with('deprecation', 'validate_legacy', include('deprecated')).once |
| 40 | + expect(scope).to receive(:function_validate_foo).never |
53 | 41 | expect(Puppet).to receive(:notice).never
|
54 | 42 | is_expected.to run.with_params('Optional[Integer]', 'validate_foo', :undef, 1, 'foo')
|
55 | 43 | end
|
|
0 commit comments