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.2.4 spec/helpers/time_travel.rb
bulldog-0.2.3 spec/helpers/time_travel.rb
bulldog-0.2.2 spec/helpers/time_travel.rb
bulldog-0.2.1 spec/helpers/time_travel.rb
bulldog-0.2.0 spec/helpers/time_travel.rb
bulldog-0.1.1 spec/helpers/time_travel.rb
bulldog-0.1.0 spec/helpers/time_travel.rb
bulldog-0.0.15 spec/helpers/time_travel.rb
bulldog-0.0.14 spec/helpers/time_travel.rb
bulldog-0.0.13 spec/helpers/time_travel.rb
bulldog-0.0.12 spec/helpers/time_travel.rb
bulldog-0.0.11 spec/helpers/time_travel.rb
bulldog-0.0.10 spec/helpers/time_travel.rb
bulldog-0.0.9 spec/helpers/time_travel.rb
bulldog-0.0.8 spec/helpers/time_travel.rb
bulldog-0.0.7 spec/helpers/time_travel.rb
bulldog-0.0.6 spec/helpers/time_travel.rb
bulldog-0.0.5 spec/helpers/time_travel.rb
bulldog-0.0.3 spec/helpers/time_travel.rb
bulldog-0.0.4 spec/helpers/time_travel.rb