add cmp for Arrays

This commit is contained in:
Dominik Richter 2016-02-18 12:08:57 +01:00
parent 2bbbb29a9b
commit 03bf732d82
2 changed files with 12 additions and 0 deletions

View file

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

View file

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