time-warp 1.0.8 → 1.0.9

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.
@@ -0,0 +1,13 @@
1
+ require 'date'
2
+
3
+ # Extend Date class to generate 'today' from modified Time.now
4
+ Date.class_eval do
5
+ class << self
6
+
7
+ def today
8
+ Time.now.to_date
9
+ end
10
+
11
+ end
12
+ end
13
+
@@ -0,0 +1,12 @@
1
+ require 'date'
2
+
3
+ # Extend DateTime class to generate 'now' from modified Time.now
4
+ DateTime.class_eval do
5
+ class << self
6
+
7
+ def now
8
+ Time.now.to_datetime
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ ##
2
+ # Extend Time class to offset the time that 'now' returns. This
3
+ # provides the opening to "warp time" for any tests checking for
4
+ # time-based limitations. Perhaps one needs to check hourly
5
+ # limits, common time borders like midnight, etc.
6
+ if !Time.respond_to?(:real_now) # assures there is no infinite looping when aliasing #now
7
+ Time.class_eval do
8
+ class << self
9
+ attr_accessor :testing_offset
10
+
11
+ alias_method :real_now, :now
12
+ def now
13
+ real_now - testing_offset
14
+ end
15
+ alias_method :new, :now
16
+
17
+ end
18
+ end
19
+ end
20
+ Time.testing_offset = 0
data/lib/core_ext.rb CHANGED
@@ -1,20 +1,3 @@
1
- ##
2
- # Extend Time class to offset the time that 'now' returns. This
3
- # provides the opening to "warp time" for any tests checking for
4
- # time-based limitations. Perhaps one needs to check hourly
5
- # limits, common time borders like midnight, etc.
6
- if !Time.respond_to?(:real_now) # assures there is no infinite looping when aliasing #now
7
- Time.class_eval do
8
- class << self
9
- attr_accessor :testing_offset
10
-
11
- alias_method :real_now, :now
12
- def now
13
- real_now - testing_offset
14
- end
15
- alias_method :new, :now
16
-
17
- end
18
- end
19
- end
20
- Time.testing_offset = 0
1
+ require File.join File.dirname(__FILE__), 'core_ext/time'
2
+ require File.join File.dirname(__FILE__), 'core_ext/date'
3
+ require File.join File.dirname(__FILE__), 'core_ext/date_time'
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
1
+ require "./test/test_helper"
2
2
 
3
3
  class TimeWarpTest < Test::Unit::TestCase
4
4
  def test_test_unit_test_case_should_respond_to_pretend_now_is
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time-warp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 8
10
- version: 1.0.8
9
+ - 9
10
+ version: 1.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Barry Hess
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-15 00:00:00 -05:00
19
- default_executable:
18
+ date: 2011-11-09 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
21
  description: TimeWarp is a ruby library for manipulating times in automated tests.
@@ -31,13 +30,15 @@ files:
31
30
  - MIT-LICENSE
32
31
  - Rakefile
33
32
  - README.md
33
+ - lib/core_ext/time.rb
34
+ - lib/core_ext/date.rb
35
+ - lib/core_ext/date_time.rb
34
36
  - lib/core_ext.rb
35
37
  - lib/time_warp.rb
36
38
  - lib/time-warp.rb
37
39
  - tasks/time_warp_tasks.rake
38
40
  - test/test_helper.rb
39
41
  - test/time_warp_test.rb
40
- has_rdoc: true
41
42
  homepage: http://github.com/harvesthq/time-warp
42
43
  licenses: []
43
44
 
@@ -67,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
68
  requirements: []
68
69
 
69
70
  rubyforge_project:
70
- rubygems_version: 1.5.0
71
+ rubygems_version: 1.8.9
71
72
  signing_key:
72
73
  specification_version: 3
73
74
  summary: Warp time in your tests