Commit 9994dedf6a10575daccf8b761db72829bd3623f8
1 parent
13870552
Exists in
master
and in
18 other branches
refactoring assert_equivalent to compare arrays properly
Showing
1 changed file
with
3 additions
and
1 deletions
Show diff stats
test/test_helper.rb
... | ... | @@ -87,7 +87,9 @@ class ActiveSupport::TestCase |
87 | 87 | alias :ok :assert_block |
88 | 88 | |
89 | 89 | def assert_equivalent(enum1, enum2) |
90 | - assert( (enum1.length == enum2.length) && ((enum1 - enum2) == []) && ((enum2 - enum1) == []), "<#{enum1.inspect}> expected to be equivalent to <#{enum2.inspect}>") | |
90 | + enum1 = enum1.group_by{|e|e}.values | |
91 | + enum2 = enum2.group_by{|e|e}.values | |
92 | + assert( (enum1.length == enum2.length) && ((enum1 - enum2) == []), "<#{enum1.inspect}> expected to be equivalent to <#{enum2.inspect}>") | |
91 | 93 | end |
92 | 94 | |
93 | 95 | def assert_mandatory(object, attribute, test_value = 'some random string') | ... | ... |