diff --git a/lib/matchers/matchers.rb b/lib/matchers/matchers.rb index daa5ac43c..b9caa264d 100644 --- a/lib/matchers/matchers.rb +++ b/lib/matchers/matchers.rb @@ -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 diff --git a/test/integration/test/integration/default/compare_matcher_spec.rb b/test/integration/test/integration/default/compare_matcher_spec.rb index caac90694..178345fca 100644 --- a/test/integration/test/integration/default/compare_matcher_spec.rb +++ b/test/integration/test/integration/default/compare_matcher_spec.rb @@ -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