Sha256: fcad2254f9072a82c20e4a765602e283c6671bb82ea8c65a0482f6b7411e9b36
Contents?: true
Size: 1.35 KB
Versions: 7
Compression:
Stored size: 1.35 KB
Contents
require 'autoshell' require 'fileutils' module Autoshell # Helper test class module TestHelper REPO_URL = File.expand_path( '../../../test/fixtures/autotune-example-blueprint.git', __FILE__) FIXTURES_PATH = File.expand_path('../../../test/fixtures', __FILE__) def before_setup @dirs = {} @fixtures = {} end def after_teardown @dirs.values.each do |dir| FileUtils.rm_rf(dir) if File.exist?(dir) end end # Get a temp dir that will get cleaned-up after this test # @param name [Symbol] name name of the tmpdir to get # @return [Pathname] absolute path def dir(name = :test) @dirs[name.to_sym] ||= Pathname.new( File.expand_path("#{Dir.tmpdir}/#{Time.now.to_i}#{rand(1000)}/")) end # autoshell fixture retriever # # @param name [Symbol] name of the fixture to retrieve # @return [Autoshell::Base] def autoshell(name) @fixtures[name.to_sym] ||= begin tmpdir = dir(name) dest_path = tmpdir.join(name.to_s) # if there is a matching dir in fixtures, copy it to the temp dir fixtures_path = File.join(FIXTURES_PATH, name.to_s) if Dir.exist? fixtures_path FileUtils.mkdir_p(tmpdir) FileUtils.cp_r(fixtures_path, dest_path) end Autoshell.new(dest_path) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems