3 describe 'validate_re' do
5 ENV.delete('STDLIB_LOG_DEPRECATIONS')
8 # Checking for deprecation warning
9 it 'should display a single deprecation' do
10 ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
11 scope.expects(:warning).with(includes('This method is deprecated'))
12 is_expected.to run.with_params('', '')
15 describe 'signature validation' do
16 it { is_expected.not_to eq(nil) }
17 it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
18 it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
19 it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
21 describe 'valid inputs' do
22 it { is_expected.to run.with_params('', '') }
23 it { is_expected.to run.with_params('', ['']) }
24 it { is_expected.to run.with_params('', [''], 'custom error') }
25 it { is_expected.to run.with_params('one', '^one') }
26 it { is_expected.to run.with_params('one', [ '^one', '^two' ]) }
27 it { is_expected.to run.with_params('one', [ '^one', '^two' ], 'custom error') }
30 describe 'invalid inputs' do
31 it { is_expected.to run.with_params('', []).and_raise_error(Puppet::ParseError, /does not match/) }
32 it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /does not match/) }
33 it { is_expected.to run.with_params('', 'two').and_raise_error(Puppet::ParseError, /does not match/) }
34 it { is_expected.to run.with_params('', ['two']).and_raise_error(Puppet::ParseError, /does not match/) }
35 it { is_expected.to run.with_params('', ['two'], 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
36 it { is_expected.to run.with_params('notone', '^one').and_raise_error(Puppet::ParseError, /does not match/) }
37 it { is_expected.to run.with_params('notone', [ '^one', '^two' ]).and_raise_error(Puppet::ParseError, /does not match/) }
38 it { is_expected.to run.with_params('notone', [ '^one', '^two' ], 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
40 describe 'non-string inputs' do
51 it { is_expected.to run.with_params(input, '.*').and_raise_error(Puppet::ParseError, /needs to be a String/) }