mirror of
https://github.com/inspec/inspec
synced 2024-11-27 15:10:44 +00:00
Merge pull request #487 from chef/chris-rock/cmp-matcher
cmp matcher should compare expected string == number
This commit is contained in:
commit
a46af20e66
2 changed files with 7 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue