diff options
author | Helen Campbell <helen@puppetlabs.com> | 2016-08-16 11:55:05 +0100 |
---|---|---|
committer | Helen Campbell <helen@puppetlabs.com> | 2016-08-17 13:49:42 +0100 |
commit | 6d185bdaa19f698270a0df4b0a0c05618864b955 (patch) | |
tree | 2d005f4664838214a4e3284e73a2060453a1216c /spec/functions | |
parent | 1d9d2c02d6669d4a6219140ae7ff3648a30c89cf (diff) |
Deprecation of ip functions
Diffstat (limited to 'spec/functions')
-rwxr-xr-x | spec/functions/is_ip_address_spec.rb | 5 | ||||
-rw-r--r-- | spec/functions/is_ipv4_address_spec.rb | 17 | ||||
-rw-r--r-- | spec/functions/is_ipv6_address_spec.rb | 17 | ||||
-rw-r--r-- | spec/functions/validate_ip_address_spec.rb | 4 | ||||
-rwxr-xr-x | spec/functions/validate_ipv4_address_spec.rb | 5 | ||||
-rwxr-xr-x | spec/functions/validate_ipv6_address_spec.rb | 4 |
6 files changed, 52 insertions, 0 deletions
diff --git a/spec/functions/is_ip_address_spec.rb b/spec/functions/is_ip_address_spec.rb index a7a383a..9386ca9 100755 --- a/spec/functions/is_ip_address_spec.rb +++ b/spec/functions/is_ip_address_spec.rb @@ -20,4 +20,9 @@ describe 'is_ip_address' do it { is_expected.to run.with_params(1).and_return(false) } it { is_expected.to run.with_params({}).and_return(false) } it { is_expected.to run.with_params([]).and_return(false) } + # Checking for deprecation warning + it 'should display a single deprecation' do + scope.expects(:warning).with(includes('This method is deprecated')) + is_expected.to run.with_params('1.1.1.1') + end end diff --git a/spec/functions/is_ipv4_address_spec.rb b/spec/functions/is_ipv4_address_spec.rb new file mode 100644 index 0000000..2b9fc49 --- /dev/null +++ b/spec/functions/is_ipv4_address_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'is_ipv4_address' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it { is_expected.to run.with_params('1.2.3.4').and_return(true) } + it { is_expected.to run.with_params('1.2.3.255').and_return(true) } + it { is_expected.to run.with_params('1.2.3').and_return(false) } + it { is_expected.to run.with_params('1.2.3.4.5').and_return(false) } + it { is_expected.to run.with_params('').and_return(false) } + it { is_expected.to run.with_params('one').and_return(false) } + # Checking for deprecation warning + it 'should display a single deprecation' do + scope.expects(:warning).with(includes('This method is deprecated')) + is_expected.to run.with_params('1.1.1.1') + end +end diff --git a/spec/functions/is_ipv6_address_spec.rb b/spec/functions/is_ipv6_address_spec.rb new file mode 100644 index 0000000..e3e4734 --- /dev/null +++ b/spec/functions/is_ipv6_address_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'is_ipv6_address' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it { is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true) } + it { is_expected.to run.with_params('85a3:0000:0000:8a2e:0370:7334:100.100.100.100').and_return(true) } + it { is_expected.to run.with_params('1.2.3').and_return(false) } + it { is_expected.to run.with_params('1.2.3.4.5').and_return(false) } + it { is_expected.to run.with_params('').and_return(false) } + it { is_expected.to run.with_params('one').and_return(false) } + # Checking for deprecation warning + it 'should display a single deprecation' do + scope.expects(:warning).with(includes('This method is deprecated')) + is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334') + end +end diff --git a/spec/functions/validate_ip_address_spec.rb b/spec/functions/validate_ip_address_spec.rb index b56ce51..10f6c37 100644 --- a/spec/functions/validate_ip_address_spec.rb +++ b/spec/functions/validate_ip_address_spec.rb @@ -19,6 +19,10 @@ describe 'validate_ip_address' do it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') } it { is_expected.to run.with_params('::1/64') } it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') } + it 'should display a single deprecation' do + scope.expects(:warning).with(includes('This method is deprecated')) + is_expected.to run.with_params('1.1.1.1') + end context 'with netmasks' do it { is_expected.to run.with_params('8.8.8.8/0') } it { is_expected.to run.with_params('8.8.8.8/16') } diff --git a/spec/functions/validate_ipv4_address_spec.rb b/spec/functions/validate_ipv4_address_spec.rb index b6170d4..b67bf6f 100755 --- a/spec/functions/validate_ipv4_address_spec.rb +++ b/spec/functions/validate_ipv4_address_spec.rb @@ -5,6 +5,11 @@ describe 'validate_ipv4_address' do it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it 'should display a single deprecation' do + scope.expects(:warning).with(includes('This method is deprecated')) + is_expected.to run.with_params('1.1.1.1') + end + describe 'valid inputs' do it { is_expected.to run.with_params('0.0.0.0') } it { is_expected.to run.with_params('8.8.8.8') } diff --git a/spec/functions/validate_ipv6_address_spec.rb b/spec/functions/validate_ipv6_address_spec.rb index 7aaf006..3afab56 100755 --- a/spec/functions/validate_ipv6_address_spec.rb +++ b/spec/functions/validate_ipv6_address_spec.rb @@ -10,6 +10,10 @@ describe 'validate_ipv6_address' do it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') } it { is_expected.to run.with_params('::1/64') } it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') } + it 'should display a single deprecation' do + scope.expects(:warning).with(includes('This method is deprecated')) + is_expected.to run.with_params('3ffe:0505:0002::') + end end describe 'invalid inputs' do |