timecop 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/timecop/time_extensions.rb +3 -3
- data/lib/timecop/time_stack_item.rb +7 -7
- metadata +3 -3
data/VERSION.yml
CHANGED
@@ -4,7 +4,7 @@ class Time #:nodoc:
|
|
4
4
|
# Time we are behaving as
|
5
5
|
def mock_time
|
6
6
|
mocked_time_stack_item = Timecop.top_stack_item
|
7
|
-
mocked_time_stack_item.nil? ? nil : mocked_time_stack_item.time
|
7
|
+
mocked_time_stack_item.nil? ? nil : mocked_time_stack_item.time(self)
|
8
8
|
end
|
9
9
|
|
10
10
|
# Alias the original now
|
@@ -37,7 +37,7 @@ if Object.const_defined?(:Date) && Date.respond_to?(:today)
|
|
37
37
|
# Date we are behaving as
|
38
38
|
def mock_date
|
39
39
|
mocked_time_stack_item = Timecop.top_stack_item
|
40
|
-
mocked_time_stack_item.nil? ? nil : mocked_time_stack_item.date
|
40
|
+
mocked_time_stack_item.nil? ? nil : mocked_time_stack_item.date(self)
|
41
41
|
end
|
42
42
|
|
43
43
|
# Alias the original today
|
@@ -60,7 +60,7 @@ if Object.const_defined?(:DateTime) && DateTime.respond_to?(:now)
|
|
60
60
|
# Time we are behaving as
|
61
61
|
def mock_time
|
62
62
|
mocked_time_stack_item = Timecop.top_stack_item
|
63
|
-
mocked_time_stack_item.nil? ? nil : mocked_time_stack_item.datetime
|
63
|
+
mocked_time_stack_item.nil? ? nil : mocked_time_stack_item.datetime(self)
|
64
64
|
end
|
65
65
|
|
66
66
|
# Fake alias :now_without_mock_time :now
|
@@ -45,23 +45,23 @@ class Timecop
|
|
45
45
|
@travel_offset
|
46
46
|
end
|
47
47
|
|
48
|
-
def time #:nodoc:
|
48
|
+
def time(time_klass=Time) #:nodoc:
|
49
49
|
if travel_offset.nil?
|
50
|
-
@time.
|
50
|
+
time_klass.at( @time.to_f )
|
51
51
|
else
|
52
|
-
Time.now_without_mock_time + travel_offset
|
52
|
+
time_klass.at( ( Time.now_without_mock_time + travel_offset ).to_f )
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def date
|
57
|
-
time.
|
56
|
+
def date(date_klass=Date)
|
57
|
+
date_klass.jd( time.to_date.jd )
|
58
58
|
end
|
59
59
|
|
60
|
-
def datetime
|
60
|
+
def datetime(datetime_klass=DateTime)
|
61
61
|
# DateTime doesn't know about DST, so let's remove its presence
|
62
62
|
our_offset = utc_offset + dst_adjustment
|
63
63
|
fractions_of_a_second = time.to_f % 1
|
64
|
-
|
64
|
+
datetime_klass.new(year, month, day, hour, min, sec + fractions_of_a_second,
|
65
65
|
utc_offset_to_rational(our_offset))
|
66
66
|
end
|
67
67
|
|
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.
|
4
|
+
version: 0.4.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: A gem providing "time travel" and "time freezing" capabilities, making
|
16
16
|
it dead simple to test time-dependent code. It provides a unified method to mock
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project: johntrupiano
|
61
|
-
rubygems_version: 1.8.
|
61
|
+
rubygems_version: 1.8.10
|
62
62
|
signing_key:
|
63
63
|
specification_version: 3
|
64
64
|
summary: A gem providing "time travel" and "time freezing" capabilities, making it
|