diff options
Diffstat (limited to 'tests/test_helper.rb')
-rw-r--r-- | tests/test_helper.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/test_helper.rb b/tests/test_helper.rb index c55e1f4..78328c9 100644 --- a/tests/test_helper.rb +++ b/tests/test_helper.rb @@ -14,9 +14,29 @@ class Test::Unit::TestCase @test_dir = File.join(cwd, 'tests', 'files') end - @wdir = File.expand_path(File.join(@test_dir, 'working')) + @wdir_dot = File.expand_path(File.join(@test_dir, 'working')) @wbare = File.expand_path(File.join(@test_dir, 'working.git')) @index = File.expand_path(File.join(@test_dir, 'index')) + + @wdir = create_temp_repo(@wdir_dot) + end + + def teardown + if @wdir + FileUtils.rm_r(@wdir) + end + end + + def create_temp_repo(clone_path) + filename = 'git_test' + Time.now.to_i.to_s + rand(300).to_s + tmp_path = File.join("/tmp/", filename) + FileUtils.mkdir_p(tmp_path) + FileUtils.cp_r(clone_path, tmp_path) + tmp_path = File.join(tmp_path, 'working') + Dir.chdir(tmp_path) do + FileUtils.mv('dot_git', '.git') + end + tmp_path end def in_temp_dir(remove_after = true) |