Update stdlib
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / sort_spec.rb
1 require 'spec_helper'
2
3 describe 'sort' do
4   describe 'signature validation' do
5     it { is_expected.not_to eq(nil) }
6     it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
7     it { is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
8     it { pending('stricter input checking'); is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /requires string or array/) }
9     it { pending('stricter input checking'); is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /requires string or array/) }
10     it { pending('stricter input checking'); is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /requires string or array/) }
11   end
12
13   context 'when called with an array' do
14     it { is_expected.to run.with_params([]).and_return([]) }
15     it { is_expected.to run.with_params(['a']).and_return(['a']) }
16     it { is_expected.to run.with_params(['c', 'b', 'a']).and_return(['a', 'b', 'c']) }
17   end
18
19   context 'when called with a string' do
20     it { is_expected.to run.with_params('').and_return('') }
21     it { is_expected.to run.with_params('a').and_return('a') }
22     it { is_expected.to run.with_params('cbda').and_return('abcd') }
23   end
24 end