【发布时间】:2011-02-24 21:19:42
【问题描述】:
我有这个:
require 'tempfile'
t = Tempfile.new('test-data')
t.open
t.sync = true
t << "apples"
t.puts "bananas"
puts "contents are [#{t.read}] (#{t.size} bytes)"
t.close
打印出来:
contents are [] (14 bytes)
为什么没有实际显示内容?我在 Ruby 1.9.2 上。
【问题讨论】:
-
“善良,倒带”是我(和其他人!)在使用 StringIO 进行单元测试时必须记住的事情:stackoverflow.com/questions/10323/…
标签: ruby temporary-files