quantum_leap 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - jruby-19mode
6
+ - rbx-19mode
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # QuantumLeap
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/mattonrails/quantum_leap.png?branch=master)](http://travis-ci.org/mattonrails/quantum_leap)
4
+
3
5
  Righting wrongs in your test suite with time travel!
4
6
 
5
7
  QuantumLeap lets you change the current time in your tests.
@@ -22,20 +24,26 @@ Or install it yourself as:
22
24
 
23
25
  ## Usage
24
26
 
25
- require 'quantum_leap'
26
-
27
- Quantum.leap(Time.new(1956, 9, 13, 15, 00))
27
+ Quantum.leap(Time.new(1956, 9, 13))
28
28
  sam.must_be_kind_of(Pilot)
29
29
  sam.must_win_baseball_game
30
30
  Quantum.leap_back
31
31
 
32
32
  Or with a block:
33
33
 
34
- Quantum.leap(Time.new(1974, 10, 24, 15, 00)) do
34
+ Quantum.leap(Time.new(1974, 10, 24)) do
35
35
  sam.must_be_kind_of(Boxer)
36
36
  sam.must_win_the_championship
37
37
  end
38
38
 
39
+ Defaults to Time.now without arguments:
40
+
41
+ Time.now
42
+ => 2012-05-31 21:25:34 -0400
43
+ Quantum.leap
44
+ Time.now
45
+ => 2012-05-31 21:25:36 -0400
46
+
39
47
  ## Contributing
40
48
 
41
49
  1. Fork it
@@ -1,3 +1,3 @@
1
1
  module QuantumLeap
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/quantum_leap.rb CHANGED
@@ -26,7 +26,7 @@ class << Time
26
26
  end
27
27
 
28
28
  class Quantum
29
- def self.leap(time)
29
+ def self.leap(time = Time.now)
30
30
  QuantumLeap.mock_current_time(time)
31
31
  return unless block_given?
32
32
  begin
data/quantum_leap.gemspec CHANGED
@@ -14,4 +14,6 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "quantum_leap"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = QuantumLeap::VERSION
17
+
18
+ gem.add_development_dependency("rake")
17
19
  end
data/spec/quantum_spec.rb CHANGED
@@ -9,31 +9,53 @@ describe Quantum do
9
9
 
10
10
  describe '.leap' do
11
11
  describe 'without a block' do
12
- let(:the_present) { Time.new }
13
- let(:the_past) { Time.new(1956, 9, 13, 15, 00) }
12
+ the_present = Time.new
13
+ the_past = Time.new(1956, 9, 13, 15, 00)
14
14
 
15
15
  it 'changes the current time' do
16
16
  Quantum.leap(the_past)
17
- Time.now.must_be_close_to(the_past)
17
+ Time.now.must_be_within_delta(the_past, 1)
18
18
  end
19
19
  end
20
20
 
21
21
  describe 'with a block' do
22
- let(:the_present) { Time.new }
23
- let(:the_past) { Time.new(1974, 10, 24, 15, 00) }
22
+ the_present = Time.new
23
+ the_past = Time.new(1974, 10, 24, 15, 00)
24
24
 
25
25
  it 'changes time only within the block' do
26
26
  Quantum.leap(the_past) do
27
- Time.now.must_be_close_to(the_past)
27
+ Time.now.must_be_within_delta(the_past, 1)
28
28
  end
29
29
  Time.now.must_be_within_delta(the_present, 1)
30
30
  end
31
31
  end
32
+
33
+ describe 'with no argument' do
34
+ describe 'without a block' do
35
+ the_present = Time.new
36
+
37
+ it 'defaults to the current time' do
38
+ Quantum.leap
39
+ Time.now.must_be_within_delta(the_present, 1)
40
+ end
41
+ end
42
+
43
+ describe 'with a block' do
44
+ the_present = Time.new
45
+
46
+ it 'changes time only within the block' do
47
+ Quantum.leap do
48
+ Time.now.must_be_within_delta(the_present, 1)
49
+ end
50
+ Time.now.must_be_within_delta(the_present, 1)
51
+ end
52
+ end
53
+ end
32
54
  end
33
55
 
34
56
  describe '.leap_back' do
35
- let(:the_present) { Time.new }
36
- let(:the_past) { Time.new(1972, 6, 15, 15, 00) }
57
+ the_present = Time.new
58
+ the_past = Time.new(1972, 6, 15, 15, 00)
37
59
 
38
60
  it 'returns to the present time' do
39
61
  Quantum.leap(the_past)
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.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,19 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-31 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-06-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &70187114188660 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70187114188660
14
25
  description: Righting wrongs in your test suite with time travel!
15
26
  email:
16
27
  - mattonrails@shortmail.com
@@ -20,6 +31,7 @@ extra_rdoc_files: []
20
31
  files:
21
32
  - .gitignore
22
33
  - .rbenv-version
34
+ - .travis.yml
23
35
  - Gemfile
24
36
  - LICENSE
25
37
  - README.md