union_spec.rb 1.9 KB

12345678910111213141516171819202122232425
  1. require 'spec_helper'
  2. describe 'union' do
  3. describe 'argument checking' 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}i) }
  6. it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
  7. it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError, %r{Every parameter must be an array}) }
  8. it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, %r{Every parameter must be an array}) }
  9. it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, %r{Every parameter must be an array}) }
  10. end
  11. it { is_expected.to run.with_params([], []).and_return([]) }
  12. it { is_expected.to run.with_params([], ['one']).and_return(['one']) }
  13. it { is_expected.to run.with_params(['one'], []).and_return(['one']) }
  14. it { is_expected.to run.with_params(['one'], ['one']).and_return(['one']) }
  15. it { is_expected.to run.with_params(['one'], ['two']).and_return(%w[one two]) }
  16. it { is_expected.to run.with_params(%w[one two three], %w[two three]).and_return(%w[one two three]) }
  17. it { is_expected.to run.with_params(%w[one two two three], %w[two three]).and_return(%w[one two three]) }
  18. it { is_expected.to run.with_params(%w[one two three], %w[two two three]).and_return(%w[one two three]) }
  19. it { is_expected.to run.with_params(%w[one two], %w[two three], %w[one three]).and_return(%w[one two three]) }
  20. it { is_expected.to run.with_params(%w[one two], %w[three four], %w[one two three], ['four']).and_return(%w[one two three four]) }
  21. it { is_expected.to run.with_params(%w[ốńə ţשׂợ], %w[ŧĥяếệ ƒởųŗ], %w[ốńə ţשׂợ ŧĥяếệ], ['ƒởųŗ']).and_return(%w[ốńə ţשׂợ ŧĥяếệ ƒởųŗ]) }
  22. it 'does not confuse types' do is_expected.to run.with_params(%w[1 2 3], [1, 2]).and_return(['1', '2', '3', 1, 2]) end
  23. end