Module: Brut::SpecSupport::ClockSupport
- Included in:
- ComponentSupport, HandlerSupport
- Defined in:
- lib/brut/spec_support/clock_support.rb
Overview
Convienience methods for creating clocks needed in tests
Instance Method Summary collapse
-
#clock_at(now:) ⇒ Object
Return a clock whose value for now is
now
, in UTC. -
#clock_in_timezone_at(timezone_name:, now:) ⇒ Object
Return a clock whose value for now is
now
in the given timezone. -
#real_clock ⇒ Object
Return a real lock in UTC.
Instance Method Details
#clock_at(now:) ⇒ Object
Return a clock whose value for now is now
, in UTC
9 10 11 |
# File 'lib/brut/spec_support/clock_support.rb', line 9 def clock_at(now:) self.clock_in_timezone_at(timezone_name: "UTC", now: now) end |
#clock_in_timezone_at(timezone_name:, now:) ⇒ Object
Return a clock whose value for now is now
in the given timezone
17 18 19 20 21 22 23 |
# File 'lib/brut/spec_support/clock_support.rb', line 17 def clock_in_timezone_at(timezone_name:, now:) time = Time.parse(now) timezone = TZInfo::Timezone.get(timezone_name) same_time_in_timezone = timezone.local_time(time.year, time.month, time.day, time.hour, time.min, time.sec) Clock.new(TZInfo::Timezone.get(timezone_name), now: same_time_in_timezone) end |