Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / delete_at_spec.rb
1 require 'spec_helper'
2
3 describe 'delete_at' do
4   it { is_expected.not_to eq(nil) }
5   it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) }
6   it { is_expected.to run.with_params('one', 1).and_raise_error(Puppet::ParseError, %r{Requires array}) }
7   it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError, %r{Requires array}) }
8   it { is_expected.to run.with_params(['one'], 'two').and_raise_error(Puppet::ParseError, %r{You must provide non-negative numeric}) }
9   it {
10     pending('Current implementation ignores parameters after the first two.')
11     is_expected.to run.with_params(['one'], 0, 1).and_raise_error(Puppet::ParseError)
12   }
13
14   describe 'argument validation' do
15     it { is_expected.to run.with_params([0, 1, 2], 3).and_raise_error(Puppet::ParseError, %r{Given index exceeds size of array}) }
16   end
17
18   it { is_expected.to run.with_params([0, 1, 2], 1).and_return([0, 2]) }
19   it { is_expected.to run.with_params([0, 1, 2], -1).and_return([0, 1]) }
20   it { is_expected.to run.with_params([0, 1, 2], -4).and_return([0, 1, 2]) }
21   it { is_expected.to run.with_params(['ƒờở', 'βāř', 'ьầż'], 1).and_return(['ƒờở', 'ьầż']) }
22
23   it 'leaves the original array intact' do
24     argument = [1, 2, 3]
25     original = argument.dup
26     _result = subject.execute(argument, 2)
27     expect(argument).to eq(original)
28   end
29 end