Sha256: ae030405af5d727d9985f33beab2a0bb1913abda455fb2b4846632dbc93b91d2
Contents?: true
Size: 733 Bytes
Versions: 6
Compression:
Stored size: 733 Bytes
Contents
if defined?(Timecop) When /^the (?:date|time) is "(\d{4}-\d{2}-\d{2}(?: \d{1,2}:\d{2})?)"$/ do |time| Timecop.travel Time.parse(time) end When /^the time is "(\d{1,2}:\d{2})"$/ do |time| Timecop.travel Time.parse(time) # date will be today end When /^it is (\d+|a|some|a few) (seconds?|minutes?|hours?|days?|weeks?|months?|years?) (later|earlier)$/ do |amount, unit, direction| amount = case amount when 'a' 1 when 'some', 'a few' 10 else amount.to_i end amount = -amount if direction == 'earlier' Timecop.travel(Time.now + amount.send(unit)) end After do Timecop.return end end
Version data entries
6 entries across 6 versions & 1 rubygems