Permalink
Browse files

Merge pull request #14 from jamieorc/master

Added rewind() method on Joint:IO.
  • Loading branch information...
jnunemaker committed Apr 16, 2012
2 parents d19dd96 + f75ecfd commit 68bd34acf5fabfeb9caf6e9f8d81fb9a5880e26f
Showing with 15 additions and 0 deletions.
  1. +4 −0 lib/joint/io.rb
  2. +11 −0 test/joint/test_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
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

0 comments on commit 68bd34a

Please sign in to comment.