Sha256: 28b4954bd37345b4302c94ebf25b6f82a672493367185abe5e77615d1238e183

Contents?: true

Size: 680 Bytes

Versions: 2

Compression:

Stored size: 680 Bytes

Contents

module SetupMacros
  def set_up_testing_directory
    @tmp = Pathname.new(@pwd = Dir.pwd).join('tmp')
    @tmp.rmtree if @tmp.exist?
    @tmp.mkpath

    @tmp.join('apps/controllers').mkpath
    @tmp.join('apps/models').mkpath

    Dir.chdir(@tmp)
    @root = @tmp
  end

  def chdir_back_to_root
    Dir.chdir(@pwd)
  end

  def create_file(path)
    file = @root.join(path)
    file.dirname.rmtree if file.dirname.exist?
    file.dirname.mkpath
    FileUtils.touch(file)
  end

  def erase_file_content(path)
    file = @root.join(path)
    File.open(file, 'w') {}
  end

  def insert_into_file(path, content)
    file = @root.join(path)
    File.write(file, content)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tset-0.0.2 spec/support/setup_macros.rb
tset-0.0.1 spec/support/setup_macros.rb