[Git][noosfero/noosfero][master] refactoring assert_equivalent to compare arrays properly

Antonio Terceiro terceiro at colivre.coop.br
Wed Dec 9 13:38:55 BRST 2015


On Wed, Dec 09, 2015 at 01:07:46PM +0000, Leandro Nunes wrote:
> Leandro Nunes pushed to branch master at Noosfero / noosfero
> 
> 
> Commits:
> 9994dedf by Leandro Nunes dos Santos at 2015-12-09T10:06:58Z
> refactoring assert_equivalent to compare arrays properly
> 
> - - - - -
> 
> 
> 1 changed file:
> 
> - test/test_helper.rb
> 
> 
> Changes:
> 
> =====================================
> test/test_helper.rb
> =====================================
> --- a/test/test_helper.rb
> +++ b/test/test_helper.rb
> @@ -87,7 +87,9 @@ class ActiveSupport::TestCase
>    alias :ok :assert_block
>  
>    def assert_equivalent(enum1, enum2)
> -    assert( (enum1.length == enum2.length) && ((enum1 - enum2) == []) && ((enum2 - enum1) == []), "<#{enum1.inspect}> expected to be equivalent to <#{enum2.inspect}>")
> +    enum1 = enum1.group_by{|e|e}.values
> +    enum2 = enum2.group_by{|e|e}.values

This code can even does not make any sense. You are transforming
Enumarable into an array of arrays ...

>> [1,2,3].group_by { |e| e }.values
=> [[1], [2], [3]]

-- 
Antonio Terceiro <terceiro at colivre.coop.br>
Colivre - Cooperativa de Tecnologias Livres
http://www.colivre.coop.br/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20151209/ec3ae6ab/attachment.pgp>


More information about the Noosfero-dev mailing list