Module: Autoshell::TestHelper
- Defined in:
- lib/autoshell/test_helper.rb
Overview
Helper test class
Constant Summary collapse
- REPO_URL =
File.( '../../../test/fixtures/autotune-example-blueprint.git', __FILE__)
- FIXTURES_PATH =
File.('../../../test/fixtures', __FILE__)
Instance Method Summary collapse
- #after_teardown ⇒ Object
-
#autoshell(name) ⇒ Autoshell::Base
autoshell fixture retriever.
- #before_setup ⇒ Object
-
#dir(name = :test) ⇒ Pathname
Get a temp dir that will get cleaned-up after this test.
Instance Method Details
#after_teardown ⇒ Object
16 17 18 19 20 |
# File 'lib/autoshell/test_helper.rb', line 16 def after_teardown @dirs.values.each do |dir| FileUtils.rm_rf(dir) if File.exist?(dir) end end |
#autoshell(name) ⇒ Autoshell::Base
autoshell fixture retriever
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/autoshell/test_helper.rb', line 34 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 |
#before_setup ⇒ Object
11 12 13 14 |
# File 'lib/autoshell/test_helper.rb', line 11 def before_setup @dirs = {} @fixtures = {} end |
#dir(name = :test) ⇒ Pathname
Get a temp dir that will get cleaned-up after this test
25 26 27 28 |
# File 'lib/autoshell/test_helper.rb', line 25 def dir(name = :test) @dirs[name.to_sym] ||= Pathname.new( File.("#{Dir.tmpdir}/#{Time.now.to_i}#{rand(1000)}/")) end |