timecop 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/timecop/time_extensions.rb +11 -1
- data/lib/timecop/timecop.rb +1 -1
- data/lib/timecop/version.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/test/timecop_test.rb +11 -33
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 778eafd7d7e50dcf0aa223c181fdc6155955ecd2ab47abf996204dddec6362d5
|
4
|
+
data.tar.gz: 4e54ef041daff39c88d6363a2de8843bfaa9ce44bdc1f515f1c7d236ff15b689
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2caa5c9934809e05002b813b5907c0761886c937444b769531b13d19e443f9a73756ae4713569db03e4f75f20b7563550813cd1e3b3026f26ad8e3fd74cfd25
|
7
|
+
data.tar.gz: a984ade8c2067409acb19b65f85d042d9208fa31df66a38c21787e741ba2cb24fc87946fa11609bb2f62fdbd7bc7bb9fe195034ed6dcd5c152bd457f1b1638dd
|
@@ -56,8 +56,18 @@ class Date #:nodoc:
|
|
56
56
|
Date.new(year, mon, d[:mday])
|
57
57
|
elsif d[:wday]
|
58
58
|
Date.new(year, mon, now.mday) + (d[:wday] - now.wday)
|
59
|
+
elsif d[:yday]
|
60
|
+
Date.new(year).next_day(d[:yday] - 1)
|
61
|
+
elsif d[:cwyear] && d[:cweek]
|
62
|
+
if d[:cwday]
|
63
|
+
Date.commercial(d[:cwyear], d[:cweek], d[:cwday])
|
64
|
+
else
|
65
|
+
Date.commercial(d[:cwyear], d[:cweek])
|
66
|
+
end
|
67
|
+
elsif d[:seconds]
|
68
|
+
Time.at(d[:seconds]).to_date
|
59
69
|
else
|
60
|
-
Date.new(year, mon
|
70
|
+
Date.new(year, mon)
|
61
71
|
end
|
62
72
|
end
|
63
73
|
|
data/lib/timecop/timecop.rb
CHANGED
data/lib/timecop/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/timecop_test.rb
CHANGED
@@ -533,38 +533,6 @@ class TestTimecop < Minitest::Test
|
|
533
533
|
end
|
534
534
|
end
|
535
535
|
|
536
|
-
def test_date_strptime_without_year
|
537
|
-
Timecop.freeze(Time.new(1984,2,28)) do
|
538
|
-
assert_equal Date.strptime('04-14', '%m-%d'), Date.new(1984, 4, 14)
|
539
|
-
end
|
540
|
-
end
|
541
|
-
|
542
|
-
def test_date_strptime_without_specifying_format
|
543
|
-
Timecop.freeze(Time.new(1984,2,28)) do
|
544
|
-
assert_equal Date.strptime('1999-04-14'), Date.new(1999, 4, 14)
|
545
|
-
end
|
546
|
-
end
|
547
|
-
|
548
|
-
def test_date_strptime_with_day_of_week
|
549
|
-
Timecop.freeze(Time.new(1984,2,28)) do
|
550
|
-
assert_equal Date.strptime('Thursday', '%A'), Date.new(1984, 3, 1)
|
551
|
-
assert_equal Date.strptime('Monday', '%A'), Date.new(1984, 2, 27)
|
552
|
-
end
|
553
|
-
end
|
554
|
-
|
555
|
-
def test_date_strptime_with_invalid_date
|
556
|
-
begin
|
557
|
-
Date.strptime('', '%Y-%m-%d')
|
558
|
-
rescue ArgumentError => e
|
559
|
-
assert_equal 'invalid date', e.message
|
560
|
-
end
|
561
|
-
end
|
562
|
-
|
563
|
-
def test_ancient_strptime
|
564
|
-
ancient = Date.strptime('11-01-08', '%Y-%m-%d').strftime
|
565
|
-
assert_equal '0011-01-08', ancient # Failed before fix to strptime_with_mock_date
|
566
|
-
end
|
567
|
-
|
568
536
|
def test_frozen_after_freeze
|
569
537
|
Timecop.freeze
|
570
538
|
assert Timecop.frozen?
|
@@ -582,7 +550,7 @@ class TestTimecop < Minitest::Test
|
|
582
550
|
assert !Timecop.frozen?
|
583
551
|
end
|
584
552
|
|
585
|
-
def
|
553
|
+
def test_thread_safe_timecop_in_parallel
|
586
554
|
Timecop.thread_safe = true
|
587
555
|
date = Time.local(2011, 01, 02)
|
588
556
|
thread = Thread.new do
|
@@ -599,6 +567,16 @@ class TestTimecop < Minitest::Test
|
|
599
567
|
Timecop.thread_safe = false
|
600
568
|
end
|
601
569
|
|
570
|
+
def test_thread_safe_timecop_returns_after_block
|
571
|
+
Timecop.thread_safe = true
|
572
|
+
date = Time.local(2017, 10, 8)
|
573
|
+
|
574
|
+
Timecop.freeze(date) { }
|
575
|
+
assert Time.now != date
|
576
|
+
ensure
|
577
|
+
Timecop.thread_safe = false
|
578
|
+
end
|
579
|
+
|
602
580
|
private
|
603
581
|
|
604
582
|
def with_safe_mode(enabled=true)
|
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.9.
|
4
|
+
version: 0.9.3
|
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: 2021-02-07 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
|
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
requirements: []
|
57
|
-
rubygems_version: 3.
|
57
|
+
rubygems_version: 3.0.8
|
58
58
|
signing_key:
|
59
59
|
specification_version: 3
|
60
60
|
summary: A gem providing "time travel" and "time freezing" capabilities, making it
|