Sha256: 1a714cb020072e386e9aeab7cbcdcd6490737c0cf4a6d07db83f69878c120763

Contents?: true

Size: 1.04 KB

Versions: 18

Compression:

Stored size: 1.04 KB

Contents

module CommonHelpers
  def in_tmp_folder(&block)
    FileUtils.chdir(@tmp_root, &block)
  end

  def in_project_folder(&block)
    project_folder = @active_project_folder || @tmp_root
    FileUtils.chdir(project_folder, &block)
  end

  def in_home_folder(&block)
    FileUtils.chdir(@home_path, &block)
  end

  def force_local_lib_override(project_name = @project_name)
    rakefile = File.read(File.join(project_name, 'Rakefile'))
    File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
      f << "$:.unshift('#{@lib_path}')\n"
      f << rakefile
    end
  end

  def setup_active_project_folder project_name
    @active_project_folder = File.join(@tmp_root, project_name)
    FileUtils.mkdir_p(@active_project_folder)
    @project_name = project_name
  end

  def prepend_to_file(filename, text)
    file = File.read(filename)
    File.open(filename, "w+") do |f|
      f << text + "\n"
      f << file
    end
  end

  def append_to_file(filename, text)
    File.open(filename, "a") do |f|
      f << text + "\n"
    end
  end
end

World(CommonHelpers)

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
choctop-0.14.1 features/support/common.rb
choctop-0.14.0 features/support/common.rb
choctop-0.13.1 features/support/common.rb
choctop-0.13.0 features/support/common.rb
billymeltdown-choctop-0.11.0.8 features/support/common.rb
choctop-0.12.1 features/support/common.rb
choctop-0.12.0 features/support/common.rb
billymeltdown-choctop-0.11.0.7 features/support/common.rb
billymeltdown-choctop-0.11.0.6 features/support/common.rb
billymeltdown-choctop-0.11.0.5 features/support/common.rb
billymeltdown-choctop-0.11.0.4 features/support/common.rb
billymeltdown-choctop-0.11.0.3 features/support/common.rb
billymeltdown-choctop-0.11.0.2 features/support/common.rb
billymeltdown-choctop-0.11.0.1 features/support/common.rb
billymeltdown-choctop-0.11.0 features/support/common.rb
choctop-0.11.1 features/support/common.rb
choctop-0.11.0 features/support/common.rb
choctop-0.10.0 features/support/common.rb