Skip to content

Instantly share code, notes, and snippets.

@Peeja
Created July 27, 2012 15:01
Show Gist options
  • Save Peeja/3188526 to your computer and use it in GitHub Desktop.
Save Peeja/3188526 to your computer and use it in GitHub Desktop.
Test Case for Timecop Issue #29
# A sample Gemfile
source "https://rubygems.org"
gem "activesupport"
gem "tzinfo"
gem "timecop", git: "https://github.com/jtrupiano/timecop"
GIT
remote: https://github.com/jtrupiano/timecop
revision: bfa7c0edcc777c54b278e7f3718e8b0e56cec1a3
specs:
timecop (0.4.1)
GEM
remote: https://rubygems.org/
specs:
activesupport (3.2.7)
i18n (~> 0.6)
multi_json (~> 1.0)
i18n (0.6.0)
multi_json (1.3.6)
tzinfo (0.3.33)
PLATFORMS
ruby
DEPENDENCIES
activesupport
timecop!
tzinfo
# https://github.com/jtrupiano/timecop/issues/29
require 'active_support/all'
require 'timecop'
Time.zone = "America/New_York"
jan1 = Time.zone.parse("Jan 1, 2012 10:00AM")
puts jan1
puts
puts "Before:"
puts DateTime.now
puts Time.now
puts
Timecop.travel(jan1)
puts "After 1:"
puts DateTime.now
puts Time.now
puts
Timecop.travel(jan1)
puts "After 2:"
puts DateTime.now
puts Time.now
puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment