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

Port `hub browse` SSH-related scenarios to cukes

上级 fefefa20
......@@ -173,3 +173,24 @@ Feature: hub browse
And "git.my.org" is a whitelisted Enterprise host
When I successfully run `hub browse`
Then "open http://git.my.org/mislav/dotfiles" should be run
Scenario: SSH alias
Given the SSH config:
"""
Host gh
User git
HostName github.com
"""
Given I am in "gh:singingwolfboy/sekrit.git" git repo
When I successfully run `hub browse`
Then "open https://github.com/singingwolfboy/sekrit" should be run
Scenario: SSH GitHub alias
Given the SSH config:
"""
Host github.com
HostName ssh.github.com
"""
Given I am in "git@github.com:suan/git-sanity.git" git repo
When I successfully run `hub browse`
Then "open https://github.com/suan/git-sanity" should be run
......@@ -41,7 +41,7 @@ Given(/^\$(\w+) is "([^"]*)"$/) do |name, value|
end
Given(/^I am in "([^"]*)" git repo$/) do |dir_name|
if dir_name.include? '://'
if dir_name.include?(':')
origin_url = dir_name
dir_name = File.basename origin_url, '.git'
end
......@@ -239,3 +239,9 @@ end
Given(/^the git commit editor is "([^"]+)"$/) do |cmd|
set_env('GIT_EDITOR', cmd)
end
Given(/^the SSH config:$/) do |config_lines|
ssh_config = "#{ENV['HOME']}/.ssh/config"
FileUtils.mkdir_p(File.dirname(ssh_config))
File.open(ssh_config, 'w') {|f| f << config_lines }
end
......@@ -267,25 +267,6 @@ class HubTest < Minitest::Test
assert_includes 'This file is generated code', hub("hub standalone")
end
def test_hub_browse_no_repo
stub_repo_url(nil)
assert_equal "Usage: hub browse [<USER>/]<REPOSITORY>\n", hub("browse")
end
def test_hub_browse_ssh_alias
with_ssh_config "Host gh\n User git\n HostName github.com" do
stub_repo_url "gh:singingwolfboy/sekrit.git"
assert_command "browse", "open https://github.com/singingwolfboy/sekrit"
end
end
def test_hub_browse_ssh_github_alias
with_ssh_config "Host github.com\n HostName ssh.github.com" do
stub_repo_url "git@github.com:suan/git-sanity.git"
assert_command "browse", "open https://github.com/suan/git-sanity"
end
end
def test_custom_browser
with_browser_env("custom") do
assert_browser("custom")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册