timecop 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ === 0.5.4 / 2012-11-29
2
+
3
+ * Maintenance
4
+ * Fix usage with Ruby 1.8
5
+
1
6
  === 0.5.2 / 2012-09-20
2
7
 
3
8
  * Feature
@@ -42,6 +42,22 @@ Timecop.freeze(Date.today + 30) do
42
42
  end
43
43
  ```
44
44
 
45
+ You can mock the time for a set of tests easily via setup/teardown methods
46
+
47
+ ```ruby
48
+ describe "some set of tests to mock" do
49
+ before do
50
+ Timecop.freeze(Time.local(1990))
51
+ end
52
+
53
+ after do
54
+ Timecop.return
55
+ end
56
+
57
+ it "should do blah blah blah" {}
58
+ end
59
+ ```
60
+
45
61
  Set the time for the test environment of a rails app -- this is particularly
46
62
  helpful if your whole application is time-sensitive. It allows you to build
47
63
  your test data at a single point in time, and to move in/out of that time as
@@ -87,7 +103,7 @@ being able to simulate activity via subsequent calls to your application.
87
103
 
88
104
  ```ruby
89
105
  # seconds will now seem like hours
90
- Timecop.lens(3600)
106
+ Timecop.scale(3600)
91
107
  Time.now
92
108
  # => 2012-09-20 21:23:25 -0500
93
109
  # seconds later, hours have past it's gone from 9pm at night to 6am in the morning
@@ -67,4 +67,15 @@ if Object.const_defined?(:DateTime) && DateTime.respond_to?(:now)
67
67
  alias_method :now, :now_with_mock_time
68
68
  end
69
69
  end
70
+
71
+ # for ruby1.8
72
+ unless Time::public_instance_methods.include? :to_datetime
73
+ class DateTime
74
+ class << self
75
+ def now_without_mock_time
76
+ Time.now_without_mock_time.send(:to_datetime)
77
+ end
78
+ end
79
+ end
80
+ end
70
81
  end
@@ -1,3 +1,3 @@
1
1
  class Timecop
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
@@ -183,7 +183,7 @@ class TestTimeStackItem < Test::Unit::TestCase
183
183
  assert_equal nil, tsi.send(:travel_offset)
184
184
  end
185
185
 
186
- def test_set_scaling_factor_for_lens
186
+ def test_set_scaling_factor_for_scale
187
187
  t_now = Time.now
188
188
  t = Time.local(2009, 10, 1, 0, 0, 30)
189
189
  expected_offset = t - t_now
@@ -248,7 +248,7 @@ class TestTimecop < Test::Unit::TestCase
248
248
  end
249
249
  end
250
250
 
251
- def test_lensing_keeps_time_moving_at_an_accelerated_rate
251
+ def test_scaling_keeps_time_moving_at_an_accelerated_rate
252
252
  t = Time.local(2008, 10, 10, 10, 10, 10)
253
253
  Timecop.scale(4, t) do
254
254
  start = Time.now
metadata CHANGED
@@ -1,27 +1,34 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: timecop
3
- version: !ruby/object:Gem::Version
4
- version: 0.5.3
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 5
8
+ - 4
9
+ version: 0.5.4
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Travis Jeffery
9
13
  - John Trupiano
10
14
  autorequire:
11
15
  bindir: bin
12
16
  cert_chain: []
13
- date: 2012-09-20 00:00:00.000000000 Z
17
+
18
+ date: 2012-11-29 00:00:00 -05:00
19
+ default_executable:
14
20
  dependencies: []
15
- description: A gem providing "time travel" and "time freezing" capabilities, making
16
- it dead simple to test time-dependent code. It provides a unified method to mock
17
- Time.now, Date.today, and DateTime.now in a single call.
21
+
22
+ description: 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.
18
23
  email: travisjeffery@gmail.com
19
24
  executables: []
25
+
20
26
  extensions: []
21
- extra_rdoc_files:
27
+
28
+ extra_rdoc_files:
22
29
  - LICENSE
23
30
  - README.markdown
24
- files:
31
+ files:
25
32
  - History.rdoc
26
33
  - LICENSE
27
34
  - README.markdown
@@ -37,34 +44,37 @@ files:
37
44
  - test/timecop_test.rb
38
45
  - test/timecop_without_date_test.rb
39
46
  - test/timecop_without_date_but_with_time_test.rb
40
- homepage: http://github.com/jtrupiano/timecop
47
+ has_rdoc: true
48
+ homepage: https://github.com/travisjeffery/timecop
41
49
  licenses: []
50
+
42
51
  post_install_message:
43
- rdoc_options:
52
+ rdoc_options:
44
53
  - --charset=UTF-8
45
- require_paths:
54
+ require_paths:
46
55
  - lib
47
- required_ruby_version: !ruby/object:Gem::Requirement
48
- none: false
49
- requirements:
50
- - - ! '>='
51
- - !ruby/object:Gem::Version
52
- version: '0'
53
- required_rubygems_version: !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
56
- - - ! '>='
57
- - !ruby/object:Gem::Version
58
- version: '0'
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
69
+ version: "0"
59
70
  requirements: []
60
- rubyforge_project: johntrupiano
61
- rubygems_version: 1.8.23
71
+
72
+ rubyforge_project: timecop
73
+ rubygems_version: 1.3.6
62
74
  signing_key:
63
75
  specification_version: 3
64
- summary: A gem providing "time travel" and "time freezing" capabilities, making it
65
- dead simple to test time-dependent code. It provides a unified method to mock Time.now,
66
- Date.today, and DateTime.now in a single call.
67
- test_files:
76
+ 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.
77
+ test_files:
68
78
  - test/test_helper.rb
69
79
  - test/time_stack_item_test.rb
70
80
  - test/timecop_test.rb