Sha256: 74cbf184b5bd833ef3087dec7b6641100b53cc597ebef77af1917271ca0c195d

Contents?: true

Size: 353 Bytes

Versions: 22

Compression:

Stored size: 353 Bytes

Contents

module TimeTravel
  def self.included(mod)
    mod.before{stop_time}
  end

  def stop_time
    warp_to Time.now
  end

  def warp_to(time)
    time = Time.parse(time) if time.is_a?(String)
    Time.stubs(:now).returns(time)
  end

  def warp_ahead(duration)
    new_now = Time.now + duration
    Time.stubs(:now).returns(new_now)
    new_now
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
bulldog-0.0.2 spec/helpers/time_travel.rb
bulldog-0.0.1 spec/helpers/time_travel.rb