mirror of
https://github.com/inspec/inspec
synced 2024-11-23 21:23:29 +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|
|
RSpec::Matchers.define :cmp do |first_expected|
|
||||||
|
|
||||||
def integer?(value)
|
def integer?(value)
|
||||||
!(value =~ /\A[1-9]\d*\Z/).nil?
|
!(value =~ /\A0+\Z|\A[1-9]\d*\Z/).nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def float?(value)
|
def float?(value)
|
||||||
|
|
|
@ -112,4 +112,14 @@ if os.linux?
|
||||||
it { should cmp 'False' }
|
it { should cmp 'False' }
|
||||||
it { should cmp false }
|
it { should cmp false }
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue