Skip to content

Commit 2fafe78

Browse files
authored
Merge pull request #1135 from jvrsantacruz/empty_start_end
Allow start/end checks on empty strings
2 parents 4b6cc31 + 3dcdb96 commit 2fafe78

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed

lib/puppet/functions/stdlib/end_with.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# 'foobar'.stdlib::end_with(['foo', 'baz']) => false
1111
# @return [Boolean] True or False
1212
dispatch :end_with do
13-
param 'String[1]', :test_string
13+
param 'String', :test_string
1414
param 'Variant[String[1],Array[String[1], 1]]', :suffixes
1515
return_type 'Boolean'
1616
end

lib/puppet/functions/stdlib/start_with.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# 'foObar'.stdlib::start_with(['bar', 'baz']) => false
1111
# @return [Boolean] True or False
1212
dispatch :start_with do
13-
param 'String[1]', :test_string
13+
param 'String', :test_string
1414
param 'Variant[String[1],Array[String[1], 1]]', :prefixes
1515
return_type 'Boolean'
1616
end

spec/functions/end_with_spec.rb

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
require 'spec_helper'
22

33
describe 'stdlib::end_with' do
4+
it { is_expected.to run.with_params('', 'bar').and_return(false) }
45
it { is_expected.to run.with_params('foobar', 'bar').and_return(true) }
56
it { is_expected.to run.with_params('foobar', 'foo').and_return(false) }
67
it { is_expected.to run.with_params('foobar', ['foo', 'baz']).and_return(false) }
7-
it do
8-
is_expected.to run.with_params('', 'foo').and_raise_error(
9-
ArgumentError, %r{'stdlib::end_with' parameter 'test_string' expects a String\[1\] value}
10-
)
11-
end
128
it do
139
is_expected.to run.with_params('foobar', '').and_raise_error(
1410
ArgumentError, %r{'stdlib::end_with' parameter 'suffixes' expects a value of type String\[1\] or Array\[String\[1\], 1\]}

spec/functions/startswith_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{expects 2 arguments, got none}i) }
66
it { is_expected.to run.with_params('').and_raise_error(ArgumentError, %r{expects 2 arguments, got 1}) }
77

8+
it { is_expected.to run.with_params('', 'foo').and_return(false) }
89
it { is_expected.to run.with_params('foobar', 'foo').and_return(true) }
910
it { is_expected.to run.with_params('foObar', ['bar', 'baz']).and_return(false) }
1011
end

0 commit comments

Comments
 (0)