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

ruby-changes:53309

From: nobu <ko1@a...>
Date: Sun, 4 Nov 2018 11:02:33 +0900 (JST)
Subject: [ruby-changes:53309] nobu:r65525 (trunk): Refine Timezone class in test-spec

nobu	2018-11-04 11:02:28 +0900 (Sun, 04 Nov 2018)

  New Revision: 65525

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65525

  Log:
    Refine Timezone class in test-spec

  Modified files:
    trunk/spec/ruby/core/time/fixtures/classes.rb
    trunk/spec/ruby/core/time/new_spec.rb
Index: spec/ruby/core/time/fixtures/classes.rb
===================================================================
--- spec/ruby/core/time/fixtures/classes.rb	(revision 65524)
+++ spec/ruby/core/time/fixtures/classes.rb	(revision 65525)
@@ -9,4 +9,18 @@ module TimeSpecs https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/time/fixtures/classes.rb#L9
     end
   end
 
+  Timezone = Struct.new(:name, :abbr, :offset)
+  class Timezone
+    def utc_offset(t = nil)
+      offset
+    end
+
+    def local_to_utc(t)
+      t - utc_offset(t)
+    end
+
+    def utc_to_local(t)
+      t + utc_offset(t)
+    end
+  end
 end
Index: spec/ruby/core/time/new_spec.rb
===================================================================
--- spec/ruby/core/time/new_spec.rb	(revision 65524)
+++ spec/ruby/core/time/new_spec.rb	(revision 65525)
@@ -117,8 +117,7 @@ end https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/time/new_spec.rb#L117
 ruby_version_is "2.6" do
   describe "Time.new with a timezone argument" do
     it "returns a Time correspoinding to UTC time returned by local_to_utc" do
-      zone = mock('timezone')
-      zone.should_receive(:local_to_utc).and_return(Time::TM.new(2000, 1, 1, 6, 30, 0))
+      zone = TimeSpecs::Timezone.new("Asia/Colombo", "MMT", (5*3600+30*60))
       t = Time.new(2000, 1, 1, 12, 0, 0, zone)
       t.to_a[0, 6].should == [0, 0, 12, 1, 1, 2000]
       t.utc_offset.should == 19800

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

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