module Autoshell::TestHelper
Helper test class
Constants
- FIXTURES_PATH
- REPO_URL
Public Instance Methods
after_teardown()
click to toggle source
# 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)
click to toggle source
autoshell fixture retriever
@param name [Symbol] name of the fixture to retrieve @return [Autoshell::Base]
# 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()
click to toggle source
# File lib/autoshell/test_helper.rb, line 11 def before_setup @dirs = {} @fixtures = {} end
dir(name = :test)
click to toggle source
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
# File lib/autoshell/test_helper.rb, line 25 def dir(name = :test) @dirs[name.to_sym] ||= Pathname.new( File.expand_path("#{Dir.tmpdir}/#{Time.now.to_i}#{rand(1000)}/")) end