Skip to content

Commit

Permalink
fix copy_stream test for Rubinius and JRuby
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Feb 25, 2013
1 parent fc7fdd5 commit 0ee4eef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions lib/faraday/upload_io.rb
Expand Up @@ -43,6 +43,14 @@ def read(length = nil, outbuf = nil)
(!got_result && length) ? nil : outbuf
end

def close
@ios.each { |io| io.close }
end

def ensure_open_and_readable
# Rubinius compatibility
end

private

def current_io
Expand Down
8 changes: 6 additions & 2 deletions test/composite_read_io_test.rb
@@ -1,7 +1,7 @@
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require 'stringio'

class CompositeReadIOTest < Test::Unit::TestCase
class CompositeReadIOTest < Faraday::TestCase
Part = Struct.new(:to_io) do
def length() to_io.string.length end
end
Expand Down Expand Up @@ -70,9 +70,13 @@ def test_multipart_rewind
assert_equal "ab", io.read(2)
end

if IO.respond_to?(:copy_stream)
# JRuby enforces types to copy_stream to be String or IO
if IO.respond_to?(:copy_stream) && !jruby?
def test_compatible_with_copy_stream
target_io = StringIO.new
def target_io.ensure_open_and_writable
# Rubinius compatibility
end
io = composite_io(part("abcd"), part("1234"))

Faraday::Timer.timeout(1) do
Expand Down

0 comments on commit 0ee4eef

Please sign in to comment.