[rspec-users] Returning a StringIO object from a stub
jeremy at infinitecube.com
Wed Nov 11 16:56:54 EST 2009
I'm trying to stub File.new so I can return a StringIO object from it
to set some expectation and make sure the subject under test is
behaving correctly, but calling readline() on the StringIO object in
the subject always returns nil. What's strange is that calling read()
returns the entire set of data in the StringIO object. Additionally,
calling readline() on the StringIO object from inside the test works
fine as well.
data = <<-DATA
faux_file = StringIO.new(data)
I'm using rspec 1.2.9 (this is not testing a rails app). Can anyone
give me any advice on why this might be?
More information about the rspec-users