Created
March 8, 2011 18:37
-
-
Save gmgent/860737 to your computer and use it in GitHub Desktop.
This file contains 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 'test_helper' | |
class ModTest < ActiveSupport::TestCase | |
test "ago function" do | |
assert_equal "1 second ago.", Mod.ago(1) | |
assert_equal "40 seconds ago.", Mod.ago(40) | |
assert_equal "1 minute, 1 second ago.", Mod.ago(61) | |
assert_equal "3 minutes, 1 second ago.", Mod.ago(181) | |
assert_equal "2 minutes, 40 seconds ago.", Mod.ago(160) | |
assert_equal "1 hour, 3 minutes, 1 second ago.", Mod.ago(3600 + 181) | |
assert_equal "2 hours, 3 minutes, 2 seconds ago.", Mod.ago((3600 * 2)+ 182) | |
assert_equal "1 day, 0 hour, 1 minute, 1 second ago.", Mod.ago((60*60*24) + 61) | |
assert_equal "1 day, 3 hours, 1 minute, 1 second ago.", Mod.ago((60*60*24) + 3600 + 3600 + 3600 + 61) | |
assert_equal "2 days, 3 hours, 0 minute, 6 seconds ago.", Mod.ago(((60*60*24)*2) + 3600 + 3600 + 3600 + 6) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment