Skip to content

Commit bce4f2b

Browse files
mameeregon
authored andcommitted
spec/ruby/core/time/: Use near time for timezone test
`time_with_zone.zone.should == (time_with_zone - 60*60).zone` fails when the time is immediately before the change of summer time. https://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable11s/ruby-master/log/20200328T232504Z.fail.html.gz ``` 1) Time#+ preserves time zone FAILED Expected "CET" == "CEST" to be truthy but was false ``` It is acceptable as it fails at most twice per year, but it would be good to use near time objects to reduce the possibility.
1 parent 8bb1921 commit bce4f2b

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

core/time/minus_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,17 @@
9292

9393
it "preserves time zone" do
9494
time_with_zone = Time.now.utc
95-
time_with_zone.zone.should == (time_with_zone - 60*60).zone
95+
time_with_zone.zone.should == (time_with_zone - 1).zone
9696

9797
time_with_zone = Time.now
98-
time_with_zone.zone.should == (time_with_zone - 60*60).zone
98+
time_with_zone.zone.should == (time_with_zone - 1).zone
9999
end
100100

101101
ruby_version_is "2.6" do
102102
context "zone is a timezone object" do
103103
it "preserves time zone" do
104104
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
105-
time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 60*60
105+
time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 1
106106

107107
time.zone.should == zone
108108
end

core/time/plus_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@
5050

5151
it "preserves time zone" do
5252
time_with_zone = Time.now.utc
53-
time_with_zone.zone.should == (time_with_zone + 60*60).zone
53+
time_with_zone.zone.should == (time_with_zone + 1).zone
5454

5555
time_with_zone = Time.now
56-
time_with_zone.zone.should == (time_with_zone + 60*60).zone
56+
time_with_zone.zone.should == (time_with_zone + 1).zone
5757
end
5858

5959
ruby_version_is "2.6" do
6060
context "zone is a timezone object" do
6161
it "preserves time zone" do
6262
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
63-
time = Time.new(2012, 1, 1, 12, 0, 0, zone) + 60*60
63+
time = Time.new(2012, 1, 1, 12, 0, 0, zone) + 1
6464

6565
time.zone.should == zone
6666
end

core/time/succ_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
context "zone is a timezone object" do
3131
it "preserves time zone" do
3232
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
33-
time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 60*60
33+
time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 1
3434

3535
time.zone.should == zone
3636
end

0 commit comments

Comments
 (0)