timecop
timecop copied to clipboard
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 DateT...
While fine-tuning an application's use of Timecop, I noticed that `frozen?` was returning true if any mock type was active, not just `:freeze` but also `:travel` or `:scale`. I believe...
Capitalized the start of two words for consistency throughout the readme.
It would be great to be able to freeze and travel time returned by this method. https://ruby-doc.org/core-2.4.2/Process.html#method-c-clock_gettime More on monotonic clocks: https://www.softwariness.com/articles/monotonic-clocks-windows-and-posix/
``` Loading development environment (Rails 5.0.6) [1] pry(main)> Date.parse('2016-W41') => Mon, 10 Oct 2016 [2] pry(main)> Timecop.freeze(2016, 10, 16, 10, 0, 0) => 2016-10-16 10:00:00 +0200 [3] pry(main)> Date.parse('2016-W41') =>...
I noticed we had some tests that measure elapsed time, and use Timecop in tests to check that the measuring results are accurate. The tests were measuring time passed in...
```ruby pry: main > Rails.cache.write('test', true, unless_exist: true, expires_in: 15.seconds) # => true pry: main > Rails.cache.write('test', true, unless_exist: true, expires_in: 15.seconds) # => false pry: main > Timecop.travel(15.minutes.from_now) {...
We see this: ```console irb(main):001:0> week = '201810' => "201810" irb(main):002:0> Date.strptime(week, "%Y%W") => Mon, 05 Mar 2018 irb(main):003:0> require 'timecop' => true irb(main):004:0> Date.strptime(week, "%Y%W") => Mon, 01 Jan...
In https://github.com/ylecuyer/puma-status I had a red build because timecop isn't yet compatible with ruby 3.1 ``` Run bundle exec rspec /home/runner/.rubies/ruby-head/lib/ruby/gems/3.1.0/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:29: warning: Pathname#untaint is deprecated and will be removed in...
through active_supports [calculations.rb](https://github.com/rails/rails/blob/53d9bb9a92c32a6dffdadd534bcb6c6d5e223b91/activesupport/lib/active_support/core_ext/time/calculations.rb#L50). Errors are all same: ``` 5) Error: TestTimecopWithoutDate#test_recursive_travel_then_freeze: NameError: uninitialized constant #::DateTime /usr/share/gems/gems/activesupport-5.2.3/lib/active_support/core_ext/time/calculations.rb:50:in `at_with_coercion' /builddir/build/BUILD/rubygem-timecop-0.9.1/usr/share/gems/gems/timecop-0.9.1/lib/timecop/time_stack_item.rb:59:in `time' /builddir/build/BUILD/rubygem-timecop-0.9.1/usr/share/gems/gems/timecop-0.9.1/lib/timecop/time_stack_item.rb:129:in `compute_travel_offset' /builddir/build/BUILD/rubygem-timecop-0.9.1/usr/share/gems/gems/timecop-0.9.1/lib/timecop/time_stack_item.rb:14:in `initialize' /builddir/build/BUILD/rubygem-timecop-0.9.1/usr/share/gems/gems/timecop-0.9.1/lib/timecop/timecop.rb:192:in `new' /builddir/build/BUILD/rubygem-timecop-0.9.1/usr/share/gems/gems/timecop-0.9.1/lib/timecop/timecop.rb:192:in `travel' /builddir/build/BUILD/rubygem-timecop-0.9.1/usr/share/gems/gems/timecop-0.9.1/lib/timecop/timecop.rb:129:in `send_travel' /builddir/build/BUILD/rubygem-timecop-0.9.1/usr/share/gems/gems/timecop-0.9.1/lib/timecop/timecop.rb:62:in...
This should be true by default. Please vote for 👍🏻 or against 👎🏼