Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Oddities with comparison and Time#usec in a test #1076

lupine opened this Issue · 3 comments

4 participants


This one's a little odd. We're using a version of acts_as_trashable to delete and restore database objects, and we have a test that goes a little bit like:

related_instance = model_instance.association
# Destroys the model & related instances in the DB, moves them to trashed_records

# Restore the model_instance and related_instance objects
restored_instance = model_class.restore_from_trash(

assert_equal(related_instance, restored_instance.association)

That assert_equal fails under Rubinius 2.0.0pre, but passes in JRuby 1.5.1 and MRI 1.8.7p302

I narrowed it down to the updated_at attributes of the two instances not evaluating as equal, and sure enough the two Time objects had different values for #usec.

The odd part is that if I inspect the value of the #usec attribute in MRI and JRuby before testing for equality, the test fails, just like rubinius! But if I don't, then the test passes. It's almost as though the value of usec is being lazily fetched, or something equally weird.


I looked at the implementation of MRI's Time#<=> and it does not lazily fetch usec. Perhaps this is a timing issue? What is the string value of the updated_at attribute? Does it even include usec?


@lupine Is this still an issue with Rubinius 2.0.0.rc1?


I'm closing this one since it hasn't seen any activity for a long time and doesn't really give us any information to go on. If this is still a problem, please open an issue! If you could provide a reproduction in that case, that would be great :).

@dbussink dbussink closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.