unique_spec.rb 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. require 'spec_helper'
  2. describe 'unique' do
  3. if Puppet.version.to_f < 5.0
  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, %r{wrong number of arguments}i) }
  7. it {
  8. pending('Current implementation ignores parameters after the first.')
  9. is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
  10. }
  11. it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
  12. it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
  13. it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
  14. end
  15. context 'when called with an array' do
  16. it { is_expected.to run.with_params([]).and_return([]) }
  17. it { is_expected.to run.with_params(['a']).and_return(['a']) }
  18. it { is_expected.to run.with_params(%w[a b a]).and_return(%w[a b]) }
  19. it { is_expected.to run.with_params(%w[ã ъ ã]).and_return(%w[ã ъ]) }
  20. end
  21. context 'when called with a string' do
  22. it { is_expected.to run.with_params('').and_return('') }
  23. it { is_expected.to run.with_params('a').and_return('a') }
  24. it { is_expected.to run.with_params('aaba').and_return('ab') }
  25. it { is_expected.to run.with_params('ããъã').and_return('ãъ') }
  26. end
  27. end
  28. end