Skip to content

Commit

Permalink
Prevent tempfiles from being GC'ed while they are still in use.
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviershay committed Jan 2, 2012
1 parent 519a9ab commit e684e71
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spec/spec_helper.rb
@@ -1,7 +1,12 @@
require 'tempfile'

# Keep a reference to all tempfiles so they are not garbage collected until the
# process exits.
$tempfiles = []

def make_file(content)
tempfile = Tempfile.new('cane')
$tempfiles << tempfile
tempfile.print(content)
tempfile.flush
tempfile.path
Expand Down

0 comments on commit e684e71

Please sign in to comment.