Check for numeric values as empty fails on those
This commit is contained in:
parent
48b658fc1c
commit
6f1d164da6
2 changed files with 9 additions and 5 deletions
|
@ -13,14 +13,18 @@ Returns true if the variable is empty.
|
|||
|
||||
value = arguments[0]
|
||||
|
||||
unless value.is_a?(Array) || value.is_a?(Hash) || value.is_a?(String)
|
||||
unless value.is_a?(Array) || value.is_a?(Hash) || value.is_a?(String) || value.is_a?(Numeric)
|
||||
raise(Puppet::ParseError, 'empty(): Requires either ' +
|
||||
'array, hash or string to work with')
|
||||
'array, hash, string or integer to work with')
|
||||
end
|
||||
|
||||
result = value.empty?
|
||||
if value.is_a?(Numeric)
|
||||
return false
|
||||
else
|
||||
result = value.empty?
|
||||
|
||||
return result
|
||||
return result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ require 'spec_helper'
|
|||
describe 'empty' do
|
||||
it { is_expected.not_to eq(nil) }
|
||||
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
|
||||
it { is_expected.to run.with_params(0).and_raise_error(Puppet::ParseError) }
|
||||
it {
|
||||
pending("Current implementation ignores parameters after the first.")
|
||||
is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError)
|
||||
}
|
||||
it { is_expected.to run.with_params(0).and_return(false) }
|
||||
it { is_expected.to run.with_params('').and_return(true) }
|
||||
it { is_expected.to run.with_params('one').and_return(false) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue