This project is archived and is in readonly mode.

#2633 ✓committed
Ken Collins

Consistent Integer Values Using Fixtures.identify In Ruby1.9

Reported by Ken Collins | May 11th, 2009 @ 04:17 PM | in 2.x

Fixtures.identify is no longer working on 1.9 since it returns a different integer each time it's run. This is a change in ruby core that brought this about and I see no clear solution. Example code.




# Ruby 1.8.x

$ irb1.8
irb(main):001:0> 'admin'.hash.abs   # => 541702176
irb(main):002:0> exit

$ irb1.8
irb(main):001:0> 'admin'.hash.abs   # => 541702176


# Ruby 1.9.x

$ irb1.9
irb(main):001:0> 'admin'.hash.abs   # => 382338625
irb(main):002:0> exit

$ irb1.9
irb(main):001:0> 'admin'.hash.abs   # => 542676158


# Proposed usage of String#sum

$ irb1.9
irb(main):001:0> 'admin'.sum        # => 521

I have attached a patch, but it has no tests because I can not think of a good way to cleanly call another process. I'd like input on a test method to add and even if using String#sum might be the right way to go.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>