|
15 | 15 | it 'should display a single deprecation' do |
16 | 16 | ENV['STDLIB_LOG_DEPRECATIONS'] = "true" |
17 | 17 | scope.expects(:warning).with(includes('This method is deprecated')) |
18 | | - is_expected.to run.with_params('1.2.3.4') |
| 18 | + is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first) |
19 | 19 | end |
20 | 20 | it 'should display no warning for deprecation' do |
21 | 21 | ENV['STDLIB_LOG_DEPRECATIONS'] = "false" |
22 | 22 | scope.expects(:warning).with(includes('This method is deprecated')).never |
23 | | - is_expected.to run.with_params('1.2.3.4') |
| 23 | + is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first) |
24 | 24 | end |
25 | | - end |
| 25 | + end |
26 | 26 |
|
27 | | - describe 'valid inputs' do |
28 | | - it { is_expected.to run.with_params('0.0.0.0') } |
29 | | - it { is_expected.to run.with_params('8.8.8.8') } |
30 | | - it { is_expected.to run.with_params('127.0.0.1') } |
31 | | - it { is_expected.to run.with_params('10.10.10.10') } |
32 | | - it { is_expected.to run.with_params('194.232.104.150') } |
33 | | - it { is_expected.to run.with_params('244.24.24.24') } |
34 | | - it { is_expected.to run.with_params('255.255.255.255') } |
35 | | - it { is_expected.to run.with_params('1.2.3.4', '5.6.7.8') } |
36 | | - context 'with netmasks' do |
37 | | - it { is_expected.to run.with_params('8.8.8.8/0') } |
38 | | - it { is_expected.to run.with_params('8.8.8.8/16') } |
39 | | - it { is_expected.to run.with_params('8.8.8.8/32') } |
40 | | - it { is_expected.to run.with_params('8.8.8.8/255.255.0.0') } |
41 | | - end |
| 27 | + SharedData::IPV4_PATTERNS.each do |value| |
| 28 | + it { is_expected.to run.with_params(value) } |
| 29 | + end |
| 30 | + |
| 31 | + SharedData::IPV4_NEGATIVE_PATTERNS.each do |value| |
| 32 | + it { is_expected.to run.with_params(value).and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } |
42 | 33 | end |
43 | 34 |
|
44 | 35 | describe 'invalid inputs' do |
45 | | - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) } |
46 | | - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) } |
47 | | - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) } |
48 | | - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } |
49 | | - it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } |
50 | | - it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } |
51 | | - it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } |
52 | | - it { is_expected.to run.with_params('affe::beef').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } |
53 | | - it { is_expected.to run.with_params('1.2.3.4', {}).and_raise_error(Puppet::ParseError, /is not a string/) } |
54 | | - it { is_expected.to run.with_params('1.2.3.4', 1).and_raise_error(Puppet::ParseError, /is not a string/) } |
55 | | - it { is_expected.to run.with_params('1.2.3.4', true).and_raise_error(Puppet::ParseError, /is not a string/) } |
56 | | - it { is_expected.to run.with_params('1.2.3.4', 'one').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) } |
| 36 | + [ {}, [], 1, true ].each do |invalid| |
| 37 | + it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, /is not a string/) } |
| 38 | + it { is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first, invalid).and_raise_error(Puppet::ParseError, /is not a string/) } |
| 39 | + end |
57 | 40 | end |
58 | 41 | end |
0 commit comments