3 describe 'validate_ipv4_address' do
5 describe 'signature validation' do
6 it { is_expected.not_to eq(nil) }
7 it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
10 context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
12 ENV.delete('STDLIB_LOG_DEPRECATIONS')
14 # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
15 it 'should display a single deprecation' do
16 ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
17 scope.expects(:warning).with(includes('This method is deprecated'))
18 is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first)
20 it 'should display no warning for deprecation' do
21 ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
22 scope.expects(:warning).with(includes('This method is deprecated')).never
23 is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first)
27 SharedData::IPV4_PATTERNS.each do |value|
28 it { is_expected.to run.with_params(value) }
31 SharedData::IPV4_NEGATIVE_PATTERNS.each do |value|
32 it { is_expected.to run.with_params(value).and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
35 describe 'invalid inputs' do
36 [ {}, [], 1, true ].each do |invalid|
37 it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, /is not a string/) }
38 it { is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first, invalid).and_raise_error(Puppet::ParseError, /is not a string/) }