Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / concat_spec.rb
1 require 'spec_helper'
2
3 describe 'concat' 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([1]).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) }
7   it { is_expected.to run.with_params(1, [2]).and_raise_error(Puppet::ParseError, %r{Requires array}) }
8   it { is_expected.to run.with_params([1], [2], [3]).and_return([1, 2, 3]) }
9   it { is_expected.to run.with_params(['1', '2', '3'], ['4', '5', '6']).and_return(['1', '2', '3', '4', '5', '6']) }
10   it { is_expected.to run.with_params(['1', '2', '3'], '4').and_return(['1', '2', '3', '4']) }
11   it { is_expected.to run.with_params(['1', '2', '3'], [['4', '5'], '6']).and_return(['1', '2', '3', ['4', '5'], '6']) }
12   it { is_expected.to run.with_params(['1', '2'], ['3', '4'], ['5', '6']).and_return(['1', '2', '3', '4', '5', '6']) }
13   it { is_expected.to run.with_params(['1', '2'], '3', '4', ['5', '6']).and_return(['1', '2', '3', '4', '5', '6']) }
14
15   context 'with UTF8 and double byte characters' do
16     it { is_expected.to run.with_params([{ 'a' => 'b' }], 'c' => 'd', 'e' => 'f').and_return([{ 'a' => 'b' }, { 'c' => 'd', 'e' => 'f' }]) }
17     it { is_expected.to run.with_params(['ấ', 'β', '©'], ['đ', 'ể', '文字列']).and_return(['ấ', 'β', '©', 'đ', 'ể', '文字列']) }
18   end
19
20   arguments = [['1', '2', '3'], ['4', '5', '6']]
21   originals = [arguments[0].dup, arguments[1].dup]
22   it 'leaves the original array intact' do
23     _result = subject.execute(arguments[0], arguments[1])
24     arguments.each_with_index do |argument, index|
25       expect(argument).to eq(originals[index])
26     end
27   end
28 end