summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--lib/puppet/functions/length.rb2
-rwxr-xr-xspec/functions/is_function_available_spec.rb (renamed from spec/functions/is_function_available.rb)0
-rwxr-xr-xspec/functions/length_spec.rb (renamed from spec/functions/length.rb)6
4 files changed, 3 insertions, 7 deletions
diff --git a/README.md b/README.md
index 223945c..ac4f997 100644
--- a/README.md
+++ b/README.md
@@ -2214,7 +2214,7 @@ Arguments:
Example:
```puppet
-validate_legacy("Optional[String]", "validate_re", "Value to be validated", ["."])
+validate_legacy('Optional[String]', 'validate_re', 'Value to be validated', ["."])
```
This function supports updating modules from Puppet 3-style argument validation (using the stdlib `validate_*` functions) to Puppet 4 data types, without breaking functionality for those depending on Puppet 3-style validation.
diff --git a/lib/puppet/functions/length.rb b/lib/puppet/functions/length.rb
index 86e735c..5ebd455 100644
--- a/lib/puppet/functions/length.rb
+++ b/lib/puppet/functions/length.rb
@@ -3,7 +3,7 @@ Puppet::Functions.create_function(:length) do
dispatch :length do
param 'Variant[String,Array,Hash]', :value
end
- def length(value)
+ def length(value)
if value.is_a?(String)
result = value.length
elsif value.is_a?(Array) || value.is_a?(Hash)
diff --git a/spec/functions/is_function_available.rb b/spec/functions/is_function_available_spec.rb
index 44f08c0..44f08c0 100755
--- a/spec/functions/is_function_available.rb
+++ b/spec/functions/is_function_available_spec.rb
diff --git a/spec/functions/length.rb b/spec/functions/length_spec.rb
index d1ab003..487cf21 100755
--- a/spec/functions/length.rb
+++ b/spec/functions/length_spec.rb
@@ -26,10 +26,6 @@ describe 'length' do
it { is_expected.to run.with_params('āβćđ').and_return(4) }
context 'when using a class extending String' do
- it 'should call its size method' do
- value = AlsoString.new('asdfghjkl')
- value.expects(:length).returns('foo')
- expect(subject).to run.with_params(value).and_return('foo')
- end
+ it { is_expected.to run.with_params(AlsoString.new('asdfghjkl')).and_return(9) }
end
end