timecop 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28306a2c78d6588f97b394b65bba1163a9a1cf4a
4
- data.tar.gz: c2323a791bb954e70a70b9595cb56135e54ff64d
3
+ metadata.gz: a736f9ef7fd96e85e0575f736c0a507095012f41
4
+ data.tar.gz: c9819e7dca7ace18be6d27445538a0c8a0a36511
5
5
  SHA512:
6
- metadata.gz: 5e445072106712764a97139527912b59ec29cb0e4a97b4a1203dd8c5d72aebea0788935ca56fec863285cb2d764f3312ad604f1d311fa51fcd4ea07a9bd4c8d8
7
- data.tar.gz: 6f690a4c4d944c7f3df343616bb4e78c707e0efaf8b9c102d71da2a72029bffb0d26dcd64dea856e59183c04cc98d5c0c5d5c7549892338dc823ba3d963968cc
6
+ metadata.gz: 5f58a4a57151a9fa501ca0dfbcd960ac0f12ccc0bee9a37198599f71fb9dd2b1ffa9781805cd8187ff2901992ea3df107845417eff4f9609b0ff6a6bd9f71810
7
+ data.tar.gz: 674f4a2d227d6aacbe0d8c4920c12ee9cd44597157b92fe16bafa1d4ed5839a3a61af66760f66144b7dc1df3a8ef07a6bc2a3a1aa283c7ca98ef2702443318d1
@@ -2,8 +2,8 @@
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/travisjeffery/timecop.png)](http://travis-ci.org/travisjeffery/timecop)
4
4
 
5
- - Source[http://github.com/travisjeffery/timecop]
6
- - Documentation[http://johntrupiano.rubyforge.org/timecop]
5
+ - [Source](http://github.com/travisjeffery/timecop)
6
+ - [Documentation](http://johntrupiano.rubyforge.org/timecop)
7
7
 
8
8
  ## DESCRIPTION
9
9
 
@@ -111,7 +111,6 @@ Time.now
111
111
  # => 2012-09-21 06:22:59 -0500
112
112
  ```
113
113
 
114
- <<<<<<< HEAD
115
114
  ### Timecop.safe_mode
116
115
 
117
116
  Safe mode forces you to use Timecop with the block syntax since it always puts time back the way it was. If you are running in safe mode and use Timecop without the block syntax `Timecop::SafeModeException` will be raised to tell the user they are not being safe.
@@ -1,4 +1,5 @@
1
1
  require 'date'
2
+ require 'time'
2
3
 
3
4
  class Time #:nodoc:
4
5
  class << self
@@ -39,6 +40,14 @@ class Date #:nodoc:
39
40
  end
40
41
 
41
42
  alias_method :today, :today_with_mock_date
43
+
44
+ alias_method :strptime_without_mock_date, :strptime
45
+
46
+ def strptime_with_mock_date(str, fmt)
47
+ Time.strptime(str, fmt).to_date
48
+ end
49
+
50
+ alias_method :strptime, :strptime_with_mock_date
42
51
  end
43
52
  end
44
53
 
@@ -51,7 +51,7 @@ class Timecop
51
51
 
52
52
  def time(time_klass = Time) #:nodoc:
53
53
  if @time.respond_to?(:in_time_zone)
54
- time = time_klass.at(@time.utc.to_r)
54
+ time = time_klass.at(@time.dup.utc.to_r)
55
55
  else
56
56
  time = time_klass.at(@time)
57
57
  end
@@ -1,3 +1,3 @@
1
1
  class Timecop
2
- VERSION = "0.6.3"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -249,6 +249,14 @@ class TestTimeStackItem < Test::Unit::TestCase
249
249
  end
250
250
  end
251
251
 
252
+ def test_freezing_a_time_leaves_timezone_intact
253
+ Time.zone = "Tokyo"
254
+ t = Time.now
255
+ t_dup = t.dup
256
+ Timecop.freeze(t) {}
257
+ assert_equal t_dup.zone, t.zone
258
+ end
259
+
252
260
  def test_freezing_a_time_with_zone_returns_proper_zones
253
261
  Time.zone = "Hawaii"
254
262
  t = ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1), ActiveSupport::TimeZone['Tokyo'])
@@ -483,6 +483,12 @@ class TestTimecop < Test::Unit::TestCase
483
483
  end
484
484
  end
485
485
 
486
+ def test_date_strptime_without_year
487
+ Timecop.freeze(Time.new(1984,2,28)) do
488
+ assert_equal Date.strptime('04-14', '%m-%d'), Date.new(1984, 4, 14)
489
+ end
490
+ end
491
+
486
492
  private
487
493
 
488
494
  def with_safe_mode(enabled=true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timecop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Jeffery
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-04 00:00:00.000000000 Z
12
+ date: 2013-11-29 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A gem providing "time travel" and "time freezing" capabilities, making
15
15
  it dead simple to test time-dependent code. It provides a unified method to mock