Update stdlib
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / is_ipv6_address_spec.rb
1 require 'spec_helper'
2
3 describe 'is_ipv6_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   it { is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true) }
8   it { is_expected.to run.with_params('85a3:0000:0000:8a2e:0370:7334:100.100.100.100').and_return(true) }
9   it { is_expected.to run.with_params('1.2.3').and_return(false) }
10   it { is_expected.to run.with_params('1.2.3.4.5').and_return(false) }
11   it { is_expected.to run.with_params('').and_return(false) }
12   it { is_expected.to run.with_params('one').and_return(false) }
13
14   context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
15     after(:all) do
16       ENV.delete('STDLIB_LOG_DEPRECATIONS')
17     end
18     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
19     it 'should display a single deprecation' do
20       ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
21       scope.expects(:warning).with(includes('This method is deprecated'))
22       is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true)
23     end
24     it 'should display no warning for deprecation' do
25       ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
26       scope.expects(:warning).with(includes('This method is deprecated')).never
27       is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true)
28     end
29   end
30 end