Question

Is there a better way to mock out StringIO input? I'm specifically looking for a way to avoid having to call the .rewind method. I tried using the block form of StringIO.open but it zeros out the internal string when returning it.

test_input = StringIO.new
test_input.puts '### Functional Tags'
test_input.puts '"@api"   *Workflow API*'
test_input.puts '"@categorize"'
test_input.puts ''
test_input.puts '"@combine"'
test_input.puts '"@flaky"  *delicate tests*'
test_input.rewind
Was it helpful?

Solution

How about:

test_input = StringIO.new <<-RUBY
### Functional Tags'
"@api"   *Workflow API*
"@categorize"

"@combine"
"@flaky"  *delicate tests*
RUBY
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top