diff --git a/lib/puppet/functions/stdlib/end_with.rb b/lib/puppet/functions/stdlib/end_with.rb index 2be98e6..fc83f70 100644 --- a/lib/puppet/functions/stdlib/end_with.rb +++ b/lib/puppet/functions/stdlib/end_with.rb @@ -1,21 +1,21 @@ # @summary # Returns true if str ends with one of the prefixes given. Each of the prefixes should be a String. # Puppet::Functions.create_function(:'stdlib::end_with') do # @param test_string The string to check # @param suffixes The suffixes to check # @example # 'foobar'.stdlib::end_with('bar') => true # 'foobar'.stdlib::end_with('foo') => false # 'foobar'.stdlib::end_with(['foo', 'baz']) => false # @return [Boolean] True or False dispatch :end_with do - param 'String[1]', :test_string + param 'String', :test_string param 'Variant[String[1],Array[String[1], 1]]', :suffixes return_type 'Boolean' end def end_with(test_string, suffixes) test_string.end_with?(*suffixes) end end diff --git a/lib/puppet/functions/stdlib/start_with.rb b/lib/puppet/functions/stdlib/start_with.rb index 294c72a..28f01bb 100644 --- a/lib/puppet/functions/stdlib/start_with.rb +++ b/lib/puppet/functions/stdlib/start_with.rb @@ -1,21 +1,21 @@ # @summary # Returns true if str starts with one of the prefixes given. Each of the prefixes should be a String. # Puppet::Functions.create_function(:'stdlib::start_with') do # @param test_string The string to check # @param prefixes The prefixes to check. # @example # 'foobar'.stdlib::start_with('foo') => true # 'foobar'.stdlib::start_with('bar') => false # 'foObar'.stdlib::start_with(['bar', 'baz']) => false # @return [Boolean] True or False dispatch :start_with do - param 'String[1]', :test_string + param 'String', :test_string param 'Variant[String[1],Array[String[1], 1]]', :prefixes return_type 'Boolean' end def start_with(test_string, prefixes) test_string.start_with?(*prefixes) end end diff --git a/spec/functions/end_with_spec.rb b/spec/functions/end_with_spec.rb index a9b95ec..5c1e8a9 100644 --- a/spec/functions/end_with_spec.rb +++ b/spec/functions/end_with_spec.rb @@ -1,17 +1,13 @@ require 'spec_helper' describe 'stdlib::end_with' do + it { is_expected.to run.with_params('', 'bar').and_return(false) } it { is_expected.to run.with_params('foobar', 'bar').and_return(true) } it { is_expected.to run.with_params('foobar', 'foo').and_return(false) } it { is_expected.to run.with_params('foobar', ['foo', 'baz']).and_return(false) } - it do - is_expected.to run.with_params('', 'foo').and_raise_error( - ArgumentError, %r{'stdlib::end_with' parameter 'test_string' expects a String\[1\] value} - ) - end it do is_expected.to run.with_params('foobar', '').and_raise_error( ArgumentError, %r{'stdlib::end_with' parameter 'suffixes' expects a value of type String\[1\] or Array\[String\[1\], 1\]} ) end end diff --git a/spec/functions/startswith_spec.rb b/spec/functions/startswith_spec.rb index 3820883..a259192 100644 --- a/spec/functions/startswith_spec.rb +++ b/spec/functions/startswith_spec.rb @@ -1,10 +1,11 @@ require 'spec_helper' describe 'stdlib::start_with' do it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{expects 2 arguments, got none}i) } it { is_expected.to run.with_params('').and_raise_error(ArgumentError, %r{expects 2 arguments, got 1}) } + it { is_expected.to run.with_params('', 'foo').and_return(false) } it { is_expected.to run.with_params('foobar', 'foo').and_return(true) } it { is_expected.to run.with_params('foObar', ['bar', 'baz']).and_return(false) } end