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

ruby-changes:59003

From: Benoit <ko1@a...>
Date: Sun, 1 Dec 2019 05:27:37 +0900 (JST)
Subject: [ruby-changes:59003] 1243255c3a (master): Update to ruby/spec@4eec3dc

https://git.ruby-lang.org/ruby.git/commit/?id=1243255c3a

From 1243255c3a36433041012b6107a5ac48658a0895 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Sat, 30 Nov 2019 21:26:52 +0100
Subject: Update to ruby/spec@4eec3dc


diff --git a/spec/ruby/CONTRIBUTING.md b/spec/ruby/CONTRIBUTING.md
index 2f9b138..1ec6f0f 100644
--- a/spec/ruby/CONTRIBUTING.md
+++ b/spec/ruby/CONTRIBUTING.md
@@ -88,6 +88,14 @@ Array.should have_method(:new) https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L88
   raise "oops"
 }.should raise_error(RuntimeError, /oops/)
 
+-> {
+  raise "oops"
+}.should raise_error(RuntimeError) { |e|
+  # Custom checks on the Exception object
+  e.message.should include("oops")
+  e.cause.should == nil
+}
+
 # To avoid! Instead, use an expectation testing what the code in the lambda does.
 # If an exception is raised, it will fail the example anyway.
 -> { ... }.should_not raise_error
diff --git a/spec/ruby/README.md b/spec/ruby/README.md
index 980eaf0..3163a78 100644
--- a/spec/ruby/README.md
+++ b/spec/ruby/README.md
@@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/README.md#L1
 # The Ruby Spec Suite
 
-[![Build Status](https://travis-ci.org/ruby/spec.svg)](https://travis-ci.org/ruby/spec)
-[![Build Status](https://ci.appveyor.com/api/projects/status/1gs6f399320o44b1?svg=true)](https://ci.appveyor.com/project/eregon/spec-x948i)
+[![Actions Build Status](https://github.com/ruby/spec/workflows/CI/badge.svg?branch=master)](https://github.com/ruby/spec/actions)
+[![Windows Actions Build Status](https://github.com/ruby/spec/workflows/Windows/badge.svg?branch=master)](https://github.com/ruby/spec/actions)
 [![Gitter](https://badges.gitter.im/ruby/spec.svg)](https://gitter.im/ruby/spec)
 
 The Ruby Spec Suite, abbreviated `ruby/spec`, is a test suite for the behavior of the Ruby programming language.
diff --git a/spec/ruby/core/array/drop_spec.rb b/spec/ruby/core/array/drop_spec.rb
index 89b8534..84ea86b 100644
--- a/spec/ruby/core/array/drop_spec.rb
+++ b/spec/ruby/core/array/drop_spec.rb
@@ -30,4 +30,22 @@ describe "Array#drop" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/drop_spec.rb#L30
     ary.shift
     ary.drop(1).should == [2]
   end
+
+  it "tries to convert the passed argument to an Integer using #to_int" do
+    obj = mock("to_int")
+    obj.should_receive(:to_int).and_return(2)
+
+    [1, 2, 3].drop(obj).should == [3]
+  end
+
+  it "raises a TypeError when the passed argument can't be coerced to Integer" do
+    -> { [1, 2].drop("cat") }.should raise_error(TypeError)
+  end
+
+  it "raises a TypeError when the passed argument isn't an integer and #to_int returns non-Integer" do
+    obj = mock("to_int")
+    obj.should_receive(:to_int).and_return("cat")
+
+    -> { [1, 2].drop(obj) }.should raise_error(TypeError)
+  end
 end
diff --git a/spec/ruby/core/class/to_s_spec.rb b/spec/ruby/core/class/to_s_spec.rb
deleted file mode 100644
index 2055593..0000000
--- a/spec/ruby/core/class/to_s_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/drop_spec.rb#L0
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-describe "Class#to_s" do
-  it 'regular class returns same name as Module#to_s' do
-    String.to_s.should == 'String'
-  end
-
-  describe 'singleton class' do
-    it 'for modules includes module name' do
-      CoreClassSpecs.singleton_class.to_s.should == '#<Class:CoreClassSpecs>'
-    end
-
-    it 'for classes includes class name' do
-      CoreClassSpecs::Record.singleton_class.to_s.should == '#<Class:CoreClassSpecs::Record>'
-    end
-
-    it 'for objects includes class name and object ID' do
-      obj = CoreClassSpecs::Record.new
-      obj.singleton_class.to_s.should =~ /#<Class:#<CoreClassSpecs::Record:0x[0-9a-f]+>>/
-    end
-  end
-end
diff --git a/spec/ruby/core/data/constants_spec.rb b/spec/ruby/core/data/constants_spec.rb
new file mode 100644
index 0000000..1b4c0d2
--- /dev/null
+++ b/spec/ruby/core/data/constants_spec.rb
@@ -0,0 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/data/constants_spec.rb#L1
+require_relative '../../spec_helper'
+
+describe "Data" do
+  it "is a subclass of Object" do
+    suppress_warning do
+      Data.superclass.should == Object
+    end
+  end
+
+  ruby_version_is "2.5" do
+    it "is deprecated" do
+      -> { Data }.should complain(/constant ::Data is deprecated/)
+    end
+  end
+end
diff --git a/spec/ruby/core/env/assoc_spec.rb b/spec/ruby/core/env/assoc_spec.rb
index 9946e32..c7a388d 100644
--- a/spec/ruby/core/env/assoc_spec.rb
+++ b/spec/ruby/core/env/assoc_spec.rb
@@ -26,6 +26,6 @@ describe "ENV.assoc" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/env/assoc_spec.rb#L26
   end
 
   it "raises TypeError if the argument is not a String and does not respond to #to_str" do
-    -> { ENV.assoc(Object.new) }.should raise_error(TypeError)
+    -> { ENV.assoc(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
   end
 end
diff --git a/spec/ruby/core/env/delete_spec.rb b/spec/ruby/core/env/delete_spec.rb
index e875df4..b7fe1ee 100644
--- a/spec/ruby/core/env/delete_spec.rb
+++ b/spec/ruby/core/env/delete_spec.rb
@@ -30,6 +30,12 @@ describe "ENV.delete" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/env/delete_spec.rb#L30
     ScratchPad.recorded.should == "foo"
   end
 
+  it "does not evaluate the block if the envirionment variable exists" do
+    ENV["foo"] = "bar"
+    ENV.delete("foo") { |name| fail "Should not happen" }
+    ENV["foo"].should == nil
+  end
+
   it "raises TypeError if the argument is not a String and does not respond to #to_str" do
     -> { ENV.delete(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
   end
diff --git a/spec/ruby/core/env/each_key_spec.rb b/spec/ruby/core/env/each_key_spec.rb
index 5c5cf4f..0efcb09 100644
--- a/spec/ruby/core/env/each_key_spec.rb
+++ b/spec/ruby/core/env/each_key_spec.rb
@@ -10,7 +10,7 @@ describe "ENV.each_key" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/env/each_key_spec.rb#L10
       ENV.clear
       ENV["1"] = "3"
       ENV["2"] = "4"
-      ENV.each_key { |k| e << k }
+      ENV.each_key { |k| e << k }.should equal(ENV)
       e.should include("1")
       e.should include("2")
     ensure
diff --git a/spec/ruby/core/env/each_value_spec.rb b/spec/ruby/core/env/each_value_spec.rb
index ea29b3a..60d9f60 100644
--- a/spec/ruby/core/env/each_value_spec.rb
+++ b/spec/ruby/core/env/each_value_spec.rb
@@ -10,7 +10,7 @@ describe "ENV.each_value" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/env/each_value_spec.rb#L10
       ENV.clear
       ENV["1"] = "3"
       ENV["2"] = "4"
-      ENV.each_value { |v| e << v }
+      ENV.each_value { |v| e << v }.should equal(ENV)
       e.should include("3")
       e.should include("4")
     ensure
diff --git a/spec/ruby/core/env/index_spec.rb b/spec/ruby/core/env/index_spec.rb
index 04986a0..43875f5 100644
--- a/spec/ruby/core/env/index_spec.rb
+++ b/spec/ruby/core/env/index_spec.rb
@@ -3,4 +3,10 @@ require_relative 'shared/key' https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/env/index_spec.rb#L3
 
 describe "ENV.index" do
   it_behaves_like :env_key, :index
+
+  it "warns about deprecation" do
+    -> do
+      ENV.index("foo")
+    end.should complain(/warning: ENV.index is deprecated; use ENV.key/)
+  end
 end
diff --git a/spec/ruby/core/env/keys_spec.rb b/spec/ruby/core/env/keys_spec.rb
index 3699b2c..b074a8f 100644
--- a/spec/ruby/core/env/keys_spec.rb
+++ b/spec/ruby/core/env/keys_spec.rb
@@ -2,8 +2,8 @@ require_relative '../../spec_helper' https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/env/keys_spec.rb#L2
 
 describe "ENV.keys" do
 
-  it "returns all the keys" do
-    ENV.keys.sort.should == ENV.to_hash.keys.sort
+  it "returns an array of the keys" do
+    ENV.keys.should == ENV.to_hash.keys
   end
 
   it "returns the keys in the locale encoding" do
diff --git a/spec/ruby/core/env/rehash_spec.rb b/spec/ruby/core/env/rehash_spec.rb
index e724fea..3782e4b 100644
--- a/spec/ruby/core/env/rehash_spec.rb
+++ b/spec/ruby/core/env/rehash_spec.rb
@@ -1 +1,7 @@
 require_relative '../../spec_helper'
+
+describe "ENV.rehash" do
+  it "returns nil" do
+    ENV.rehash.should == nil
+  end
+end
diff --git a/spec/ruby/core/env/replace_spec.rb b/spec/ruby/core/env/replace_spec.rb
index 8837dee..9fc6764 100644
--- a/spec/ruby/core/env/replace_spec.rb
+++ b/spec/ruby/core/env/replace_spec.rb
@@ -1,15 +1,51 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/env/replace_spec.rb#L1
 require_relative '../../spec_helper'
 
 describe "ENV.replace" do
+  before :each do
+    @orig = ENV.to_hash
+    ENV.delete("foo")
+  end
+
+  after :each do
+    ENV.replace(@orig)
+  end
 
   it "replaces ENV with a Hash" do
-    ENV["foo"] = "bar"
-    e = ENV.reject { |k, v| k == "foo" }
-    e["baz"] = "bam"
-    ENV.replace e
-    ENV["foo"].should == nil
-    ENV["baz"].should == "bam"
-    ENV.delete "baz"
+    ENV.replace("foo" => "0", "bar" => "1").should equal(ENV)
+    ENV.size.should == 2
+    ENV["foo"].should == "0"
+    ENV["bar"].should == "1"
+  end
+
+  it "raises TypeError if the argument is not a Hash" do
+    -> { ENV.replace(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into Hash")
+    ENV.to_hash.should == @orig
+  end
+
+  it "raises TypeError if a key is not a String" do
+    -> { ENV.replace(Object.new => "0") }.should raise_error(TypeError, "no implicit conversion of Object into String")
+    ENV.to_hash.should == @orig
+  end
+
+  it "raises TypeError if a value is not a String" do
+    -> { ENV.replace("foo" => Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
+    ENV.to_hash.should == @orig
+  end
+
+  it "raises Errno::EINVAL when the key contains the '=' character" do
+    -> { ENV.replace("foo=" =>"bar") }.should raise_error (... truncated)

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

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