quantum_leap 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +3 -0
- data/CONTRIBUTING.md +45 -0
- data/README.md +1 -8
- data/lib/quantum.rb +22 -0
- data/lib/quantum_leap.rb +4 -54
- data/lib/quantum_leap/accelerator.rb +28 -0
- data/lib/quantum_leap/core_ext/date.rb +6 -0
- data/lib/quantum_leap/core_ext/time.rb +4 -0
- data/lib/quantum_leap/version.rb +1 -1
- data/quantum_leap.gemspec +0 -1
- data/spec/spec_helper.rb +0 -1
- metadata +16 -12
- data/.rbenv-version +0 -1
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
I would love for the community to help me make `quantum_leap` the time mocking
|
4
|
+
gem we've collectively always wanted!
|
5
|
+
|
6
|
+
Here's all the information you'll need:
|
7
|
+
|
8
|
+
## GitHub Issues
|
9
|
+
|
10
|
+
Issues is an excellent feature! Leave any suggestions, feature requests and bug
|
11
|
+
reports there. I will try to address all as time allows.
|
12
|
+
|
13
|
+
If I haven't responded to your Issue within a reasonable timeframe, feel free
|
14
|
+
to ping me at <mattonrails@shortmail.com> or on
|
15
|
+
[Twitter](http://twitter.com/mattonrails).
|
16
|
+
|
17
|
+
## Trello Board
|
18
|
+
|
19
|
+
Check out the [Trello
|
20
|
+
board](https://trello.com/board/quantumleap/4fc55ee290d3e95063cfc925) to see
|
21
|
+
what features and enhancements are planned for QuantumLeap and what is
|
22
|
+
currently in process.
|
23
|
+
|
24
|
+
Anyone can view, comment on, or vote for cards on this board. If you would like
|
25
|
+
to be a member and collaborate on this board, let me know.
|
26
|
+
|
27
|
+
## Code
|
28
|
+
|
29
|
+
This is a **Ruby 1.9** gem meant to support **MRI**, **Rubinius** and
|
30
|
+
**JRuby**.
|
31
|
+
|
32
|
+
Changes to `quantum_leap` should not break on any of the supported Ruby
|
33
|
+
implementations. [Travis CI](http://travis-ci.org/#!/mattonrails/quantum_leap)
|
34
|
+
indicates the current build status on all three rubies.
|
35
|
+
|
36
|
+
QuantumLeap comes with a `MiniTest::Spec` test suite--the test framework built
|
37
|
+
into Ruby 1.9, with a little extra sugar.
|
38
|
+
|
39
|
+
1. Fork this project
|
40
|
+
2. Consider working in a topic branch (git checkout -b lazers)
|
41
|
+
3. Write your patch or new functionality
|
42
|
+
4. Please provide test coverage
|
43
|
+
5. Push to the branch (git push origin lazers)
|
44
|
+
6. Create new Pull Request
|
45
|
+
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# QuantumLeap
|
2
2
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/mattonrails/quantum_leap.png?branch=master)](http://travis-ci.org/mattonrails/quantum_leap)
|
4
|
+
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/mattonrails/quantum_leap)
|
4
5
|
|
5
6
|
Righting wrongs in your test suite with time travel!
|
6
7
|
|
@@ -35,11 +36,3 @@ Quantum.leap(Time.new(1974, 10, 24)) do
|
|
35
36
|
sam.must_win_the_championship
|
36
37
|
end
|
37
38
|
```
|
38
|
-
|
39
|
-
## Contributing
|
40
|
-
|
41
|
-
1. Fork it
|
42
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
44
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
-
5. Create new Pull Request
|
data/lib/quantum.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'quantum_leap'
|
2
|
+
|
3
|
+
class Quantum
|
4
|
+
INITIAL_LEAP = Time.new(1956, 9, 13, 15, 00)
|
5
|
+
|
6
|
+
def self.leap(time = INITIAL_LEAP)
|
7
|
+
QuantumLeap::Accelerator.mock_current_time(time)
|
8
|
+
if block_given?
|
9
|
+
begin
|
10
|
+
yield
|
11
|
+
ensure
|
12
|
+
QuantumLeap::Accelerator.reset
|
13
|
+
end
|
14
|
+
end
|
15
|
+
return Time.now
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.leap_back
|
19
|
+
QuantumLeap::Accelerator.reset
|
20
|
+
Time.now
|
21
|
+
end
|
22
|
+
end
|
data/lib/quantum_leap.rb
CHANGED
@@ -1,57 +1,7 @@
|
|
1
1
|
require 'quantum_leap/version'
|
2
|
-
require 'date'
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
require 'quantum_leap/core_ext/date'
|
4
|
+
require 'quantum_leap/core_ext/time'
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
def reset
|
12
|
-
@time_travel_offsets = []
|
13
|
-
end
|
14
|
-
|
15
|
-
def mock_current_time(new_time)
|
16
|
-
time_travel_offsets.push(Time.now - new_time)
|
17
|
-
end
|
18
|
-
|
19
|
-
def now
|
20
|
-
Time.really_now - time_travel_offsets.inject(0, :+)
|
21
|
-
end
|
22
|
-
|
23
|
-
def date
|
24
|
-
now.to_date
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class << Time
|
29
|
-
alias_method :really_now, :now
|
30
|
-
def now; QuantumLeap.now; end
|
31
|
-
end
|
32
|
-
|
33
|
-
class << Date
|
34
|
-
alias_method :really_today, :today
|
35
|
-
def today; QuantumLeap.date; end
|
36
|
-
end
|
37
|
-
|
38
|
-
class Quantum
|
39
|
-
INITIAL_LEAP = Time.new(1956, 9, 13, 15, 00)
|
40
|
-
|
41
|
-
def self.leap(time = INITIAL_LEAP)
|
42
|
-
QuantumLeap.mock_current_time(time)
|
43
|
-
if block_given?
|
44
|
-
begin
|
45
|
-
yield
|
46
|
-
ensure
|
47
|
-
QuantumLeap.reset
|
48
|
-
end
|
49
|
-
end
|
50
|
-
return Time.now
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.leap_back
|
54
|
-
QuantumLeap.reset
|
55
|
-
Time.now
|
56
|
-
end
|
57
|
-
end
|
6
|
+
require 'quantum_leap/accelerator'
|
7
|
+
require 'quantum'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'quantum_leap'
|
2
|
+
|
3
|
+
module QuantumLeap
|
4
|
+
module Accelerator
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def time_travel_offsets
|
8
|
+
@time_travel_offsets ||= []
|
9
|
+
end
|
10
|
+
|
11
|
+
def reset
|
12
|
+
@time_travel_offsets = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def mock_current_time(new_time)
|
16
|
+
time_travel_offsets.push(Time.now - new_time)
|
17
|
+
end
|
18
|
+
|
19
|
+
def now
|
20
|
+
Time.really_now - time_travel_offsets.inject(0, :+)
|
21
|
+
end
|
22
|
+
|
23
|
+
def date
|
24
|
+
now.to_date
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/lib/quantum_leap/version.rb
CHANGED
data/quantum_leap.gemspec
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quantum_leap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-05-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,18 +21,12 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: minitest-colorize
|
27
|
-
requirement: &70356085913680 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
none: false
|
29
26
|
requirements:
|
30
27
|
- - ! '>='
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: '0'
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70356085913680
|
36
30
|
description: Righting wrongs in your test suite with time travel!
|
37
31
|
email:
|
38
32
|
- mattonrails@shortmail.com
|
@@ -41,13 +35,17 @@ extensions: []
|
|
41
35
|
extra_rdoc_files: []
|
42
36
|
files:
|
43
37
|
- .gitignore
|
44
|
-
- .rbenv-version
|
45
38
|
- .travis.yml
|
39
|
+
- CONTRIBUTING.md
|
46
40
|
- Gemfile
|
47
41
|
- LICENSE
|
48
42
|
- README.md
|
49
43
|
- Rakefile
|
44
|
+
- lib/quantum.rb
|
50
45
|
- lib/quantum_leap.rb
|
46
|
+
- lib/quantum_leap/accelerator.rb
|
47
|
+
- lib/quantum_leap/core_ext/date.rb
|
48
|
+
- lib/quantum_leap/core_ext/time.rb
|
51
49
|
- lib/quantum_leap/version.rb
|
52
50
|
- quantum_leap.gemspec
|
53
51
|
- spec/quantum_spec.rb
|
@@ -64,15 +62,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
62
|
- - ! '>='
|
65
63
|
- !ruby/object:Gem::Version
|
66
64
|
version: '0'
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
hash: 781284437395688069
|
67
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
69
|
none: false
|
69
70
|
requirements:
|
70
71
|
- - ! '>='
|
71
72
|
- !ruby/object:Gem::Version
|
72
73
|
version: '0'
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
hash: 781284437395688069
|
73
77
|
requirements: []
|
74
78
|
rubyforge_project:
|
75
|
-
rubygems_version: 1.8.
|
79
|
+
rubygems_version: 1.8.23
|
76
80
|
signing_key:
|
77
81
|
specification_version: 3
|
78
82
|
summary: Lets you change the current time in your tests
|
data/.rbenv-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.9.3-p125
|