quantum_leap 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -2
- data/lib/quantum_leap/version.rb +1 -1
- data/lib/quantum_leap.rb +8 -0
- data/spec/quantum_spec.rb +13 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
Righting wrongs in your test suite with time travel!
|
4
4
|
|
5
|
-
QuantumLeap lets you change the current time in your tests.
|
6
|
-
|
5
|
+
QuantumLeap lets you change the current time in your tests.
|
6
|
+
|
7
|
+
I can't promise you'll meet any historical figures, however.
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
@@ -24,6 +25,7 @@ Or install it yourself as:
|
|
24
25
|
require 'quantum_leap'
|
25
26
|
|
26
27
|
Quantum.leap(Time.now + 60)
|
28
|
+
Quantum.leap_back
|
27
29
|
|
28
30
|
## Contributing
|
29
31
|
|
data/lib/quantum_leap/version.rb
CHANGED
data/lib/quantum_leap.rb
CHANGED
@@ -7,6 +7,10 @@ module QuantumLeap
|
|
7
7
|
@time_travel_offsets ||= []
|
8
8
|
end
|
9
9
|
|
10
|
+
def reset
|
11
|
+
@time_travel_offsets = []
|
12
|
+
end
|
13
|
+
|
10
14
|
def mock_current_time(new_time)
|
11
15
|
time_travel_offsets.push(Time.now - new_time)
|
12
16
|
end
|
@@ -25,4 +29,8 @@ class Quantum
|
|
25
29
|
def self.leap(time)
|
26
30
|
QuantumLeap.mock_current_time(time)
|
27
31
|
end
|
32
|
+
|
33
|
+
def self.leap_back
|
34
|
+
QuantumLeap.reset
|
35
|
+
end
|
28
36
|
end
|
data/spec/quantum_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'quantum_leap'
|
|
4
4
|
describe Quantum do
|
5
5
|
|
6
6
|
describe '.leap' do
|
7
|
-
the_past = Time.new(
|
7
|
+
the_past = Time.new(1956, 9, 13, 15, 00)
|
8
8
|
|
9
9
|
it 'changes the current time' do
|
10
10
|
Quantum.leap(the_past)
|
@@ -12,4 +12,16 @@ describe Quantum do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
describe '.leap_back' do
|
16
|
+
the_present = Time.new
|
17
|
+
the_past = Time.new(1972, 6, 15, 15, 00)
|
18
|
+
|
19
|
+
it 'returns to the present time' do
|
20
|
+
Quantum.leap(the_past)
|
21
|
+
Time.now.must_be_within_delta(the_past, 1)
|
22
|
+
Quantum.leap_back
|
23
|
+
Time.now.must_be_within_delta(the_present, 1)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
15
27
|
end
|