- it "should return chosen values from an array when passed ranges and multiple indexes" do
- result = scope.function_values_at([['a','b','c','d','e','f','g'],["0","2","4-5"]])
- expect(result).to(eq(['a','c','e','f']))
+ context 'when requesting multiple items' do
+ it { is_expected.to run.with_params([0, 1, 2], [1, -1]).and_raise_error(Puppet::ParseError, /Unknown format of given index/) }
+ it { is_expected.to run.with_params([0, 1, 2], [0, 2]).and_return([0, 2]) }
+ it { is_expected.to run.with_params([0, 1, 2], ['0-2', 1, 2]).and_return([0, 1, 2, 1, 2]) }
+ it { is_expected.to run.with_params([0, 1, 2], [3, 2]).and_raise_error(Puppet::ParseError, /index exceeds array size/) }
+
+ describe 'different range syntaxes' do
+ it { is_expected.to run.with_params([0, 1, 2], '0-2').and_return([0, 1, 2]) }
+ it { is_expected.to run.with_params([0, 1, 2], '0..2').and_return([0, 1, 2]) }
+ it { is_expected.to run.with_params([0, 1, 2], '0...2').and_return([0, 1]) }
+ it {
+ pending('fix this bounds check')
+ is_expected.to run.with_params([0, 1, 2], '0...3').and_return([0, 1, 2])
+ }
+ end