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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e1bf57b28c2d86304d5ca7192fb44fab26457ea631ebe45d1361b4e8ad165e5
4
- data.tar.gz: cbd98da4611a74dda4c377a89b25a9e66be575fde9278663a36386857f0b80db
3
+ metadata.gz: 778eafd7d7e50dcf0aa223c181fdc6155955ecd2ab47abf996204dddec6362d5
4
+ data.tar.gz: 4e54ef041daff39c88d6363a2de8843bfaa9ce44bdc1f515f1c7d236ff15b689
5
5
  SHA512:
6
- metadata.gz: 5f3d6796ee0f520b1bcc6dfc3cd7251f8a9ae32b6079e29b7564418f9250da70bd3d39042c311d17e7f1507ff2a6522ece4a4160d6bb8170db820b6b60c9493d
7
- data.tar.gz: bc5600d477a487a23892ffed0a57511aa66dfb188b8b6600ff82194afe8b38921ed869fc184f15584be18f7b1f8a68bebe15b9f96ee0628bd2bde60302cb4fc5
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, now.mday)
70
+ Date.new(year, mon)
61
71
  end
62
72
  end
63
73
 
@@ -200,7 +200,7 @@ class Timecop
200
200
  begin
201
201
  yield stack_item.time
202
202
  ensure
203
- @stack.replace stack_backup
203
+ stack.replace stack_backup
204
204
  @safe = safe_backup
205
205
  end
206
206
  end
@@ -1,3 +1,3 @@
1
1
  class Timecop
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
data/test/test_helper.rb CHANGED
@@ -29,7 +29,7 @@ class Minitest::Test
29
29
  Time.at(time.to_i).to_datetime.offset
30
30
  end
31
31
 
32
- TIMEZONES = ["Europe/Paris", "UTC", "America/Chicago"]
32
+ TIMEZONES = ["Pacific/Midway", "Europe/Paris", "UTC", "America/Chicago"]
33
33
 
34
34
  def each_timezone
35
35
  old_tz = ENV["TZ"]
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 test_thread_safe_timecop
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.2
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: 2020-10-14 00:00:00.000000000 Z
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.1.4
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