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

ruby-changes:55608

From: Benoit <ko1@a...>
Date: Mon, 29 Apr 2019 06:20:57 +0900 (JST)
Subject: [ruby-changes:55608] Benoit Daloze:994833085a (trunk): Update to ruby/mspec@c25d63d

https://git.ruby-lang.org/ruby.git/commit/?id=994833085a

From 994833085ae06afbe94d30ab183d80e0234fbe14 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Sun, 28 Apr 2019 23:20:09 +0200
Subject: Update to ruby/mspec@c25d63d


diff --git a/spec/mspec/lib/mspec/helpers/io.rb b/spec/mspec/lib/mspec/helpers/io.rb
index 5361fb9..f2c799d 100644
--- a/spec/mspec/lib/mspec/helpers/io.rb
+++ b/spec/mspec/lib/mspec/helpers/io.rb
@@ -65,8 +65,6 @@ end https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/helpers/io.rb#L65
 # with any Ruby object). The file descriptor can safely be passed
 # to IO.new without creating a Ruby object alias to the fd.
 def new_fd(name, mode="w:utf-8")
-  mode = options_or_mode(mode)
-
   if mode.kind_of? Hash
     if mode.key? :mode
       mode = mode[:mode]
@@ -75,41 +73,15 @@ def new_fd(name, mode="w:utf-8") https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/helpers/io.rb#L73
     end
   end
 
-  IO.sysopen name, fmode(mode)
+  IO.sysopen name, mode
 end
 
 # Creates an IO instance for a temporary file name. The file
 # must be deleted.
 def new_io(name, mode="w:utf-8")
-  IO.new new_fd(name, options_or_mode(mode)), options_or_mode(mode)
+  IO.new new_fd(name, mode), mode
 end
 
 def find_unused_fd
   Dir.entries("/dev/fd").map(&:to_i).max + 1
 end
-
-# This helper simplifies passing file access modes regardless of
-# whether the :encoding feature is enabled. Only the access specifier
-# itself will be returned if :encoding is not enabled. Otherwise,
-# the full mode string will be returned (i.e. the helper is a no-op).
-def fmode(mode)
-  if FeatureGuard.enabled? :encoding
-    mode
-  else
-    mode.split(':').first
-  end
-end
-
-# This helper simplifies passing file access modes or options regardless of
-# whether the :encoding feature is enabled. Only the access specifier itself
-# will be returned if :encoding is not enabled. Otherwise, the full mode
-# string or option will be returned (i.e. the helper is a no-op).
-def options_or_mode(oom)
-  return fmode(oom) if oom.kind_of? String
-
-  if FeatureGuard.enabled? :encoding
-    oom
-  else
-    fmode(oom[:mode] || "r:utf-8")
-  end
-end
diff --git a/spec/mspec/lib/mspec/utils/options.rb b/spec/mspec/lib/mspec/utils/options.rb
index 9f8dd01..bbe6423 100644
--- a/spec/mspec/lib/mspec/utils/options.rb
+++ b/spec/mspec/lib/mspec/utils/options.rb
@@ -384,7 +384,7 @@ class MSpecOptions https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/utils/options.rb#L384
   def repeat
     on("-R", "--repeat", "NUMBER",
        "Repeatedly run an example NUMBER times") do |o|
-      MSpec.repeat = o.to_i
+      MSpec.repeat = Integer(o)
     end
   end
 
diff --git a/spec/mspec/spec/helpers/io_spec.rb b/spec/mspec/spec/helpers/io_spec.rb
index 3219f59..86e4209 100644
--- a/spec/mspec/spec/helpers/io_spec.rb
+++ b/spec/mspec/spec/helpers/io_spec.rb
@@ -64,7 +64,7 @@ describe Object, "#new_fd" do https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/helpers/io_spec.rb#L64
     fd = new_fd @name
     fd.should be_kind_of(Integer)
 
-    @io = IO.new fd, fmode('w:utf-8')
+    @io = IO.new fd, 'w:utf-8'
     @io.sync = true
     @io.print "io data"
 
@@ -76,7 +76,7 @@ describe Object, "#new_fd" do https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/helpers/io_spec.rb#L76
     fd = new_fd @name, { :mode => 'w:utf-8' }
     fd.should be_kind_of(Integer)
 
-    @io = IO.new fd, fmode('w:utf-8')
+    @io = IO.new fd, 'w:utf-8'
     @io.sync = true
     @io.print "io data"
 
@@ -134,41 +134,3 @@ describe Object, "#new_io" do https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/helpers/io_spec.rb#L134
     IO.read(@name).should == "io data"
   end
 end
-
-describe Object, "#fmode" do
-  it "returns the argument unmodified if :encoding feature is enabled" do
-    FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(true)
-    fmode("rb:binary:utf-8").should == "rb:binary:utf-8"
-  end
-
-  it "returns only the file access mode if :encoding feature is not enabled" do
-    FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(false)
-    fmode("rb:binary:utf-8").should == "rb"
-  end
-end
-
-describe Object, "#options_or_mode" do
-  describe "if passed a Hash" do
-    it "returns a mode string if :encoding feature is not enabled" do
-      FeatureGuard.should_receive(:enabled?).with(:encoding).twice.and_return(false)
-      options_or_mode(:mode => "rb:binary").should == "rb"
-    end
-
-    it "returns a Hash if :encoding feature is enabled" do
-      FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(true)
-      options_or_mode(:mode => "rb:utf-8").should == { :mode => "rb:utf-8" }
-    end
-  end
-
-  describe "if passed a String" do
-    it "returns only the file access mode if :encoding feature is not enabled" do
-      FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(false)
-      options_or_mode("rb:binary:utf-8").should == "rb"
-    end
-
-    it "returns the argument unmodified if :encoding feature is enabled" do
-      FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(true)
-      options_or_mode("rb:binary:utf-8").should == "rb:binary:utf-8"
-    end
-  end
-end
-- 
cgit v0.10.2


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

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