Update puppetlabs/stdlib module
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / unique_spec.rb
1 require 'spec_helper'
2
3 describe 'unique' do
4   if Puppet.version.to_f < 5.0
5     describe 'signature validation' do
6       it { is_expected.not_to eq(nil) }
7       it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
8       it {
9         pending('Current implementation ignores parameters after the first.')
10         is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
11       }
12       it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
13       it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
14       it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
15     end
16
17     context 'when called with an array' do
18       it { is_expected.to run.with_params([]).and_return([]) }
19       it { is_expected.to run.with_params(['a']).and_return(['a']) }
20       it { is_expected.to run.with_params(['a', 'b', 'a']).and_return(['a', 'b']) }
21       it { is_expected.to run.with_params(['ã', 'ъ', 'ã']).and_return(['ã', 'ъ']) }
22     end
23
24     context 'when called with a string' do
25       it { is_expected.to run.with_params('').and_return('') }
26       it { is_expected.to run.with_params('a').and_return('a') }
27       it { is_expected.to run.with_params('aaba').and_return('ab') }
28       it { is_expected.to run.with_params('ããъã').and_return('ãъ') }
29     end
30   end
31 end