Sha256: 1a9f7800186218f7c86ae05604004928e97ea39831a2149f5eba3dfdbd64b1c8
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
require 'chronic' require 'timecop' # # TemporalHelpers module group all the needed methods to use Timecop with # Cucumber # # @author [zedtux] # module TemporalHelpers # Travels to +time+ and lets the clock keep running. # # If a block is given, executes the block at that # time then returns to the present. def travel_to(time, &block) Timecop.travel parse_time(time), &block end # Travels to and freezes the clock at +time+. # # If a block is given, executes the block at that # time then returns to the present. def freeze_time_at(time, &block) Timecop.freeze parse_time(time), &block end private def parse_time(time) Chronic.parse(time) || Time.parse(time) end end World(TemporalHelpers) Given(/^it is currently (.+)$/) do |time| travel_to time end Given(/^time is frozen at (.+)$/) do |time| freeze_time_at time end Given(/^(?:I|we) jump in our Delorean and return to the present$/) do Timecop.return end Before do # Ensure Chronic is using the same time zone Chronic.time_class = defined?(Rails) ? Time.zone : Time.now.zone end After do Timecop.return end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cucumber-timecop-0.0.5 | lib/cucumber/timecop.rb |