timecop 0.3.4 → 0.3.5

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,4 +1,10 @@
1
- === 0.3.4 / unreleased (RC2 released 2009-11-28)
1
+ === 0.3.5 / 2010-06-07
2
+
3
+ * Maintenance
4
+ * Return a cloned time instance in order to support the destructive methods #gmt, #utc and #localtime
5
+ * Don't use full path requires where unnecessary
6
+
7
+ === 0.3.4 / 2009-12-07
2
8
 
3
9
  * Maintenance
4
10
  * Fix various timezone-related issues. Notably, when traveling to a DateTime
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 4
2
+ :patch: 5
3
3
  :major: 0
4
4
  :minor: 3
data/lib/timecop.rb CHANGED
@@ -1,2 +1 @@
1
- # Require Timecop
2
- require File.join(File.dirname(__FILE__), 'timecop', 'timecop')
1
+ require 'timecop/timecop'
@@ -47,7 +47,7 @@ class Timecop
47
47
 
48
48
  def time #:nodoc:
49
49
  if travel_offset.nil?
50
- @time
50
+ @time.clone
51
51
  else
52
52
  Time.now_without_mock_time + travel_offset
53
53
  end
@@ -106,8 +106,8 @@ class Timecop
106
106
 
107
107
  def compute_travel_offset
108
108
  return nil if mock_type == :freeze
109
- @time - Time.now_without_mock_time
109
+ time - Time.now_without_mock_time
110
110
  end
111
111
 
112
112
  end
113
- end
113
+ end
@@ -1,6 +1,6 @@
1
1
  require 'singleton'
2
- require File.join(File.dirname(__FILE__), 'time_extensions')
3
- require File.join(File.dirname(__FILE__), 'time_stack_item')
2
+ require 'timecop/time_extensions'
3
+ require 'timecop/time_stack_item'
4
4
 
5
5
  # Timecop
6
6
  # * Wrapper class for manipulating the extensions to the Time, Date, and DateTime objects
data/test/run_tests.sh CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/bin/sh
2
2
 
3
3
  echo "\033[1;81m Running test_time_stack_item...\033[0m"
4
- ruby test_time_stack_item.rb || (echo "FAILED!!!!!!!!!!!!")
4
+ ruby -I../lib test_time_stack_item.rb || (echo "FAILED!!!!!!!!!!!!")
5
5
 
6
6
  echo "\033[1;81m Running test_timecop_without_date...\033[0m"
7
- ruby test_timecop_without_date.rb || (echo "FAILED!!!!!!!!!!!!")
7
+ ruby -I../lib test_timecop_without_date.rb || (echo "FAILED!!!!!!!!!!!!")
8
8
 
9
9
  echo "\033[1;81m Running test_timecop_without_date_but_with_time...\033[0m"
10
- ruby test_timecop_without_date_but_with_time.rb || (echo "FAILED!!!!!!!!!!!!")
10
+ ruby -I../lib test_timecop_without_date_but_with_time.rb || (echo "FAILED!!!!!!!!!!!!")
11
11
 
12
12
  echo "\033[1;81m Running test_timecop...\033[0m"
13
- ruby test_timecop.rb || (echo "FAILED!!!!!!!!!!!!")
13
+ ruby -I../lib test_timecop.rb || (echo "FAILED!!!!!!!!!!!!")
data/test/test_timecop.rb CHANGED
@@ -209,6 +209,21 @@ class TestTimecop < Test::Unit::TestCase
209
209
  end
210
210
  end
211
211
  end
212
+
213
+ def test_destructive_methods_on_frozen_time
214
+ # Use any time zone other than UTC.
215
+ ENV['TZ'] = 'EST'
216
+
217
+ t = Time.local(2008, 10, 10, 10, 10, 10)
218
+ Timecop.freeze(t) do
219
+ assert !Time.now.utc?, "Time#local failed to return a time in the local time zone."
220
+
221
+ # #utc, #gmt, and #localtime are destructive methods.
222
+ Time.now.utc
223
+
224
+ assert !Time.now.utc?, "Failed to thwart destructive methods."
225
+ end
226
+ end
212
227
 
213
228
  def test_recursive_travel_maintains_each_context
214
229
  t = Time.local(2008, 10, 10, 10, 10, 10)
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timecop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ hash: 25
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 5
10
+ version: 0.3.5
5
11
  platform: ruby
6
12
  authors:
7
13
  - John Trupiano
@@ -9,7 +15,7 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-12-07 00:00:00 -05:00
18
+ date: 2010-06-07 00:00:00 -04:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
@@ -48,21 +54,27 @@ rdoc_options:
48
54
  require_paths:
49
55
  - lib
50
56
  required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ">="
53
60
  - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
54
64
  version: "0"
55
- version:
56
65
  required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
57
67
  requirements:
58
68
  - - ">="
59
69
  - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
60
73
  version: "0"
61
- version:
62
74
  requirements: []
63
75
 
64
76
  rubyforge_project: johntrupiano
65
- rubygems_version: 1.3.5
77
+ rubygems_version: 1.3.7
66
78
  signing_key:
67
79
  specification_version: 3
68
80
  summary: A gem providing "time travel" and "time freezing" capabilities, making it dead simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call.