ed63bc384d4f609c284e57f38c120436501bd715
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / shell_escape_spec.rb
1 require 'spec_helper'
2
3 describe 'shell_escape' do
4   it { is_expected.not_to eq(nil) }
5
6   describe 'signature validation' do
7     it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
8     it { is_expected.to run.with_params('foo', 'bar').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
9   end
10
11   describe 'stringification' do
12     it { is_expected.to run.with_params(10).and_return('10') }
13     it { is_expected.to run.with_params(false).and_return('false') }
14   end
15
16   describe 'escaping' do
17     it { is_expected.to run.with_params('foo').and_return('foo') }
18     it { is_expected.to run.with_params('foo bar').and_return('foo\ bar') }
19     it {
20       is_expected.to run.with_params('~`!@#$%^&*()_+-=[]\{}|;\':",./<>?')
21                         .and_return('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?')
22     }
23   end
24
25   context 'with UTF8 and double byte characters' do
26     it { is_expected.to run.with_params('スペー スを含むテ  キスト').and_return('\\ス\\ペ\\ー\\ \\ス\\を\\含\\む\\テ\\ \\ \\キ\\ス\\ト') }
27     it { is_expected.to run.with_params('μťƒ 8  ŧĕχť').and_return('\\μ\\ť\\ƒ\\ 8\\ \\ \\ŧ\\ĕ\\χ\\ť') }
28   end
29 end