Sha256: b03ce54911d142783f0c546289e4d73585f7d71268bdf88ea6476e08a13b0c26

Contents?: true

Size: 733 Bytes

Versions: 9

Compression:

Stored size: 733 Bytes

Contents

# frozen_string_literal: true

require 'fileutils'

# Helper methods for integration specs.
module IntegrationHelp
  def test_files
    @test_files ||= []
  end

  def cleanup_test_files
    test_files.each do |f|
      FileUtils.rm(f) if File.exist?(f)
    end
  end

  # @param original_path [String]
  # @return [String]
  def make_temp_test_file(original_path)
    file_name = File.basename(original_path)
    relative_tmp_path = File.join(temp_base_dir, file_name)
    tmp_path = File.expand_path(relative_tmp_path, __dir__)

    return tmp_path if test_files.include?(tmp_path)
    FileUtils.cp(original_path, tmp_path)
    test_files << tmp_path

    tmp_path
  end

  def temp_base_dir
    File.join(%w[.. .. tmp])
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta16 spec/support/integration_help.rb
ffi-gdal-1.0.0.beta15 spec/support/integration_help.rb
ffi-gdal-1.0.0.beta14 spec/support/integration_help.rb
ffi-gdal-1.0.0.beta13 spec/support/integration_help.rb
ffi-gdal-1.0.0.beta12 spec/support/integration_help.rb
ffi-gdal-1.0.0.beta11 spec/support/integration_help.rb
ffi-gdal-1.0.0.beta10 spec/support/integration_help.rb
ffi-gdal-1.0.0.beta9 spec/support/integration_help.rb
ffi-gdal-1.0.0.beta8 spec/support/integration_help.rb