4 it { is_expected.not_to eq(nil) }
6 describe 'signature validation in puppet3', :unless => RSpec.configuration.puppet_future do
7 it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
9 pending('Current implementation ignores parameters after the third.')
10 is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
12 it { is_expected.to run.with_params('1..2..3').and_raise_error(Puppet::ParseError, %r{Unable to compute range}i) }
13 it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{Unknown range format}i) }
16 describe 'signature validation in puppet4', :if => RSpec.configuration.puppet_future do
18 pending 'the puppet 4 implementation'
19 is_expected.to run.with_params.and_raise_error(ArgumentError)
22 pending 'the puppet 4 implementation'
23 is_expected.to run.with_params('').and_raise_error(ArgumentError)
26 pending 'the puppet 4 implementation'
27 is_expected.to run.with_params({}).and_raise_error(ArgumentError)
30 pending 'the puppet 4 implementation'
31 is_expected.to run.with_params([]).and_raise_error(ArgumentError)
34 pending 'the puppet 4 implementation'
35 is_expected.to run.with_params(true).and_raise_error(ArgumentError)
38 is_expected.to run.with_params(1, 2, 'foo').and_raise_error(ArgumentError)
41 pending 'the puppet 4 implementation'
42 is_expected.to run.with_params(1, 2, []).and_raise_error(ArgumentError)
45 pending 'the puppet 4 implementation'
46 is_expected.to run.with_params(1, 2, {}).and_raise_error(ArgumentError)
49 pending 'the puppet 4 implementation'
50 is_expected.to run.with_params(1, 2, true).and_raise_error(ArgumentError)
53 pending 'the puppet 4 implementation'
54 is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(ArgumentError)
57 pending 'the puppet 4 implementation'
58 is_expected.to run.with_params('1..2..3').and_raise_error(ArgumentError)
62 context 'with characters as bounds' do
63 it { is_expected.to run.with_params('d', 'a').and_return([]) }
64 it { is_expected.to run.with_params('a', 'a').and_return(['a']) }
65 it { is_expected.to run.with_params('a', 'b').and_return(['a', 'b']) }
66 it { is_expected.to run.with_params('a', 'd').and_return(['a', 'b', 'c', 'd']) }
67 it { is_expected.to run.with_params('a', 'd', 1).and_return(['a', 'b', 'c', 'd']) }
68 it { is_expected.to run.with_params('a', 'd', '1').and_return(['a', 'b', 'c', 'd']) }
69 it { is_expected.to run.with_params('a', 'd', 2).and_return(['a', 'c']) }
70 it { is_expected.to run.with_params('a', 'd', -2).and_return(['a', 'c']) }
71 it { is_expected.to run.with_params('a', 'd', 3).and_return(['a', 'd']) }
72 it { is_expected.to run.with_params('a', 'd', 4).and_return(['a']) }
75 context 'with strings as bounds' do
76 it { is_expected.to run.with_params('onea', 'oned').and_return(['onea', 'oneb', 'onec', 'oned']) }
77 it { is_expected.to run.with_params('two', 'one').and_return([]) }
78 it { is_expected.to run.with_params('true', 'false').and_return([]) }
79 it { is_expected.to run.with_params('false', 'true').and_return(['false']) }
82 context 'with integers as bounds' do
83 it { is_expected.to run.with_params(4, 1).and_return([]) }
84 it { is_expected.to run.with_params(1, 1).and_return([1]) }
85 it { is_expected.to run.with_params(1, 2).and_return([1, 2]) }
86 it { is_expected.to run.with_params(1, 4).and_return([1, 2, 3, 4]) }
87 it { is_expected.to run.with_params(1, 4, 1).and_return([1, 2, 3, 4]) }
88 it { is_expected.to run.with_params(1, 4, '1').and_return([1, 2, 3, 4]) }
89 it { is_expected.to run.with_params(1, 4, 2).and_return([1, 3]) }
90 it { is_expected.to run.with_params(1, 4, -2).and_return([1, 3]) }
91 it { is_expected.to run.with_params(1, 4, 3).and_return([1, 4]) }
92 it { is_expected.to run.with_params(1, 4, 4).and_return([1]) }
95 context 'with integers as strings as bounds' do
96 it { is_expected.to run.with_params('4', '1').and_return([]) }
97 it { is_expected.to run.with_params('1', '1').and_return([1]) }
98 it { is_expected.to run.with_params('1', '2').and_return([1, 2]) }
99 it { is_expected.to run.with_params('1', '4').and_return([1, 2, 3, 4]) }
100 it { is_expected.to run.with_params('1', '4', 1).and_return([1, 2, 3, 4]) }
101 it { is_expected.to run.with_params('1', '4', '1').and_return([1, 2, 3, 4]) }
102 it { is_expected.to run.with_params('1', '4', 2).and_return([1, 3]) }
103 it { is_expected.to run.with_params('1', '4', -2).and_return([1, 3]) }
104 it { is_expected.to run.with_params('1', '4', 3).and_return([1, 4]) }
105 it { is_expected.to run.with_params('1', '4', 4).and_return([1]) }
108 context 'with prefixed numbers as strings as bounds' do
109 it { is_expected.to run.with_params('host01', 'host04').and_return(['host01', 'host02', 'host03', 'host04']) }
110 it { is_expected.to run.with_params('01', '04').and_return([1, 2, 3, 4]) }
113 context 'with prefixed numbers as utf8 strings as bounds' do
114 it { is_expected.to run.with_params('ħөŝŧ01', 'ħөŝŧ04').and_return(['ħөŝŧ01', 'ħөŝŧ02', 'ħөŝŧ03', 'ħөŝŧ04']) }
117 context 'with prefixed numbers as double byte character strings as bounds' do
118 it { is_expected.to run.with_params('ホスト01', 'ホスト04').and_return(['ホスト01', 'ホスト02', 'ホスト03', 'ホスト04']) }
121 context 'with dash-range syntax' do
122 it { is_expected.to run.with_params('4-1').and_return([]) }
123 it { is_expected.to run.with_params('1-1').and_return([1]) }
124 it { is_expected.to run.with_params('1-2').and_return([1, 2]) }
125 it { is_expected.to run.with_params('1-4').and_return([1, 2, 3, 4]) }
128 context 'with two-dot-range syntax' do
129 it { is_expected.to run.with_params('4..1').and_return([]) }
130 it { is_expected.to run.with_params('1..1').and_return([1]) }
131 it { is_expected.to run.with_params('1..2').and_return([1, 2]) }
132 it { is_expected.to run.with_params('1..4').and_return([1, 2, 3, 4]) }
135 context 'with three-dot-range syntax' do
136 it { is_expected.to run.with_params('4...1').and_return([]) }
137 it { is_expected.to run.with_params('1...1').and_return([]) }
138 it { is_expected.to run.with_params('1...2').and_return([1]) }
139 it { is_expected.to run.with_params('1...3').and_return([1, 2]) }
140 it { is_expected.to run.with_params('1...5').and_return([1, 2, 3, 4]) }
143 describe 'when passing mixed arguments as bounds' do
145 pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially') # rubocop:disable Metrics/LineLength : unable to cut line to required length
146 is_expected.to run.with_params('0', 'a').and_raise_error(Puppet::ParseError, %r{cannot interpolate between numeric and non-numeric bounds})
149 pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially') # rubocop:disable Metrics/LineLength : unable to cut line to required length
150 is_expected.to run.with_params(0, 'a').and_raise_error(Puppet::ParseError, %r{cannot interpolate between numeric and non-numeric bounds})
153 pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially') # rubocop:disable Metrics/LineLength : unable to cut line to required length
154 is_expected.to run.with_params('h0', 'ha').and_raise_error(Puppet::ParseError, %r{cannot interpolate between numeric and non-numeric bounds})