vandrijevik-with_time_frozen_at 1.0 → 1.0.1
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/README.markdown +33 -0
- data/with_time_frozen_at.gemspec +3 -3
- data/with_time_frozen_at.rb +1 -1
- data/with_time_frozen_at_test.rb +8 -0
- metadata +3 -3
- data/README.rdoc +0 -22
data/README.markdown
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
WithTimeFrozenAt
|
2
|
+
================
|
3
|
+
|
4
|
+
`with_time_frozen_at` makes time-sensitive testing using Test::Unit in Ruby super-easy!
|
5
|
+
|
6
|
+
How, you ask?
|
7
|
+
-------------
|
8
|
+
|
9
|
+
require 'test/unit'
|
10
|
+
require 'with_time_frozen_at'
|
11
|
+
|
12
|
+
class TimeSensitiveTest < Test::Unit::TestCase
|
13
|
+
def test_that_something_happens_at_this_exact_time
|
14
|
+
expected_time = Time.local(1984, 5, 15)
|
15
|
+
|
16
|
+
with_time_frozen_at expected_time do |time|
|
17
|
+
assert_equal expected_time, Time.now
|
18
|
+
assert_equal expected_time, time
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Inside the block you pass to `with_time_frozen_at`, `Time.now` returns the time that you specified in the call. This time is also passed as a block argument for your convenience.
|
24
|
+
|
25
|
+
After the block is executed, `Time.now` is restored to its original behavior for that squeaky-clean feeling (and for being able to tell the current time)!
|
26
|
+
|
27
|
+
Credits
|
28
|
+
-------
|
29
|
+
|
30
|
+
This version of `with_time_frozen_at` was inspired by the variant that was written by the authors in 2008. That implementation may have been slightly different and depended on Rails. This one does not.
|
31
|
+
|
32
|
+
----
|
33
|
+
Copyright (c) Vladimir Andrijevik and Dan Hodos, released under the MIT license
|
data/with_time_frozen_at.gemspec
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = %q{with_time_frozen_at}
|
5
|
-
spec.version = "1.0"
|
5
|
+
spec.version = "1.0.1"
|
6
6
|
|
7
7
|
spec.authors = ["Vladimir Andrijevik", "Dan Hodos"]
|
8
|
-
spec.date = %q{2009-06-
|
8
|
+
spec.date = %q{2009-06-12}
|
9
9
|
spec.description = %q{with_time_frozen_at makes writing time-sensitive tests in Ruby super easy.}
|
10
10
|
spec.email = %q{vladimir@andrijevik.net}
|
11
|
-
spec.files = ["README.
|
11
|
+
spec.files = ["README.markdown", "with_time_frozen_at.gemspec", "with_time_frozen_at.rb"]
|
12
12
|
spec.homepage = %q{http://github.com/vandrijevik/with_time_frozen_at/}
|
13
13
|
spec.require_path = "."
|
14
14
|
spec.summary = %q{a helper for writing time-sensitive tests in Ruby}
|
data/with_time_frozen_at.rb
CHANGED
data/with_time_frozen_at_test.rb
CHANGED
@@ -18,6 +18,14 @@ class WithTimeFrozenAtTestCase < Test::Unit::TestCase
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def test_freezes_time_now_to_return_specified_time
|
22
|
+
expected_time = Time.local(2009, 6, 10, 22, 19)
|
23
|
+
|
24
|
+
with_time_frozen_at expected_time do |time|
|
25
|
+
assert_equal expected_time, Time.now
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
21
29
|
def test_defines_now_with_freeze_method_on_time
|
22
30
|
with_time_frozen_at Time.local(2009) do |time|
|
23
31
|
assert_respond_to Time, :now_with_freeze
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vandrijevik-with_time_frozen_at
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Andrijevik
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-06-
|
13
|
+
date: 2009-06-12 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -23,7 +23,7 @@ extensions: []
|
|
23
23
|
extra_rdoc_files: []
|
24
24
|
|
25
25
|
files:
|
26
|
-
- README.
|
26
|
+
- README.markdown
|
27
27
|
- with_time_frozen_at.gemspec
|
28
28
|
- with_time_frozen_at.rb
|
29
29
|
has_rdoc: false
|
data/README.rdoc
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
= HasPhoneNumber
|
2
|
-
|
3
|
-
with_time_frozen at is a testing helper that makes time-sensitive testing easy!
|
4
|
-
|
5
|
-
== How, you ask?
|
6
|
-
|
7
|
-
class TimeSensitiveTest < Test::Unit::TestCase
|
8
|
-
def test_that_something_happens_at_this_exact_time
|
9
|
-
expected_time = Time.local(1984, 5, 15)
|
10
|
-
|
11
|
-
with_time_frozen_at expected_time do |time|
|
12
|
-
assert_equal expected_time, Time.now
|
13
|
-
assert_equal expected_time, time
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
Inside the block you pass to with_time_frozen_at, Time.now returns the time that you specified in the call. This time is also passed as a block argument for your convenience.
|
19
|
-
|
20
|
-
== Credits
|
21
|
-
|
22
|
-
This version of with_time_frozen_at was inspired by the variant that was written by the authors in 2008. That implementation may have been slightly different and depended on Rails. This one does not.
|