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:
Christoph Hartmann 2016-08-30 11:41:25 +02:00 committed by GitHub
commit 4673dfd90f
2 changed files with 11 additions and 1 deletions

View file

@ -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)

View file

@ -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