Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the directory param to Git.clone optional
Signed-off-by: James Couball <jcouball@yahoo.com>
- Loading branch information
Showing
5 changed files
with
73 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test/unit' | ||
require_relative '../test_helper' | ||
|
||
# Tests for Git.clone | ||
class TestGitClone < Test::Unit::TestCase | ||
def setup_repo | ||
Git.init('repository.git', bare: true) | ||
git = Git.clone('repository.git', 'temp') | ||
File.write('temp/test.txt', 'test') | ||
git.add('test.txt') | ||
git.commit('Initial commit') | ||
end | ||
|
||
def test_git_clone_with_name | ||
in_temp_dir do |path| | ||
setup_repo | ||
clone_dir = 'clone_to_this_dir' | ||
git = Git.clone('repository.git', clone_dir) | ||
assert(Dir.exist?(clone_dir)) | ||
expected_dir = File.realpath(clone_dir) | ||
assert_equal(expected_dir, git.dir.to_s) | ||
end | ||
end | ||
|
||
def test_git_clone_with_no_name | ||
in_temp_dir do |path| | ||
setup_repo | ||
git = Git.clone('repository.git') | ||
assert(Dir.exist?('repository')) | ||
expected_dir = File.realpath('repository') | ||
assert_equal(expected_dir, git.dir.to_s) | ||
end | ||
end | ||
end |