shell_escape_spec.rb 1.2 KB

1234567891011121314151617181920212223242526272829
  1. require 'spec_helper'
  2. describe 'shell_escape' 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. end
  8. describe 'stringification' do
  9. it { is_expected.to run.with_params(10).and_return('10') }
  10. it { is_expected.to run.with_params(false).and_return('false') }
  11. end
  12. describe 'escaping' do
  13. it { is_expected.to run.with_params('foo').and_return('foo') }
  14. it { is_expected.to run.with_params('foo bar').and_return('foo\ bar') }
  15. it {
  16. is_expected.to run.with_params('~`!@#$%^&*()_+-=[]\{}|;\':",./<>?')
  17. .and_return('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?')
  18. }
  19. end
  20. context 'with UTF8 and double byte characters' do
  21. it { is_expected.to run.with_params('スペー スを含むテ キスト').and_return('\\ス\\ペ\\ー\\ \\ス\\を\\含\\む\\テ\\ \\ \\キ\\ス\\ト') }
  22. it { is_expected.to run.with_params('μťƒ 8 ŧĕχť').and_return('\\μ\\ť\\ƒ\\ 8\\ \\ \\ŧ\\ĕ\\χ\\ť') }
  23. end
  24. end