Update stdlib
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / is_ipv4_address_spec.rb
1 require 'spec_helper'
2
3 describe 'is_ipv4_address' do
4
5   it { is_expected.not_to eq(nil) }
6   it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
7
8   SharedData::IPV4_PATTERNS.each do |value|
9     it { is_expected.to run.with_params(value).and_return(true) }
10   end
11
12   SharedData::IPV4_NEGATIVE_PATTERNS.each do |value|
13     it { is_expected.to run.with_params(value).and_return(false) }
14   end
15
16   context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
17     after(:all) do
18       ENV.delete('STDLIB_LOG_DEPRECATIONS')
19     end
20     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
21     it 'should display a single deprecation' do
22       ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
23       scope.expects(:warning).with(includes('This method is deprecated'))
24       is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first).and_return(true)
25     end
26     it 'should display no warning for deprecation' do
27       ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
28       scope.expects(:warning).with(includes('This method is deprecated')).never
29       is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first).and_return(true)
30     end
31   end
32 end