module RSpec::Files::Buffer

Constants

TMP

Public Class Methods

open(mode = 'w+', root: TMP) { |file| ... } click to toggle source
# File lib/rspec/files/buffer.rb, line 28
def self.open(mode = 'w+', root: TMP)
        path = File.join(root, SecureRandom.hex(32))
        file = File.open(path, mode)
        
        File.unlink(path)
        
        return file unless block_given?
        
        begin
                yield file
        ensure
                file.close
        end
end