timecop 0.7.0 → 0.7.1
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_extensions.rb +6 -1
- data/lib/timecop/version.rb +1 -1
- data/test/test_helper.rb +5 -3
- data/test/timecop_test.rb +11 -0
- metadata +8 -6
- checksums.yaml +0 -7
@@ -43,7 +43,12 @@ class Date #:nodoc:
|
|
43
43
|
|
44
44
|
alias_method :strptime_without_mock_date, :strptime
|
45
45
|
|
46
|
-
def strptime_with_mock_date(str, fmt)
|
46
|
+
def strptime_with_mock_date(str = '-4712-01-01', fmt = '%F', start = Date::ITALY)
|
47
|
+
unless start == Date::ITALY
|
48
|
+
raise ArgumentError, "Timecop's #{self}::#{__method__} only " +
|
49
|
+
"supports Date::ITALY for the start argument."
|
50
|
+
end
|
51
|
+
|
47
52
|
Time.strptime(str, fmt).to_date
|
48
53
|
end
|
49
54
|
|
data/lib/timecop/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -24,11 +24,13 @@ class Test::Unit::TestCase
|
|
24
24
|
assert !times_effectively_equal(time1, time2, seconds_interval), "#{msg}: time1 = #{time1.to_s}, time2 = #{time2.to_s}"
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
# Gets the local offset (supplied by ENV['TZ'] or your computer's clock)
|
28
|
+
# At the given timestamp, or Time.now if not time is given.
|
29
|
+
def local_offset(time = Time.now)
|
30
|
+
Time.at(time.to_i).to_datetime.offset
|
29
31
|
end
|
30
32
|
|
31
|
-
TIMEZONES = ["Europe/Paris", "UTC", "
|
33
|
+
TIMEZONES = ["Europe/Paris", "UTC", "America/Chicago"]
|
32
34
|
|
33
35
|
def each_timezone
|
34
36
|
old_tz = ENV["TZ"]
|
data/test/timecop_test.rb
CHANGED
@@ -249,6 +249,11 @@ class TestTimecop < Test::Unit::TestCase
|
|
249
249
|
each_timezone do
|
250
250
|
t = DateTime.parse("2009-10-11 00:38:00 +0200")
|
251
251
|
Timecop.freeze(t) do
|
252
|
+
if ENV['TZ'] == 'UTC'
|
253
|
+
assert_equal(local_offset, 0, "Local offset not be zero for #{ENV['TZ']}")
|
254
|
+
else
|
255
|
+
assert_not_equal(local_offset, 0, "Local offset should not be zero for #{ENV['TZ']}")
|
256
|
+
end
|
252
257
|
assert_equal local_offset, DateTime.now.offset, "Failed for timezone: #{ENV['TZ']}"
|
253
258
|
end
|
254
259
|
end
|
@@ -489,6 +494,12 @@ class TestTimecop < Test::Unit::TestCase
|
|
489
494
|
end
|
490
495
|
end
|
491
496
|
|
497
|
+
def test_date_strptime_without_specifying_format
|
498
|
+
Timecop.freeze(Time.new(1984,2,28)) do
|
499
|
+
assert_equal Date.strptime('1999-04-14'), Date.new(1999, 4, 14)
|
500
|
+
end
|
501
|
+
end
|
502
|
+
|
492
503
|
private
|
493
504
|
|
494
505
|
def with_safe_mode(enabled=true)
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timecop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Travis Jeffery
|
@@ -9,7 +10,7 @@ authors:
|
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2013-
|
13
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
13
14
|
dependencies: []
|
14
15
|
description: A gem providing "time travel" and "time freezing" capabilities, making
|
15
16
|
it dead simple to test time-dependent code. It provides a unified method to mock
|
@@ -38,25 +39,26 @@ files:
|
|
38
39
|
homepage: https://github.com/travisjeffery/timecop
|
39
40
|
licenses:
|
40
41
|
- MIT
|
41
|
-
metadata: {}
|
42
42
|
post_install_message:
|
43
43
|
rdoc_options:
|
44
44
|
- --charset=UTF-8
|
45
45
|
require_paths:
|
46
46
|
- lib
|
47
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
48
49
|
requirements:
|
49
|
-
- - '>='
|
50
|
+
- - ! '>='
|
50
51
|
- !ruby/object:Gem::Version
|
51
52
|
version: 1.9.2
|
52
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
53
55
|
requirements:
|
54
|
-
- - '>='
|
56
|
+
- - ! '>='
|
55
57
|
- !ruby/object:Gem::Version
|
56
58
|
version: '0'
|
57
59
|
requirements: []
|
58
60
|
rubyforge_project: timecop
|
59
|
-
rubygems_version:
|
61
|
+
rubygems_version: 1.8.23
|
60
62
|
signing_key:
|
61
63
|
specification_version: 3
|
62
64
|
summary: A gem providing "time travel" and "time freezing" capabilities, making it
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: a736f9ef7fd96e85e0575f736c0a507095012f41
|
4
|
-
data.tar.gz: c9819e7dca7ace18be6d27445538a0c8a0a36511
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 5f58a4a57151a9fa501ca0dfbcd960ac0f12ccc0bee9a37198599f71fb9dd2b1ffa9781805cd8187ff2901992ea3df107845417eff4f9609b0ff6a6bd9f71810
|
7
|
-
data.tar.gz: 674f4a2d227d6aacbe0d8c4920c12ee9cd44597157b92fe16bafa1d4ed5839a3a61af66760f66144b7dc1df3a8ef07a6bc2a3a1aa283c7ca98ef2702443318d1
|