Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #12 from tomykaira/DateTime_1.9.3

Fix #10, Support DateTime.now in ruby 1.9.3
  • Loading branch information...
commit e6c0b0936d4b1a3cbe1fdde83fb5ebb4f6990155 2 parents e47cfc7 + 0c98ffa
@cavalle cavalle authored
Showing with 15 additions and 0 deletions.
  1. +8 −0 lib/delorean.rb
  2. +7 −0 spec/delorean_spec.rb
View
8 lib/delorean.rb
@@ -68,4 +68,12 @@ def today(sg=Date::ITALY)
Date.civil(t.year, t.mon, t.mday)
end
end
+
+ class << DateTime
+ alias_method :now_without_delorean, :now
+
+ def now(sg=Date::ITALY)
+ Time.now.to_datetime
+ end
+ end
end
View
7 spec/delorean_spec.rb
@@ -57,6 +57,13 @@
Time.now.should be_close(datetime, 1)
end
end
+
+ it "should change the result of DateTime" do
+ datetime = DateTime.strptime("2011-05-25 18:00", "%Y-%m-%d %H:%M")
+ Delorean.time_travel_to(datetime) do
+ DateTime.now.should be_close(datetime, 1)
+ end
+ end
end
describe "back_to_the_present" do
Please sign in to comment.
Something went wrong with that request. Please try again.