timecop 0.5.8 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/timecop/time_stack_item.rb +3 -1
- data/lib/timecop/version.rb +1 -1
- data/test/time_stack_item_test.rb +10 -0
- metadata +2 -2
@@ -52,7 +52,9 @@ class Timecop
|
|
52
52
|
|
53
53
|
def time(time_klass = Time) #:nodoc:
|
54
54
|
begin
|
55
|
-
|
55
|
+
actual_time = time_klass.at(@time)
|
56
|
+
calculated_time = time_klass.at(@time.to_f)
|
57
|
+
time = times_are_equal_within_epsilon(actual_time, calculated_time, 1) ? actual_time : calculated_time
|
56
58
|
rescue
|
57
59
|
time = time_klass.at(@time.to_f)
|
58
60
|
end
|
data/lib/timecop/version.rb
CHANGED
@@ -244,4 +244,14 @@ class TestTimeStackItem < Test::Unit::TestCase
|
|
244
244
|
assert_equal time, Time.now
|
245
245
|
assert_equal time.nsec, Time.now.nsec if (Time.now.respond_to?(:nsec))
|
246
246
|
end
|
247
|
+
|
248
|
+
def test_time_with_different_timezone
|
249
|
+
require 'active_support/all'
|
250
|
+
|
251
|
+
Time.zone = "Tokyo"
|
252
|
+
t = Time.now
|
253
|
+
Timecop.freeze(t) do
|
254
|
+
assert_times_effectively_equal t, Time.now
|
255
|
+
end
|
256
|
+
end
|
247
257
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: timecop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.9
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Travis Jeffery
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: A gem providing "time travel" and "time freezing" capabilities, making it dead simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call.
|
16
16
|
email: travisjeffery@gmail.com
|