提交 c56ef898 编写于 作者: M Mislav Marohnić

fix tests failing if the current dir is something else than "hub"

Some tests relied on the current working directory being named "hub".
This change makes it possible for tests to stub out the name of the
current directory.

References 9801b465
上级 b319397c
......@@ -225,7 +225,7 @@ module Hub
# > git remote add origin git@github.com:USER/REPO.git
def init(args)
if args.delete('-g')
url = github_url(:private => true, :repo => File.basename(Dir.pwd))
url = github_url(:private => true, :repo => current_dirname)
args.after "git remote add origin #{url}"
end
end
......
......@@ -34,7 +34,7 @@ module Hub
end
def repo_name
REMOTES[default_remote][:repo] || File.basename(Dir.pwd)
REMOTES[default_remote][:repo] || current_dirname
end
# Either returns the GitHub user as set by git-config(1) or aborts
......@@ -138,5 +138,11 @@ module Hub
url % [user, repo]
end
end
DIRNAME = File.basename(Dir.pwd)
def current_dirname
DIRNAME
end
end
end
......@@ -16,6 +16,7 @@ class HubTest < Test::Unit::TestCase
def setup
COMMANDS.replace %w[open groff]
Hub::Context::DIRNAME.replace 'hub'
@git = Hub::Context::GIT_CONFIG.replace(Hash.new { |h, k|
raise ArgumentError, "`git #{k}` not stubbed"
......@@ -356,10 +357,9 @@ class HubTest < Test::Unit::TestCase
end
def test_init
dirname = File.basename(Dir.pwd)
h = Hub("init -g")
assert_equal "git init", h.command
assert_equal "git remote add origin git@github.com:tpw/#{dirname}.git", h.after
assert_equal "git remote add origin git@github.com:tpw/hub.git", h.after
end
def test_init_no_login
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册