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

ruby-changes:66407

From: Benoit <ko1@a...>
Date: Wed, 2 Jun 2021 22:55:16 +0900 (JST)
Subject: [ruby-changes:66407] 750f807575 (master): Update to ruby/spec@c6e9285

https://git.ruby-lang.org/ruby.git/commit/?id=750f807575

From 750f80757523bb916beff51cf30e585a378acd84 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Wed, 2 Jun 2021 15:54:38 +0200
Subject: Update to ruby/spec@c6e9285

---
 spec/ruby/library/yaml/fixtures/common.rb  |  6 ------
 spec/ruby/library/yaml/load_spec.rb        |  8 +++++---
 spec/ruby/library/yaml/shared/load.rb      | 22 +++++++++++-----------
 spec/ruby/library/yaml/unsafe_load_spec.rb |  5 +++--
 4 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/spec/ruby/library/yaml/fixtures/common.rb b/spec/ruby/library/yaml/fixtures/common.rb
index 1d86880..f7fb403 100644
--- a/spec/ruby/library/yaml/fixtures/common.rb
+++ b/spec/ruby/library/yaml/fixtures/common.rb
@@ -1,9 +1,3 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/yaml/fixtures/common.rb#L1
-begin
-  require 'syck'
-rescue LoadError
-  # do nothing
-end
-
 require 'yaml'
 
 $test_file = tmp("yaml_test_file")
diff --git a/spec/ruby/library/yaml/load_spec.rb b/spec/ruby/library/yaml/load_spec.rb
index a84b609..56700a8 100644
--- a/spec/ruby/library/yaml/load_spec.rb
+++ b/spec/ruby/library/yaml/load_spec.rb
@@ -1,8 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/yaml/load_spec.rb#L1
 require_relative '../../spec_helper'
 require_relative 'shared/load'
 
-ruby_version_is ""..."3.1" do
-  describe "YAML.load" do
-    it_behaves_like :yaml_load, :load
+describe "YAML.load" do
+  it_behaves_like :yaml_load_safe, :load
+
+  guard -> { Psych::VERSION < "4.0.0" } do
+    it_behaves_like :yaml_load_unsafe, :load
   end
 end
diff --git a/spec/ruby/library/yaml/shared/load.rb b/spec/ruby/library/yaml/shared/load.rb
index 5e7b455..185a5a6 100644
--- a/spec/ruby/library/yaml/shared/load.rb
+++ b/spec/ruby/library/yaml/shared/load.rb
@@ -1,16 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/yaml/shared/load.rb#L1
 require_relative '../fixtures/common'
 require_relative '../fixtures/strings'
 
-describe :yaml_load, shared: true do
-  after :each do
-    rm_r $test_file
-  end
-
+describe :yaml_load_safe, shared: true do
   it "returns a document from current io stream when io provided" do
     File.open($test_file, 'w') do |io|
       YAML.dump( ['badger', 'elephant', 'tiger'], io )
     end
     File.open($test_file) { |yf| YAML.send(@method,  yf ) }.should == ['badger', 'elephant', 'tiger']
+  ensure
+    rm_r $test_file
   end
 
   it "loads strings" do
@@ -90,6 +88,14 @@ describe :yaml_load, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/yaml/shared/load.rb#L88
     YAML.send(@method, block_seq).should == [[["one", "two", "three"]]]
   end
 
+  it "loads a symbol key that contains spaces" do
+    string = ":user name: This is the user name."
+    expected = { :"user name" => "This is the user name."}
+    YAML.send(@method, string).should == expected
+  end
+end
+
+describe :yaml_load_unsafe, shared: true do
   it "works on complex keys" do
     require 'date'
     expected = {
@@ -101,12 +107,6 @@ describe :yaml_load, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/yaml/shared/load.rb#L107
     YAML.send(@method, $complex_key_1).should == expected
   end
 
-  it "loads a symbol key that contains spaces" do
-    string = ":user name: This is the user name."
-    expected = { :"user name" => "This is the user name."}
-    YAML.send(@method, string).should == expected
-  end
-
   describe "with iso8601 timestamp" do
     it "computes the microseconds" do
       [ [YAML.send(@method, "2011-03-22t23:32:11.2233+01:00"),   223300],
diff --git a/spec/ruby/library/yaml/unsafe_load_spec.rb b/spec/ruby/library/yaml/unsafe_load_spec.rb
index 66eaf85..385cd2a 100644
--- a/spec/ruby/library/yaml/unsafe_load_spec.rb
+++ b/spec/ruby/library/yaml/unsafe_load_spec.rb
@@ -1,8 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/yaml/unsafe_load_spec.rb#L1
 require_relative '../../spec_helper'
 require_relative 'shared/load'
 
-ruby_version_is "3.1" do
+guard -> { Psych::VERSION >= "4.0.0" } do
   describe "YAML.unsafe_load" do
-    it_behaves_like :yaml_load, :unsafe_load
+    it_behaves_like :yaml_load_safe, :unsafe_load
+    it_behaves_like :yaml_load_unsafe, :unsafe_load
   end
 end
-- 
cgit v1.1


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

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