timecop 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -52,7 +52,9 @@ class Timecop
52
52
 
53
53
  def time(time_klass = Time) #:nodoc:
54
54
  begin
55
- time = time_klass.at(@time)
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
@@ -1,3 +1,3 @@
1
1
  class Timecop
2
- VERSION = "0.5.8"
2
+ VERSION = "0.5.9"
3
3
  end
@@ -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.8
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-08 00:00:00.000000000 Z
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