Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
lupine opened this Issue · 3 comments

4 participants

@lupine

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
model_instance.destroy

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

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.

@evanphx
Owner

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?

@frodsan

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

@dbussink
Owner

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.