Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / delete_regex_spec.rb
1 require 'spec_helper'
2
3 describe 'delete_regex' do
4   it { is_expected.not_to eq(nil) }
5   it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
6   it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
7   it { is_expected.to run.with_params([], 'two') }
8   it { is_expected.to run.with_params({}, 'two') }
9   it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError) }
10   it { is_expected.to run.with_params([], 'two', 'three', 'four').and_raise_error(Puppet::ParseError) }
11   it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) }
12
13   describe 'deleting from an array' do
14     it { is_expected.to run.with_params([], '').and_return([]) }
15     it { is_expected.to run.with_params([], 'two').and_return([]) }
16     it { is_expected.to run.with_params(['two'], 'two').and_return([]) }
17     it { is_expected.to run.with_params(['two', 'two'], 'two').and_return([]) }
18     it { is_expected.to run.with_params(['one', 'two', 'three'], '^t.*').and_return(['one']) }
19     it { is_expected.to run.with_params(['ab', 'b', 'c', 'b'], 'b').and_return(['ab', 'c']) }
20     it { is_expected.to run.with_params(['one', 'two', 'three'], 'four').and_return(['one', 'two', 'three']) }
21     it { is_expected.to run.with_params(['one', 'two', 'three'], 'e').and_return(['one', 'two', 'three']) }
22     it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) }
23     it { is_expected.to run.with_params(['two', 'one', 'two', 'three', 'two'], 'two').and_return(['one', 'three']) }
24     it { is_expected.to run.with_params(['abracadabra'], 'abr').and_return(['abracadabra']) }
25     it { is_expected.to run.with_params(['abracadabra'], '^.*jimbob.*$').and_return(['abracadabra']) }
26   end
27
28   describe 'deleting from an array' do
29     it { is_expected.to run.with_params({}, '').and_return({}) }
30     it { is_expected.to run.with_params({}, 'key').and_return({}) }
31     it { is_expected.to run.with_params({ 'key' => 'value' }, 'key').and_return({}) }
32     it {
33       is_expected.to run \
34         .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'key2') \
35         .and_return('key1' => 'value1', 'key3' => 'value3')
36     }
37     it {
38       is_expected.to run \
39         .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, ['key1', 'key2']) \
40         .and_return('key3' => 'value3')
41     }
42   end
43
44   it 'leaves the original array intact' do
45     argument1 = ['one', 'two', 'three']
46     original1 = argument1.dup
47     subject.execute(argument1, 'two')
48     expect(argument1).to eq(original1)
49   end
50   it 'leaves the original hash intact' do
51     argument1 = { 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }
52     original1 = argument1.dup
53     subject.execute(argument1, 'key2')
54     expect(argument1).to eq(original1)
55   end
56 end