mirror of
https://github.com/inspec/inspec
synced 2024-11-27 15:10:44 +00:00
Merge pull request #991 from jeremymv2/cmp_treat_0_as_integer
cmp not treating 0 as integer only as string
This commit is contained in:
commit
4673dfd90f
2 changed files with 11 additions and 1 deletions
|
@ -232,7 +232,7 @@ end
|
|||
RSpec::Matchers.define :cmp do |first_expected|
|
||||
|
||||
def integer?(value)
|
||||
!(value =~ /\A[1-9]\d*\Z/).nil?
|
||||
!(value =~ /\A0+\Z|\A[1-9]\d*\Z/).nil?
|
||||
end
|
||||
|
||||
def float?(value)
|
||||
|
|
|
@ -112,4 +112,14 @@ if os.linux?
|
|||
it { should cmp 'False' }
|
||||
it { should cmp false }
|
||||
end
|
||||
|
||||
describe 0 do
|
||||
it { should cmp 0 }
|
||||
it { should cmp 00 }
|
||||
it { should cmp '0' }
|
||||
it { should cmp '00' }
|
||||
it { should_not cmp 1 }
|
||||
it { should_not cmp '01' }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue