Created
September 12, 2011 09:54
-
-
Save aalin/1210945 to your computer and use it in GitHub Desktop.
Diff times so that you can read them in rspec
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
| require 'rspec-expectations' | |
| class RSpec::Expectations::Differ | |
| def diff_as_object(a, b) | |
| if a.is_a?(Time) && b.is_a?(Time) | |
| minutes, seconds = (b - a).divmod(60) | |
| hours, minutes = minutes.divmod(60) | |
| Kernel.format(" %dh %dm %ds \nactual: %s\nexpected: %s", hours, minutes, seconds % 60, b.utc.to_s, a.utc.to_s) | |
| else | |
| super | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment