Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

io.rb: added rewind method to rewind @io. Recently, Joint::IO was upd…

…ated to use a StringIO object for the content rather than just a String. We need access to the rewind method on @io.
  • Loading branch information...
commit f75ecfd6386a75a6d66680115bfa49415fd128cb 1 parent 065efdb
jamieorc authored
Showing with 15 additions and 0 deletions.
  1. +4 −0 lib/joint/io.rb
  2. +11 −0 test/joint/test_io.rb
4 lib/joint/io.rb
View
@@ -17,6 +17,10 @@ def content=(value)
def read(*args)
@io.read(*args)
end
+
+ def rewind
+ @io.rewind if @io.respond_to?(:rewind)
+ end
alias path name
end
11 test/joint/test_io.rb
View
@@ -25,4 +25,15 @@ class IOTest < Test::Unit::TestCase
Joint::IO.new(:content => 'Testing').read.should == 'Testing'
end
end
+
+ context "#rewind" do
+ should "rewinds the io to position 0" do
+ io = Joint::IO.new(:content => 'Testing')
+ io.read.should == 'Testing'
+ io.read.should == ''
+ io.rewind
+ io.read.should == 'Testing'
+ end
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.