shell_join_spec.rb 1.4 KB

123456789101112131415161718192021222324252627282930
  1. require 'spec_helper'
  2. describe 'shell_join' do
  3. it { is_expected.not_to eq(nil) }
  4. describe 'signature validation' do
  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(['foo'], ['bar']).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
  7. it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError, %r{is not an Array}i) }
  8. end
  9. describe 'shell argument joining' do
  10. it { is_expected.to run.with_params(['foo']).and_return('foo') }
  11. it { is_expected.to run.with_params(%w[foo bar]).and_return('foo bar') }
  12. it { is_expected.to run.with_params(['foo', 'bar baz']).and_return('foo bar\ baz') }
  13. it {
  14. is_expected.to run.with_params(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?'])
  15. .and_return('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?')
  16. }
  17. context 'with UTF8 and double byte characters' do
  18. it { is_expected.to run.with_params(%w[μťƒ 8 ŧĕχť]).and_return('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť') }
  19. it { is_expected.to run.with_params(['スペー', 'スを含むテ', ' キスト']).and_return('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト') }
  20. end
  21. end
  22. describe 'stringification' do
  23. it { is_expected.to run.with_params([10, false, 'foo']).and_return('10 false foo') }
  24. end
  25. end