1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
Yusuke Endoh 2020-03-29 10:06:53 +09:00
parent 6379c6af4d
commit 87aebecdc2
3 changed files with 7 additions and 7 deletions

View file

@ -92,17 +92,17 @@ describe "Time#-" do
it "preserves time zone" do
time_with_zone = Time.now.utc
time_with_zone.zone.should == (time_with_zone - 60*60).zone
time_with_zone.zone.should == (time_with_zone - 1).zone
time_with_zone = Time.now
time_with_zone.zone.should == (time_with_zone - 60*60).zone
time_with_zone.zone.should == (time_with_zone - 1).zone
end
ruby_version_is "2.6" do
context "zone is a timezone object" do
it "preserves time zone" do
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 60*60
time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 1
time.zone.should == zone
end

View file

@ -50,17 +50,17 @@ describe "Time#+" do
it "preserves time zone" do
time_with_zone = Time.now.utc
time_with_zone.zone.should == (time_with_zone + 60*60).zone
time_with_zone.zone.should == (time_with_zone + 1).zone
time_with_zone = Time.now
time_with_zone.zone.should == (time_with_zone + 60*60).zone
time_with_zone.zone.should == (time_with_zone + 1).zone
end
ruby_version_is "2.6" do
context "zone is a timezone object" do
it "preserves time zone" do
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
time = Time.new(2012, 1, 1, 12, 0, 0, zone) + 60*60
time = Time.new(2012, 1, 1, 12, 0, 0, zone) + 1
time.zone.should == zone
end

View file

@ -30,7 +30,7 @@ describe "Time#succ" do
context "zone is a timezone object" do
it "preserves time zone" do
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 60*60
time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 1
time.zone.should == zone
end