Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #9 from arsduo/master

Fixing StringIO bug in 1.9.2
  • Loading branch information...
commit 1a87f0b7936c7b28ef0201dd37a364cbe228652d 2 parents c1baab8 + 212b321
@nicksieger authored
Showing with 4 additions and 3 deletions.
  1. +3 −1 lib/composite_io.rb
  2. +1 −2  test/test_composite_io.rb
View
4 lib/composite_io.rb
@@ -66,7 +66,9 @@ def initialize(filename_or_io, content_type, filename = nil)
io = filename_or_io
local_path = ""
if io.respond_to? :read
- local_path = filename_or_io.path
+ # in Ruby 1.9.2, StringIOs no longer respond to path
+ # (since they respond to :length, so we don't need their local path, see parts.rb:41)
+ local_path = filename_or_io.respond_to?(:path) ? filename_or_io.path : "local.path"
else
io = File.open(filename_or_io)
local_path = filename_or_io
View
3  test/test_composite_io.rb
@@ -12,7 +12,7 @@ def test_full_read_from_several_ios
assert_equal 'the quick brown fox', @io.read
end
- unless RUBY_VERSION < '1.9'
+ unless RUBY_VERSION < '1.9'
def test_read_from_multibyte
utf8 = File.open(File.dirname(__FILE__)+'/multibyte.txt')
binary = StringIO.new("\x86")
@@ -21,7 +21,6 @@ def test_read_from_multibyte
end
end
-
def test_partial_read
assert_equal 'the quick', @io.read(9)
end
Please sign in to comment.
Something went wrong with that request. Please try again.