Sha256: d60e41a22de623b6c086606ba66ef26ccd6b603c6228e1301eb077d5527d50b2

Contents?: true

Size: 702 Bytes

Versions: 2

Compression:

Stored size: 702 Bytes

Contents

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

2 entries across 2 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta7 spec/support/integration_help.rb
ffi-gdal-1.0.0.beta6 spec/support/integration_help.rb