summaryrefslogtreecommitdiff
path: root/spec/functions/shell_split_spec.rb
diff options
context:
space:
mode:
authorJoris <joris@jorisvanderwel.com>2016-04-28 19:44:30 +0200
committerTP Honey <tphoney@users.noreply.github.com>2016-04-28 18:44:30 +0100
commit9e1f74f3fcac4aeaccade3ea92e6cafbaf71a64f (patch)
tree951a0596bb3dec824c1343d8837ec7ca9d9b10bc /spec/functions/shell_split_spec.rb
parent24797bb5ad73eb4baee0567282ef2670ed141a5c (diff)
Expose the functions of ruby's built-in Shellwords module (#580)
* Add shell_escape function, shell_join function & shell_split function
Diffstat (limited to 'spec/functions/shell_split_spec.rb')
-rw-r--r--spec/functions/shell_split_spec.rb24
1 files changed, 24 insertions, 0 deletions
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