travisjeffery/timecop
View on GitHub ↗ ★ 3,424 Ruby
A gem providing "time travel", "time freezing", and "time acceleration" capabilities, making it simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call.
5 mentions on Hacker News by 4 people: 0 stories, 5 comments · first 2012-12-11 · latest 2026-04-21
20082026
-
Ruby's timecop is great for those test scenarios https://github.com/travisjeffery/timecop
comment by pmontra · 2026-04-21 · in 10 years ago, someone wrote a test for Servo that included an expiry in 2026 -
The Ruby equivalent is Timecop https://github.com/travisjeffery/timecop Dynamic languages have the advantage to be able to rewrite the standard library classes at runtime.
comment by pmontra · 2023-12-20 · in How to unit test code that depends on time -
…there is a ruby testing library with the same name that's somewhat well-known (~3K stars on github) https://github.com/travisjeffery/timecop
comment by facebiff · 2020-04-01 · in Show HN: Time Cop – A simple, private, open-source time tracking app -
eek. Time tests should be using something like https://github.com/travisjeffery/timecop for repeatability. If you do mean to allow random starting values like that, you should look into property-based testing…
comment by bazzargh · 2015-06-05 · in When a+b+c does not equal c+b+a -
…out either of the following libs. As far as I can tell they differ only in their pun selection. https://github.com/travisjeffery/timecop https://github.com/bebanjo/delorean In the ruby community, disliking someone's choice of science…
comment by JonnieCache · 2012-12-11 · in FreezeGun: easy mocking of Python datetimes