From 9e1f74f3fcac4aeaccade3ea92e6cafbaf71a64f Mon Sep 17 00:00:00 2001 From: Joris Date: Thu, 28 Apr 2016 19:44:30 +0200 Subject: Expose the functions of ruby's built-in Shellwords module (#580) * Add shell_escape function, shell_join function & shell_split function --- spec/functions/shell_split_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 spec/functions/shell_split_spec.rb (limited to 'spec/functions/shell_split_spec.rb') diff --git a/spec/functions/shell_split_spec.rb b/spec/functions/shell_split_spec.rb new file mode 100644 index 0000000..beeb977 --- /dev/null +++ b/spec/functions/shell_split_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe 'shell_split' do + it { is_expected.not_to eq(nil) } + + describe 'signature validation' do + it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it { is_expected.to run.with_params('foo', 'bar').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + end + + describe 'stringification' do + it { is_expected.to run.with_params(10).and_return(['10']) } + it { is_expected.to run.with_params(false).and_return(['false']) } + end + + describe 'shell line spliting' do + it { is_expected.to run.with_params('foo').and_return(['foo']) } + it { is_expected.to run.with_params('foo bar').and_return(['foo', 'bar']) } + it { is_expected.to run.with_params('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?') + .and_return(['~`!@#$%^&*()_+-=[]\{}|;\':",./<>?']) } + it { is_expected.to run.with_params('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?') + .and_return(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?']) } + end +end -- cgit v1.2.3