ruby-changes:60563
From: Yusuke <ko1@a...>
Date: Sun, 29 Mar 2020 10:08:50 +0900 (JST)
Subject: [ruby-changes:60563] 87aebecdc2 (master): spec/ruby/core/time/: Use near time for timezone test
https://git.ruby-lang.org/ruby.git/commit/?id=87aebecdc2 From 87aebecdc23d4da2130af586bafa360973cef479 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Sun, 29 Mar 2020 10:06:53 +0900 Subject: 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. diff --git a/spec/ruby/core/time/minus_spec.rb b/spec/ruby/core/time/minus_spec.rb index e0fbf94..65613d1 100644 --- a/spec/ruby/core/time/minus_spec.rb +++ b/spec/ruby/core/time/minus_spec.rb @@ -92,17 +92,17 @@ describe "Time#-" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/time/minus_spec.rb#L92 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 diff --git a/spec/ruby/core/time/plus_spec.rb b/spec/ruby/core/time/plus_spec.rb index 0a9984f..6c29baf 100644 --- a/spec/ruby/core/time/plus_spec.rb +++ b/spec/ruby/core/time/plus_spec.rb @@ -50,17 +50,17 @@ describe "Time#+" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/time/plus_spec.rb#L50 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 diff --git a/spec/ruby/core/time/succ_spec.rb b/spec/ruby/core/time/succ_spec.rb index e68e64b..532448a 100644 --- a/spec/ruby/core/time/succ_spec.rb +++ b/spec/ruby/core/time/succ_spec.rb @@ -30,7 +30,7 @@ describe "Time#succ" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/time/succ_spec.rb#L30 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/