Module: Timecop::Rspec
- Defined in:
- lib/timecop/rspec.rb,
lib/timecop/rspec/version.rb,
lib/timecop/rspec/traveler.rb,
lib/timecop/rspec/travel_log.rb,
lib/timecop/rspec/time_machine.rb,
lib/timecop/rspec/example_decorator.rb,
lib/timecop/rspec/sequential_time_machine.rb
Overview
RSpec integration for the timecop gem.
Provides helpers to run examples with frozen or traveling time, and an optional global time that applies across examples when configured via ENV.
Environment variables:
-
GLOBAL_TIME_TRAVEL_TIME: String representation of a time (preferred)
-
GLOBAL_TIME_TRAVEL_DATE: String representation of a date (fallback)
Defined Under Namespace
Modules: Version Classes: ExampleDecorator, SequentialTimeMachine, TimeMachine, TravelLog, Traveler
Constant Summary collapse
- VERSION =
Convenience constant aliasing Version::VERSION
Version::VERSION
Class Method Summary collapse
-
.global_time ⇒ Time
The globally configured time parsed from ENV.
-
.global_time_configured? ⇒ Boolean
Whether a global time has been configured via ENV.
-
.time_machine(sequential: false) ⇒ Timecop::Rspec::SequentialTimeMachine, Timecop::Rspec::TimeMachine
Selects a time machine strategy.
Class Method Details
.global_time ⇒ Time
The globally configured time parsed from ENV.
41 42 43 |
# File 'lib/timecop/rspec.rb', line 41 def global_time @global_time ||= Time.parse(global_time_travel_string) end |
.global_time_configured? ⇒ Boolean
Whether a global time has been configured via ENV.
33 34 35 36 |
# File 'lib/timecop/rspec.rb', line 33 def global_time_configured? str = global_time_travel_string !(str.nil? || str == "") end |
.time_machine(sequential: false) ⇒ Timecop::Rspec::SequentialTimeMachine, Timecop::Rspec::TimeMachine
Selects a time machine strategy.
23 24 25 26 27 28 29 |
# File 'lib/timecop/rspec.rb', line 23 def time_machine(sequential: false) if sequential SequentialTimeMachine.instance else TimeMachine.instance end end |