From: Brian Mitchell Date: 2005-08-27T06:49:04+09:00 Subject: Re: stringio as file On 8/26/05, Joe Van Dyk wrote: > On 8/26/05, Joe Van Dyk wrote: > > On 8/26/05, Joe Van Dyk wrote: > > > StringIO can be used as a standin for a File object when testing, right? > > > > > > require 'stringio' > > > > > > def expects_file file > > > file.open > > > puts file.gets > > > end > > > > > > s = StringIO.new "Hello World\nHow are you?" > > > expects_file s > > > > > > What don't I understand here? > > > > Ah, nevermind. I forgot File.open is a class method. > > This still confuses me though: > > require 'stringio' > > a = StringIO.new > a << "Hello\n" > a << "World" > try something along the lines of: a.rewind > puts a.gets # prints nil I would recommend you check the rdocs and see a.methods.sort Brian.