Sha256: ced6909e24f683b16058e7f8e47a9b0f605383dfe2ebde012a49f7c2a3b1d0af

Contents?: true

Size: 1.53 KB

Versions: 10

Compression:

Stored size: 1.53 KB

Contents

require 'fileutils'
module TestApp
  def create_test_app
    [test_app_path, deploy_to].each do |path|
      FileUtils.rm_rf(path)
      FileUtils.mkdir(path)
    end

    File.open(gemfile, 'w+') do |file|
      file.write "gem 'capistrano', path: '#{path_to_cap}'"
    end

    Dir.chdir(test_app_path) do
      %x[bundle]
    end
  end

  def install_test_app_with(config)
    create_test_app
    Dir.chdir(test_app_path) do
      %x[bundle exec cap install STAGES=#{stage}]
    end
    write_local_deploy_file(config)
  end

  def write_local_deploy_file(config)
    File.open(test_stage_path, 'w') do |file|
      file.write config
    end
  end

  def create_shared_directory(path)
    FileUtils.mkdir_p(shared_path.join(path))
  end

  def create_shared_file(path)
    File.open(shared_path.join(path), 'w')
  end

  def cap(task)
    Dir.chdir(test_app_path) do
      %x[bundle exec cap #{stage} #{task}]
    end
  end

  def stage
    'test'
  end

  def test_stage_path
    test_app_path.join('config/deploy/test.rb')
  end

  def test_app_path
    Pathname.new('/tmp/test_app')
  end

  def deploy_to
    Pathname.new('/tmp/test_app/deploy_to')
  end

  def shared_path
    deploy_to.join('shared')
  end

  def current_path
    deploy_to.join('current')
  end

  def releases_path
    deploy_to.join('releases')
  end

  def release_path
    releases_path.join(Dir.entries(releases_path).last)
  end

  def path_to_cap
    File.expand_path('.')
  end

  def gemfile
    test_app_path.join('Gemfile')
  end

  def current_user
    `whoami`.chomp
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
capistrano-3.0.0.pre14 spec/support/test_app.rb
capistrano-3.0.0.pre13 spec/support/test_app.rb
capistrano-3.0.0.pre12 spec/support/test_app.rb
capistrano-3.0.0.pre11 spec/support/test_app.rb
capistrano-3.0.0.pre10 spec/support/test_app.rb
capistrano-3.0.0.pre7 spec/support/test_app.rb
capistrano-3.0.0.pre6 spec/support/test_app.rb
capistrano-3.0.0.pre5 spec/support/test_app.rb
capistrano-3.0.0.pre4 spec/support/test_app.rb
capistrano-3.0.0.pre3 spec/support/test_app.rb