timecop 0.6.3 → 0.7.0
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.
- checksums.yaml +4 -4
- data/README.markdown +2 -3
- data/lib/timecop/time_extensions.rb +9 -0
- data/lib/timecop/time_stack_item.rb +1 -1
- data/lib/timecop/version.rb +1 -1
- data/test/time_stack_item_test.rb +8 -0
- data/test/timecop_test.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a736f9ef7fd96e85e0575f736c0a507095012f41
|
4
|
+
data.tar.gz: c9819e7dca7ace18be6d27445538a0c8a0a36511
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f58a4a57151a9fa501ca0dfbcd960ac0f12ccc0bee9a37198599f71fb9dd2b1ffa9781805cd8187ff2901992ea3df107845417eff4f9609b0ff6a6bd9f71810
|
7
|
+
data.tar.gz: 674f4a2d227d6aacbe0d8c4920c12ee9cd44597157b92fe16bafa1d4ed5839a3a61af66760f66144b7dc1df3a8ef07a6bc2a3a1aa283c7ca98ef2702443318d1
|
data/README.markdown
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
[](http://travis-ci.org/travisjeffery/timecop)
|
4
4
|
|
5
|
-
- Source
|
6
|
-
- Documentation
|
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
|
|
data/lib/timecop/version.rb
CHANGED
@@ -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'])
|
data/test/timecop_test.rb
CHANGED
@@ -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.
|
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-
|
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
|