mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
add cmp for Arrays
This commit is contained in:
parent
2bbbb29a9b
commit
03bf732d82
2 changed files with 12 additions and 0 deletions
|
@ -244,6 +244,7 @@ RSpec::Matchers.define :cmp do |expected|
|
|||
end
|
||||
|
||||
match do |actual|
|
||||
actual = actual[0] if actual.is_a?(Array) && !expected.is_a?(Array) && actual.length == 1
|
||||
# if actual and expected are strings
|
||||
if expected.is_a?(String) && actual.is_a?(String)
|
||||
actual.casecmp(expected) == 0
|
||||
|
|
|
@ -18,4 +18,15 @@ if os.linux?
|
|||
its('LogLevel') { should cmp 'info' }
|
||||
its('LogLevel') { should cmp 'InfO' }
|
||||
end
|
||||
|
||||
describe passwd.passwords.uniq do
|
||||
it { should eq ['x'] }
|
||||
it { should cmp ['x'] }
|
||||
it { should cmp 'x' }
|
||||
end
|
||||
|
||||
describe passwd.usernames do
|
||||
it { should include 'root' }
|
||||
it { should_not cmp 'root' }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue