Merge pull request #487 from chef/chris-rock/cmp-matcher

cmp matcher should compare expected string == number
This commit is contained in:
Dominik Richter 2016-02-23 22:55:06 +01:00
commit a46af20e66
2 changed files with 7 additions and 0 deletions

View file

@ -248,6 +248,8 @@ RSpec::Matchers.define :cmp do |expected|
# if actual and expected are strings
if expected.is_a?(String) && actual.is_a?(String)
actual.casecmp(expected) == 0
elsif expected.is_a?(String) && integer?(expected) && actual.is_a?(Integer)
expected.to_i == actual
elsif expected.is_a?(Integer) && integer?(actual)
expected == actual.to_i
elsif expected.is_a?(Float) && float?(actual)

View file

@ -29,4 +29,9 @@ if os.linux?
it { should include 'root' }
it { should_not cmp 'root' }
end
len = passwd.passwords.length
describe len do
it { should cmp len.to_s }
end
end