[DRE-commits] [test-kitchen] 07/07: Fix monkey patching of IO.read

Hleb Valoshka tsfgnu-guest at moszumanska.debian.org
Wed Jul 8 09:06:48 UTC 2015


This is an automated email from the git hooks/post-receive script.

tsfgnu-guest pushed a commit to branch fix-monkey-patching-of-io-read
in repository test-kitchen.

commit 7cd7f8d4104d7626899b0ecbf285b121e10326f7
Author: Hleb Valoshka <375gnu at gmail.com>
Date:   Mon Jun 29 20:39:07 2015 +0300

    Fix monkey patching of IO.read
---
 spec/spec_helper.rb | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 08de316..1dba35b 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -43,7 +43,21 @@ require "tempfile"
 # Nasty hack to redefine IO.read in terms of File#read for fakefs
 class IO
   def self.read(*args)
-    File.open(args[0], "rb") { |f| f.read(args[1]) }
+    length = args[1]
+    offset = args[2]
+    opt = args[3]
+    if length.kind_of? Hash
+      opt = length
+      length = nil
+    elsif offset.kind_of? Hash
+      opt = offset
+      offset = nil
+    end
+    if opt && opt.has_key?(:mode)
+      File.open(args[0], opt) { |f| f.read(length) }
+    else
+      File.open(args[0], "rb", opt) { |f| f.read(length) }
+    end
   end
 end
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/test-kitchen.git



More information about the Pkg-ruby-extras-commits mailing list