Created
July 12, 2010 14:45
-
-
Save jodosha/472552 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This module is intended for test usage, it helps to compare Time instances with millisecond precision. | |
| # Ruby has a fine-grained internal representation of Time values, so if you try: | |
| # Time.now == Time.now # => false | |
| # By including this module the above comparison returns true. | |
| module ComparableWithFixnum | |
| def self.included(base) | |
| base.class_eval do | |
| alias :"original_==" :== | |
| end | |
| end | |
| def ==(other) | |
| if other.kind_of?(self.class) | |
| self.to_i == other.to_i | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment