Skip to content

Instantly share code, notes, and snippets.

@nvloff
Created April 3, 2013 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nvloff/5299555 to your computer and use it in GitHub Desktop.
Save nvloff/5299555 to your computer and use it in GitHub Desktop.
class SandboxedTestCase < TestCase
def setup
@remote_repo = sandbox_init('testrepo.git')
@repo = sandbox_clone(@remote_repo)
end
def teardown
FileUtils.remove_entry_secure(@remote_repo.path)
FileUtils.remove_entry_secure(@repo.path)
end
def sandbox_init(repo)
dir = Dir.mktmpdir 'dir'
repo_dir = File.join(TestCase::TEST_DIR, (File.join('fixtures', repo, '.')))
`git clone --bare #{repo_dir} #{dir}`
Rugged::Repository.new(dir)
end
def sandbox_clone(repository)
dir = Dir.mktmpdir 'dir'
`git clone #{repository.path} #{dir}`
Rugged::Repository.new(dir)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment