module Tapioca::Helpers::Test::Content

def add_content_file(name, content)

def add_content_file(name, content)
  file_name = tmp_path("lib/#{name}")
  raise ArgumentError, "a file named '#{name}' was already added; cannot overwrite." if File.exist?(file_name)
  FileUtils.mkdir_p(File.dirname(file_name))
  File.write(file_name, content)
  file_name
end

def add_ruby_file(name, content, require_file: true)

def add_ruby_file(name, content, require_file: true)
  add_content_file(name, content).tap do |file_name|
    Tapioca.silence_warnings { require(file_name) } if require_file
  end
end

def remove_tmp_path

def remove_tmp_path
  FileUtils.rm_rf(tmp_path)
end

def teardown

def teardown
  super
  remove_tmp_path
end

def tmp_path(*args)

def tmp_path(*args)
  @tmp_path = T.let(@tmp_path, T.nilable(String))
  @tmp_path ||= Dir.mktmpdir
  T.unsafe(File).join(@tmp_path, *args)
end