Skip to content

Instantly share code, notes, and snippets.

@aalin
Created September 12, 2011 09:54
Show Gist options
  • Select an option

  • Save aalin/1210945 to your computer and use it in GitHub Desktop.

Select an option

Save aalin/1210945 to your computer and use it in GitHub Desktop.
Diff times so that you can read them in rspec
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