X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Ffunctions%2Fip_in_range_spec.rb;fp=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Ffunctions%2Fip_in_range_spec.rb;h=01d800ce6c2f801160edb2c36c615bcc2c41b715;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hp=0000000000000000000000000000000000000000;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/spec/functions/ip_in_range_spec.rb b/3rdparty/modules/stdlib/spec/functions/ip_in_range_spec.rb new file mode 100644 index 000000000..01d800ce6 --- /dev/null +++ b/3rdparty/modules/stdlib/spec/functions/ip_in_range_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'stdlib::ip_in_range' do + describe 'signature validation' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{'stdlib::ip_in_range' expects 2 arguments, got none}) } + it { is_expected.to run.with_params('one', 'two', '3').and_raise_error(ArgumentError, %r{'stdlib::ip_in_range' expects 2 arguments, got 3}) } + it { is_expected.to run.with_params([], []).and_raise_error(ArgumentError, %r{'stdlib::ip_in_range' parameter 'ipaddress' expects a String value, got Array}) } + it { is_expected.to run.with_params('1.1.1.1', 7).and_raise_error(ArgumentError, %r{'stdlib::ip_in_range' parameter 'range' expects a value of type String or Array, got Integer}) } + end + + describe 'basic validation inputs' do + it { is_expected.to run.with_params('192.168.100.12', '192.168.100.0/24').and_return(true) } + it { is_expected.to run.with_params('192.168.100.12', ['10.10.10.10/24', '192.168.100.0/24']).and_return(true) } + it { is_expected.to run.with_params('10.10.10.10', '192.168.100.0/24').and_return(false) } + end +end