Sha256: 3374d7a0c29c3c3cee1c8fc50d3fcb44fef4d708878a504a8ffa3a9a6c7d708f

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 Bytes

Contents

module ShoelacesTestHelpers
  APP_NAME = 'dummy'

  def remove_project_directory
    FileUtils.rm_rf(project_path)
  end

  def create_tmp_directory
    FileUtils.mkdir_p(tmp_path)
  end

  def run_shoelaces(arguments = nil)
    Dir.chdir(tmp_path) do
      Bundler.with_clean_env do
        ENV['TESTING'] = '1'

        %x(#{shoelaces_bin} #{APP_NAME} #{arguments})
      end
    end
  end

  def drop_dummy_database
    if File.exists?(project_path)
      Dir.chdir(project_path) do
        Bundler.with_clean_env do
          `rake db:drop`
        end
      end
    end
  end

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

  private

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

  def shoelaces_bin
    File.join(root_path, 'bin', 'shoelaces')
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoelaces-0.1.0 spec/support/shoelaces.rb