timecop 0.8.0 → 0.8.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.
- checksums.yaml +4 -4
- data/Rakefile +9 -3
- data/lib/timecop/time_stack_item.rb +1 -1
- data/lib/timecop/version.rb +1 -1
- data/test/test_helper.rb +3 -7
- data/test/time_stack_item_test.rb +16 -4
- data/test/timecop_test.rb +3 -3
- data/test/timecop_without_date_but_with_time_test.rb +4 -6
- data/test/timecop_without_date_test.rb +3 -3
- metadata +9 -9
- data/test/run_tests.sh +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfc685225a22109f897b68e3174608a4b6a16def
|
4
|
+
data.tar.gz: 66aee6ccc9dfd424502c3f3f149c175af3fa3fbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac084a1428c7b528faa70aa321b1cb9db1f9f3f8eb45e4a94777f15b915662fc60ba9208091837903348348a1c902c109649aa7a471819cbec7ea1e0d8c1a377
|
7
|
+
data.tar.gz: 14082a5cba36b7f5238455d884025c5f9ce01ca0b81073f9b9860220286d13db10cce76b3da38465fb585976fd29782a1e0d81913d699814e4505790446e03b7
|
data/Rakefile
CHANGED
@@ -3,8 +3,6 @@ require 'bundler/gem_tasks'
|
|
3
3
|
require 'rake/testtask'
|
4
4
|
require 'rdoc/task'
|
5
5
|
|
6
|
-
$LOAD_PATH.unshift("lib")
|
7
|
-
|
8
6
|
Rake::RDocTask.new do |rdoc|
|
9
7
|
if File.exist?('VERSION')
|
10
8
|
version = File.read('VERSION')
|
@@ -21,7 +19,15 @@ Rake::RDocTask.new do |rdoc|
|
|
21
19
|
end
|
22
20
|
|
23
21
|
task :test do
|
24
|
-
|
22
|
+
failed = Dir["test/*_test.rb"].map do |test|
|
23
|
+
command = "ruby #{test}"
|
24
|
+
puts
|
25
|
+
puts command
|
26
|
+
command unless system(command)
|
27
|
+
end.compact
|
28
|
+
if failed.any?
|
29
|
+
abort "#{failed.count} Tests failed\n#{failed.join("\n")}"
|
30
|
+
end
|
25
31
|
end
|
26
32
|
|
27
33
|
desc 'Default: run tests'
|
@@ -101,7 +101,7 @@ class Timecop
|
|
101
101
|
time_klass.at(arg.to_time.to_f).getlocal
|
102
102
|
elsif Object.const_defined?(:Date) && arg.is_a?(Date)
|
103
103
|
time_klass.local(arg.year, arg.month, arg.day, 0, 0, 0)
|
104
|
-
elsif args.empty? && arg.kind_of?(Integer)
|
104
|
+
elsif args.empty? && (arg.kind_of?(Integer) || arg.kind_of?(Float))
|
105
105
|
Time.now + arg
|
106
106
|
elsif arg.nil?
|
107
107
|
Time.now
|
data/lib/timecop/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,16 +1,12 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'bundler/setup'
|
3
2
|
require 'minitest/autorun'
|
3
|
+
require 'minitest/rg'
|
4
4
|
|
5
5
|
$VERBOSE = true # enable ruby warnings
|
6
6
|
|
7
|
-
|
8
|
-
require 'mocha/setup'
|
9
|
-
rescue LoadError
|
10
|
-
require 'mocha'
|
11
|
-
end
|
7
|
+
require 'mocha/setup'
|
12
8
|
|
13
|
-
class Minitest::
|
9
|
+
class Minitest::Test
|
14
10
|
private
|
15
11
|
# Tests to see that two times are within the given distance,
|
16
12
|
# in seconds, from each other.
|
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'date'
|
2
|
-
|
3
|
-
require
|
4
|
-
|
2
|
+
require_relative "test_helper"
|
3
|
+
require 'timecop'
|
5
4
|
require 'active_support/all'
|
6
5
|
|
7
|
-
class TestTimeStackItem < Minitest::
|
6
|
+
class TestTimeStackItem < Minitest::Test
|
8
7
|
def teardown
|
9
8
|
Timecop.return
|
10
9
|
Time.zone = nil
|
@@ -87,6 +86,19 @@ class TestTimeStackItem < Minitest::Unit::TestCase
|
|
87
86
|
assert_equal s, stack_item.sec
|
88
87
|
end
|
89
88
|
|
89
|
+
def test_new_with_float
|
90
|
+
t = Time.now
|
91
|
+
y, m, d, h, min, s = t.year, t.month, t.day, t.hour, t.min, t.sec
|
92
|
+
stack_item = Timecop::TimeStackItem.new(:freeze, 0.0)
|
93
|
+
|
94
|
+
assert_equal y, stack_item.year
|
95
|
+
assert_equal m, stack_item.month
|
96
|
+
assert_equal d, stack_item.day
|
97
|
+
assert_equal h, stack_item.hour
|
98
|
+
assert_equal min, stack_item.min
|
99
|
+
assert_equal s, stack_item.sec
|
100
|
+
end
|
101
|
+
|
90
102
|
def test_new_with_individual_arguments
|
91
103
|
y, m, d, h, min, s = 2008, 10, 10, 10, 10, 10
|
92
104
|
stack_item = Timecop::TimeStackItem.new(:freeze, y, m, d, h, min, s)
|
data/test/timecop_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
require_relative "test_helper"
|
2
|
+
require 'timecop'
|
3
3
|
|
4
|
-
class TestTimecop < Minitest::
|
4
|
+
class TestTimecop < Minitest::Test
|
5
5
|
def teardown
|
6
6
|
Timecop.return
|
7
7
|
end
|
@@ -1,10 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class TestTimecopWithoutDateButWithTime < Minitest::Unit::TestCase
|
4
|
-
TIMECOP_LIB = File.join(File.dirname(__FILE__), '..', 'lib', 'timecop')
|
1
|
+
require_relative "test_helper"
|
2
|
+
require "time"
|
5
3
|
|
4
|
+
class TestTimecopWithoutDateButWithTime < Minitest::Test
|
6
5
|
def test_loads_properly_when_time_is_required_instead_of_date
|
7
|
-
require
|
8
|
-
require TIMECOP_LIB
|
6
|
+
require 'timecop'
|
9
7
|
end
|
10
8
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
require_relative "test_helper"
|
2
|
+
require 'timecop'
|
3
3
|
|
4
|
-
class TestTimecopWithoutDate < Minitest::
|
4
|
+
class TestTimecopWithoutDate < Minitest::Test
|
5
5
|
|
6
6
|
def setup
|
7
7
|
Object.send(:remove_const, :Date) if Object.const_defined?(:Date)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timecop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Jeffery
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-04-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A gem providing "time travel" and "time freezing" capabilities, making
|
15
15
|
it dead simple to test time-dependent code. It provides a unified method to mock
|
@@ -27,36 +27,35 @@ files:
|
|
27
27
|
- lib/timecop.rb
|
28
28
|
- lib/timecop/time_extensions.rb
|
29
29
|
- lib/timecop/time_stack_item.rb
|
30
|
-
- lib/timecop/version.rb
|
31
30
|
- lib/timecop/timecop.rb
|
32
|
-
-
|
31
|
+
- lib/timecop/version.rb
|
33
32
|
- test/test_helper.rb
|
34
33
|
- test/time_stack_item_test.rb
|
35
34
|
- test/timecop_test.rb
|
36
|
-
- test/timecop_without_date_test.rb
|
37
35
|
- test/timecop_without_date_but_with_time_test.rb
|
36
|
+
- test/timecop_without_date_test.rb
|
38
37
|
homepage: https://github.com/travisjeffery/timecop
|
39
38
|
licenses:
|
40
39
|
- MIT
|
41
40
|
metadata: {}
|
42
41
|
post_install_message:
|
43
42
|
rdoc_options:
|
44
|
-
- --charset=UTF-8
|
43
|
+
- "--charset=UTF-8"
|
45
44
|
require_paths:
|
46
45
|
- lib
|
47
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
47
|
requirements:
|
49
|
-
- -
|
48
|
+
- - ">="
|
50
49
|
- !ruby/object:Gem::Version
|
51
50
|
version: 1.9.2
|
52
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
52
|
requirements:
|
54
|
-
- -
|
53
|
+
- - ">="
|
55
54
|
- !ruby/object:Gem::Version
|
56
55
|
version: '0'
|
57
56
|
requirements: []
|
58
57
|
rubyforge_project: timecop
|
59
|
-
rubygems_version: 2.
|
58
|
+
rubygems_version: 2.4.5
|
60
59
|
signing_key:
|
61
60
|
specification_version: 3
|
62
61
|
summary: A gem providing "time travel" and "time freezing" capabilities, making it
|
@@ -68,3 +67,4 @@ test_files:
|
|
68
67
|
- test/timecop_test.rb
|
69
68
|
- test/timecop_without_date_test.rb
|
70
69
|
- test/timecop_without_date_but_with_time_test.rb
|
70
|
+
has_rdoc:
|