Sha256: f69bfcee3d15ba21b5db45ee79ced9ccbeb435403542924f193ea4bc1f15e67a

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module SuspendersTestHelpers
  APP_NAME = "dummy_app"

  def remove_project_directory
    FileUtils.rm_rf(project_path)
  end

  def create_tmp_directory
    FileUtils.mkdir_p(tmp_path)
  end

  def run_tractor_beam(arguments = nil)
    Dir.chdir(tmp_path) do
      Bundler.with_clean_env do
        `#{tractor_beam_bin} #{APP_NAME} #{arguments}`
      end
    end
  end

  def tractor_beam_help_command
    Dir.chdir(tmp_path) do
      Bundler.with_clean_env do
        `#{tractor_beam_bin} -h`
      end
    end
  end

  def setup_app_dependencies
    return unless File.exist?(project_path)

    Dir.chdir(project_path) do
      Bundler.with_clean_env do
        `bundle check || bundle install`
      end
    end
  end

  def drop_dummy_database
    return unless File.exist?(project_path)

    Dir.chdir(project_path) do
      Bundler.with_clean_env do
        `rails db:drop`
      end
    end
  end

  def project_path
    @project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
  end

  def usage_file
    @usage_path ||= File.join(root_path, "USAGE")
  end

  private

  def tmp_path
    @tmp_path ||= Pathname.new("#{root_path}/tmp")
  end

  def tractor_beam_bin
    File.join(root_path, "bin", "tractor_beam")
  end

  def root_path
    File.expand_path("../../../", __FILE__)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tractor_beam-0.1.2 spec/support/tractor_beam.rb