module RSpecCommand::ClassMethods

def file(path, content=nil, &block)

Parameters:
  • block (Proc) -- Optional block to return file data to write.
  • content (String) -- File data to write.
  • path (String) -- Path within the temporary directory to write to.
def file(path, content=nil, &block)
  raise "file path should be relative the the temporary directory." if path == File.expand_path(path)
  before do
    content = instance_eval(&block) if block
    dest_path = File.join(temp_path, path)
    FileUtils.mkdir_p(File.dirname(dest_path))
    IO.write(dest_path, content)
  end
end