Module: Tins::TimeFreezer
- Defined in:
- lib/tins/xt/time_freezer.rb
Overview
TimeFreezer provides a mechanism to temporarily freeze time across multiple time-related classes.
This module allows you to temporarily replace the behavior of Time, DateTime, and Date classes with dummy implementations that always return a specific time value. This is particularly useful for testing code that depends on current time values.
Class Method Summary collapse
-
.freeze(time) { ... } ⇒ Object
Freezes time for the duration of the given block.
Class Method Details
.freeze(time) { ... } ⇒ Object
Freezes time for the duration of the given block.
This method temporarily replaces the behavior of Time, DateTime, and Date classes with dummy implementations that always return the specified time value.
time-related classes to
42 43 44 45 46 47 48 49 50 |
# File 'lib/tins/xt/time_freezer.rb', line 42 def self.freeze(time) Time.dummy(time) do DateTime.dummy(time) do Date.dummy(time) do yield end end end end |