3 describe 'validate_ipv4_address' do
4 describe 'signature validation' do
5 it { is_expected.not_to eq(nil) }
6 it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
9 context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do
11 ENV.delete('STDLIB_LOG_DEPRECATIONS')
13 # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
14 it 'displays a single deprecation' do
15 ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
16 expect(scope).to receive(:warning).with(include('This method is deprecated'))
17 is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first)
19 it 'displays no warning for deprecation' do
20 ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
21 expect(scope).to receive(:warning).with(include('This method is deprecated')).never
22 is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first)
26 SharedData::IPV4_PATTERNS.each do |value|
27 it { is_expected.to run.with_params(value) }
30 SharedData::IPV4_NEGATIVE_PATTERNS.each do |value|
31 it { is_expected.to run.with_params(value).and_raise_error(Puppet::ParseError, %r{is not a valid IPv4}) }
34 describe 'invalid inputs' do
35 [{}, [], 1, true].each do |invalid|
36 it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, %r{is not a string}) }
37 it { is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first, invalid).and_raise_error(Puppet::ParseError, %r{is not a string}) }