Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
c66ecfe0
H
hub
项目概览
github
/
hub
接近 1 年 前同步成功
通知
3
Star
22523
Fork
2406
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c66ecfe0
编写于
12月 08, 2009
作者:
C
Chris Wanstrath
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
basic install tests passing for shells
上级
e48d374b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
8 deletion
+48
-8
lib/hub/commands.rb
lib/hub/commands.rb
+12
-2
test/helper.rb
test/helper.rb
+21
-0
test/install_test.rb
test/install_test.rb
+15
-6
未找到文件。
lib/hub/commands.rb
浏览文件 @
c66ecfe0
...
...
@@ -89,7 +89,17 @@ module Hub
'fish'
=>
'alias git hub'
}
shell
=
args
[
1
]
if
shell
=
args
[
1
]
puts
"Run this in your shell to start using `hub` as `git`:"
print
" "
else
puts
"usage: hub install SHELL"
,
""
puts
"known shells:"
shells
.
map
{
|
key
,
_
|
key
}.
sort
.
each
do
|
key
|
puts
" "
+
key
end
exit
end
if
shells
[
shell
]
puts
shells
[
shell
]
...
...
@@ -162,7 +172,7 @@ help
# All calls to `puts` in after hooks or commands are paged,
# git-style.
def
puts
(
content
)
def
puts
(
*
args
)
page_stdout
super
end
...
...
test/helper.rb
浏览文件 @
c66ecfe0
...
...
@@ -44,4 +44,25 @@ class Test::Unit::TestCase
def
assert_command
(
input
,
expected
)
assert_equal
expected
,
Hub
(
input
).
command
end
# Asserts that `hub` will show a specific installation command for a
# specific shell.
#
# e.g.
# assert_install_command "sh", "alias git=hub"
#
# Here we are saying that this:
# $ hub install sh
# Should display this:
# Run this in your shell to start using `hub` as `git`:
# alias git=hub
def
assert_install_command
(
shell
,
command
)
expected
=
"Run this in your shell to start using `hub` as `git`:
\n
%s
\n
"
assert_equal
(
expected
%
command
,
hub
(
"install
#{
shell
}
"
))
end
# Asserts that `haystack` includes `needle`.
def
assert_includes
(
needle
,
haystack
)
assert
haystack
.
include?
(
needle
)
end
end
test/install_test.rb
浏览文件 @
c66ecfe0
...
...
@@ -2,27 +2,36 @@ $LOAD_PATH.unshift File.dirname(__FILE__)
require
'helper'
class
InstallTest
<
Test
::
Unit
::
TestCase
def
test_install
instructions
=
hub
(
"install"
)
assert_includes
"bash"
,
instructions
assert_includes
"sh"
,
instructions
assert_includes
"csh"
,
instructions
assert_includes
"zsh"
,
instructions
assert_includes
"fish"
,
instructions
end
def
test_install_bash
assert_
equal
"alias git=hub
\n
"
,
hub
(
"install bash"
)
assert_
install_command
"bash"
,
"alias git=hub"
end
def
test_install_sh
assert_
equal
"alias git=hub
\n
"
,
hub
(
"install sh"
)
assert_
install_command
"sh"
,
"alias git=hub"
end
def
test_install_zsh
assert_
equal
"alias git=hub
\n
"
,
hub
(
"install zsh"
)
assert_
install_command
"zsh"
,
"alias git=hub"
end
def
test_install_csh
assert_
equal
"alias git hub
\n
"
,
hub
(
"install csh"
)
assert_
install_command
"csh"
,
"alias git hub"
end
def
test_install_fish
assert_
equal
"alias git hub
\n
"
,
hub
(
"install fish"
)
assert_
install_command
"fish"
,
"alias git hub"
end
def
test_install_blah
assert_
equal
"fatal: never heard of `blah'
\n
"
,
hub
(
"install blah"
)
assert_
install_command
"blah"
,
"fatal: never heard of `blah'"
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录