← Graph

Is time travel the only way to test Time.current?

question 3 connections

An audience member challenges Rodzik's assertion that time-travel helpers are the only way to test `Time.current`/`Time.now`, offering two alternatives: algebraic effects, and dependency injection of a per-request/per-process current-time object. Rodzik fully agrees those are often better approaches, but notes time-travel helpers remain the ones he still sees in real codebases.

answer_summary
No. Algebraic effects and dependency injection of a per-request current-time object are better approaches; Rodzik agrees but notes time-travel helpers persist in real RSpec suites.
question Is time travel the only way to test Time.current?
about
Discusses how to properly test current-time dependencies.
question Is time travel the only way to test Time.current?
about
Proposes DI of a current-time object as an alternative to time-travel helpers.
question Is time travel the only way to test Time.current?
asked_at
Audience challenged the 'only option' claim about time-travel helpers.

Provenance

Read by
1 extraction