timecop 0.4.1 → 0.4.3

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/History.rdoc CHANGED
@@ -1,3 +1,13 @@
1
+ === 0.4.1 / 2012-07-27
2
+
3
+ * Maintenance
4
+ * Mock Time#new the same as Time#now since they're synonyms
5
+ * Set default arg in parsing to 2000
6
+ * Time.freeze defaults to Time#now
7
+ * Use Time#parse is available to parse Time's given as strings
8
+ * Add ActiveSupport Time.zone support
9
+ * Stop DateTime from losing precision after traveling
10
+
1
11
  === 0.3.5 / 2010-06-07
2
12
 
3
13
  * Maintenance
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 1
2
+ :patch: 3
3
3
  :major: 0
4
4
  :minor: 4
@@ -17,7 +17,17 @@ class Time #:nodoc:
17
17
 
18
18
  # Alias now to now_with_mock_time
19
19
  alias_method :now, :now_with_mock_time
20
- alias_method :new, :now
20
+
21
+ alias_method :new_without_mock_time, :new
22
+ def new_with_mock_time *args
23
+ if args.size > 0
24
+ new_without_mock_time *args
25
+ else
26
+ now
27
+ end
28
+ end
29
+
30
+ alias_method :new, :new_with_mock_time
21
31
  end
22
32
  end
23
33
 
@@ -99,7 +99,7 @@ class Timecop
99
99
  elsif arg.nil?
100
100
  Time.now
101
101
  else
102
- if Time.respond_to?(:parse)
102
+ if Time.respond_to?(:parse) && arg.is_a?(String)
103
103
  Time.parse(arg)
104
104
  else
105
105
  # we'll just assume it's a list of y/m/d/h/m/s
@@ -19,6 +19,18 @@ class TestTimeStackItem < Test::Unit::TestCase
19
19
  assert_equal min, stack_item.min
20
20
  assert_equal s, stack_item.sec
21
21
  end
22
+
23
+ def test_new_with_time_and_arguments
24
+ t = Time.new(2012, 7, 28, 20, 0)
25
+ y, m, d, h, min, s = t.year, t.month, t.day, t.hour, t.min, t.sec
26
+ stack_item = Timecop::TimeStackItem.new(:freeze, t)
27
+ assert_equal y, stack_item.year
28
+ assert_equal m, stack_item.month
29
+ assert_equal d, stack_item.day
30
+ assert_equal h, stack_item.hour
31
+ assert_equal min, stack_item.min
32
+ assert_equal s, stack_item.sec
33
+ end
22
34
 
23
35
  def test_new_with_datetime_now
24
36
  t = DateTime.now
@@ -165,6 +177,11 @@ class TestTimeStackItem < Test::Unit::TestCase
165
177
  Timecop.freeze(date)
166
178
  end
167
179
 
180
+ def test_parse_only_string_with_active_support
181
+ Time.expects(:parse).never
182
+ Timecop.freeze(2011, 01, 02, hour=0, minute=0, second=0)
183
+ end
184
+
168
185
  def test_integration_with_rails_time_zone
169
186
  time = Time.now
170
187
  def time.in_time_zone
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.1
4
+ version: 0.4.3
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-06-27 00:00:00.000000000Z
13
+ date: 2012-06-28 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.10
61
+ rubygems_version: 1.8.19
62
62
  signing_key:
63
63
  specification_version: 3
64
64
  summary: A gem providing "time travel" and "time freezing" capabilities, making it
@@ -70,3 +70,4 @@ test_files:
70
70
  - test/timecop_test.rb
71
71
  - test/timecop_without_date_test.rb
72
72
  - test/timecop_without_date_but_with_time_test.rb
73
+ has_rdoc: