Frage

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
War es hilfreich?

Lösung

How about:

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

"@combine"
"@flaky"  *delicate tests*
RUBY
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top