class
StringIO
v2_5_5 -
Show latest stable
- Superclass: Object
Pseudo I/O on String object.
Commonly used to simulate `$stdio` or `$stderr`
Examples
require 'stringio' io = StringIO.new io.puts "Hello World" io.string #=> "Hello World\n"
Included modules
- Enumerable
- IO::generic_readable
- IO::generic_writable
Files
- ext/stringio/stringio.c
1Note
Useful for mocking out IO methods like #gets and #puts
This class is helpful when testing certain classes of software libraries that are dependent on console input and output, similar to some testing uses of Java's StringBuffer