[前][次][番号順一覧][スレッド一覧]

ruby-changes:58190

From: Nobuyoshi <ko1@a...>
Date: Thu, 10 Oct 2019 14:52:19 +0900 (JST)
Subject: [ruby-changes:58190] 6f522455bf (master): [rubygems/rubygems] Do not compare with unreliable Gem::Specification::TODAY

https://git.ruby-lang.org/ruby.git/commit/?id=6f522455bf

From 6f522455bf801acefcd2ade0b2e4a2fef3cb70a4 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 7 Oct 2019 00:12:18 +0900
Subject: [rubygems/rubygems] Do not compare with unreliable
 Gem::Specification::TODAY

https://gist.github.com/ko1/a88834d744a0682711dab53fd9015a04#file-brlog-trunk-nopara-20191005-235153-L393-L472

https://github.com/rubygems/rubygems/commit/707408d8e7

diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index c10aa99..a1c3961 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -74,6 +74,12 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L74
     end
   end
 
+  def assert_date(date)
+    assert_kind_of Time, date
+    assert_equal [0, 0, 0], [date.hour, date.min, date.sec]
+    assert_operator (Gem::Specification::TODAY..Time.now), :cover?, date
+  end
+
   def setup
     super
 
@@ -1035,7 +1041,7 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1041
     end
     assert_equal 'keyedlist', spec.name
     assert_equal '0.4.0', spec.version.to_s
-    assert_equal Gem::Specification::TODAY, spec.date
+    assert_kind_of Time, spec.date
     assert spec.required_ruby_version.satisfied_by?(Gem::Version.new('1'))
     assert_equal false, spec.has_unit_tests?
   end
@@ -1694,10 +1700,7 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1700
   end
 
   def test_date
-    today = Gem::Specification::TODAY
-    a1_date = @a1.date
-    now = Time.now
-    assert_operator (today..now), :cover?, a1_date
+    assert_date @a1.date
   end
 
   def test_date_equals_date
@@ -2421,7 +2424,7 @@ Gem::Specification.new do |s| https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L2424
   s.required_rubygems_version = Gem::Requirement.new(\"> 0\".freeze) if s.respond_to? :required_rubygems_version=
   s.require_paths = ["lib".freeze, "other".freeze]
   s.authors = ["A User".freeze]
-  s.date = "#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}"
+  s.date = "#{@a2.date.strftime("%Y-%m-%d")}"
   s.description = "This is a test description".freeze
   s.email = "example@e...".freeze
   s.files = ["lib/code.rb".freeze]
@@ -2464,7 +2467,7 @@ Gem::Specification.new do |s| https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L2467
   s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
   s.require_paths = ["lib".freeze]
   s.authors = ["A User".freeze]
-  s.date = "#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}"
+  s.date = "#{@a2.date.strftime("%Y-%m-%d")}"
   s.description = "This is a test description".freeze
   s.email = "example@e...".freeze
   s.files = ["lib/code.rb".freeze]
@@ -2497,7 +2500,7 @@ Gem::Specification.new do |s| https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L2500
   s.required_rubygems_version = Gem::Requirement.new(\"> 0\".freeze) if s.respond_to? :required_rubygems_version=
   s.require_paths = ["lib".freeze]
   s.authors = ["A User".freeze]
-  s.date = "#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}"
+  s.date = "#{@a2.date.strftime("%Y-%m-%d")}"
   s.description = "This is a test description".freeze
   s.email = "example@e...".freeze
   s.homepage = "http://example.com".freeze
@@ -2552,7 +2555,7 @@ Gem::Specification.new do |s| https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L2555
   s.required_rubygems_version = Gem::Requirement.new(\">= 0\".freeze) if s.respond_to? :required_rubygems_version=
   s.require_paths = ["lib".freeze]
   s.authors = ["A User".freeze]
-  s.date = "#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}"
+  s.date = "#{@c1.date.strftime("%Y-%m-%d")}"
   s.description = "This is a test description".freeze
   s.email = "example@e...".freeze
   s.executables = ["exec".freeze]
@@ -3624,6 +3627,11 @@ Did you mean 'Ruby'? https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L3627
   end
 
   def test_metadata_specs
+    @m1 = quick_gem 'm', '1' do |s|
+      s.files = %w[lib/code.rb]
+      s.metadata = { 'one' => "two", 'two' => "three" }
+    end
+
     valid_ruby_spec = <<-EOF
 # -*- encoding: utf-8 -*-
 # stub: m 1 ruby lib
@@ -3636,7 +3644,7 @@ Gem::Specification.new do |s| https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L3644
   s.metadata = { "one" => "two", "two" => "three" } if s.respond_to? :metadata=
   s.require_paths = ["lib".freeze]
   s.authors = ["A User".freeze]
-  s.date = "#{Gem::Specification::TODAY.strftime("%Y-%m-%d")}"
+  s.date = "#{@m1.date.strftime("%Y-%m-%d")}"
   s.description = "This is a test description".freeze
   s.email = "example@e...".freeze
   s.files = ["lib/code.rb".freeze]
@@ -3646,11 +3654,6 @@ Gem::Specification.new do |s| https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L3654
 end
     EOF
 
-    @m1 = quick_gem 'm', '1' do |s|
-      s.files = %w[lib/code.rb]
-      s.metadata = { 'one' => "two", 'two' => "three" }
-    end
-
     assert_equal @m1.to_ruby, valid_ruby_spec
   end
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]