puppetlabs-stdlib/spec/functions/shell_join_spec.rb
Joris 9e1f74f3fc Expose the functions of ruby's built-in Shellwords module (#580)
* Add shell_escape function, shell_join function & shell_split function
2016-04-28 18:44:30 +01:00

23 lines
1.1 KiB
Ruby

require 'spec_helper'
describe 'shell_join' 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) }
it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError, /is not an Array/i) }
end
describe 'shell argument joining' 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(['foo', 'bar baz']).and_return('foo bar\ baz') }
it { is_expected.to run.with_params(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?'])
.and_return('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?') }
end
describe 'stringification' do
it { is_expected.to run.with_params([10, false, 'foo']).and_return('10 false foo') }
end
end