Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
ee8b35d8
H
hub
项目概览
github
/
hub
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
ee8b35d8
编写于
5月 08, 2012
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rewrite `hub create` tests as cukes
上级
b90b16b7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
102 addition
and
120 deletion
+102
-120
features/create.feature
features/create.feature
+102
-0
test/hub_test.rb
test/hub_test.rb
+0
-120
未找到文件。
features/create.feature
0 → 100644
浏览文件 @
ee8b35d8
Feature
:
hub create
Background
:
Given
I am in
"dotfiles"
git repo
And
I am
"mislav"
on github.com with OAuth token
"OTOKEN"
Scenario
:
Create repo
Given the GitHub API server
:
"""
post('/user/repos') {
halt 400 if params[:private]
status 200
}
"""
When
I successfully run `hub create`
Then the url for "origin" should be "git@github.com
:
mislav/dotfiles.git"
And the output should contain exactly "created repository
:
mislav/dotfiles\n"
Scenario
:
Create private repo
Given the GitHub API server
:
"""
post('/user/repos') {
halt 400 unless params[:private]
status 200
}
"""
When
I successfully run `hub create -p`
Then the url for "origin" should be "git@github.com
:
mislav/dotfiles.git"
Scenario
:
HTTPS is preferred
Given the GitHub API server
:
"""
post('/user/repos') { status 200 }
"""
And
HTTPS is preferred
When
I successfully run `hub create`
Then the url for "origin" should be "https
:
//github.com/mislav/dotfiles.git"
Scenario
:
Create in organization
Given the GitHub API server
:
"""
post('/orgs/acme/repos') { status 200 }
"""
When
I successfully run `hub create acme/dotfiles`
Then the url for "origin" should be "git@github.com
:
acme/dotfiles.git"
And the output should contain exactly "created repository
:
acme/dotfiles\n"
Scenario
:
Creating repo failed
Given the GitHub API server
:
"""
post('/user/repos') { status 500 }
"""
When
I run `hub create`
Then the stderr should contain "Error creating repository
:
Internal
Server
Error
(HTTP
500)"
And
the exit status should be 1
And
there should be no
"origin"
remote
Scenario
:
With custom name
Given the GitHub API server
:
"""
post('/user/repos') {
halt 400 unless params[:name] == 'myconfig'
status 200
}
"""
When
I successfully run `hub create myconfig`
Then the url for "origin" should be "git@github.com
:
mislav/myconfig.git"
Scenario
:
With description and homepage
Given the GitHub API server
:
"""
post('/user/repos') {
halt 400 unless params[:description] == 'mydesc' and
params[:homepage] == 'http://example.com'
status 200
}
"""
When I successfully run `hub create -d mydesc -h http
:
//example.com`
Then the url for "origin" should be "git@github.com
:
mislav/dotfiles.git"
Scenario
:
Not in git repo
Given
the current dir is not a repo
When
I run `hub create`
Then
the stderr should contain
"'create' must be run from inside a git repository"
And
the exit status should be 1
Scenario
:
Origin remote already exists
Given the GitHub API server
:
"""
post('/user/repos') { status 200 }
"""
And the "origin" remote has url "git
:
//github.com/mislav/dotfiles.git"
When
I successfully run `hub create`
Then the url for "origin" should be "git
:
//github.com/mislav/dotfiles.git"
Scenario
:
GitHub repo already exists
Given the GitHub API server
:
"""
get('/repos/mislav/dotfiles') { status 200 }
"""
When
I successfully run `hub create`
Then
the output should contain
"mislav/dotfiles already exists on github.com\n"
And the url for "origin" should be "git@github.com
:
mislav/dotfiles.git"
test/hub_test.rb
浏览文件 @
ee8b35d8
...
...
@@ -244,126 +244,6 @@ class HubTest < Test::Unit::TestCase
"push origin,staging,qa cool-feature"
end
def
test_create
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"https://api.github.com/user/repos"
).
with
(
:body
=>
{
'name'
=>
'hub'
,
'private'
=>
false
})
expected
=
"remote add -f origin git@github.com:tpw/hub.git
\n
"
expected
<<
"created repository: tpw/hub
\n
"
assert_equal
expected
,
hub
(
"create"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_custom_name
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
,
'hubbub'
)
stub_request
(
:post
,
"https://api.github.com/user/repos"
).
with
(
:body
=>
{
'name'
=>
'hubbub'
,
'private'
=>
false
})
expected
=
"remote add -f origin git@github.com:tpw/hubbub.git
\n
"
expected
<<
"created repository: tpw/hubbub
\n
"
assert_equal
expected
,
hub
(
"create hubbub"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_in_organization
stub_no_remotes
stub_nonexisting_fork
(
'acme'
,
'hubbub'
)
stub_request
(
:post
,
"https://api.github.com/orgs/acme/repos"
).
with
(
:body
=>
{
'name'
=>
'hubbub'
,
'private'
=>
false
})
expected
=
"remote add -f origin git@github.com:acme/hubbub.git
\n
"
expected
<<
"created repository: acme/hubbub
\n
"
assert_equal
expected
,
hub
(
"create acme/hubbub"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_failed
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"https://api.github.com/user/repos"
).
to_return
(
:status
=>
[
401
,
"Your token is fail"
])
expected
=
"Error creating repository: Your token is fail (HTTP 401)
\n
"
assert_equal
expected
,
hub
(
"create"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_private_repository
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"https://api.github.com/user/repos"
).
with
(
:body
=>
{
'name'
=>
'hub'
,
'private'
=>
true
})
expected
=
"remote add -f origin git@github.com:tpw/hub.git
\n
"
expected
<<
"created repository: tpw/hub
\n
"
assert_equal
expected
,
hub
(
"create -p"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_private_repository_fails
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"https://api.github.com/user/repos"
).
to_return
(
:status
=>
[
422
,
"Unprocessable Entity"
],
:headers
=>
{
"Content-type"
=>
"application/json"
},
:body
=>
%({"message":"repository creation failed: You are over your quota."})
)
expected
=
"Error creating repository: Unprocessable Entity (HTTP 422)
\n
"
expected
<<
"repository creation failed: You are over your quota.
\n
"
assert_equal
expected
,
hub
(
"create -p"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_with_description_and_homepage
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"https://api.github.com/user/repos"
).
with
(
:body
=>
{
'name'
=>
'hub'
,
'private'
=>
false
,
'description'
=>
'toyproject'
,
'homepage'
=>
'http://example.com'
})
expected
=
"remote add -f origin git@github.com:tpw/hub.git
\n
"
expected
<<
"created repository: tpw/hub
\n
"
assert_equal
expected
,
hub
(
"create -d toyproject -h http://example.com"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_with_invalid_arguments
assert_equal
"invalid argument: -a
\n
"
,
hub
(
"create -a blah"
)
{
ENV
[
'GIT'
]
=
'echo'
}
assert_equal
"invalid argument: bleh
\n
"
,
hub
(
"create blah bleh"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_with_existing_repository
stub_no_remotes
stub_existing_fork
(
'tpw'
)
expected
=
"tpw/hub already exists on github.com
\n
"
expected
<<
"remote add -f origin git@github.com:tpw/hub.git
\n
"
expected
<<
"set remote origin: tpw/hub
\n
"
assert_equal
expected
,
hub
(
"create"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_https_protocol
stub_no_remotes
stub_existing_fork
(
'tpw'
)
stub_https_is_preferred
expected
=
"tpw/hub already exists on github.com
\n
"
expected
<<
"remote add -f origin https://github.com/tpw/hub.git
\n
"
expected
<<
"set remote origin: tpw/hub
\n
"
assert_equal
expected
,
hub
(
"create"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_outside_git_repo
stub_no_git_repo
assert_equal
"'create' must be run from inside a git repository
\n
"
,
hub
(
"create"
)
end
def
test_create_origin_already_exists
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"https://api.github.com/user/repos"
).
with
(
:body
=>
{
'name'
=>
'hub'
,
'private'
=>
false
})
expected
=
"remote -v
\n
created repository: tpw/hub
\n
"
assert_equal
expected
,
hub
(
"create"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_pullrequest
expected
=
"Aborted: head branch is the same as base (
\"
master
\"
)
\n
"
<<
"(use `-h <branch>` to specify an explicit pull request head)
\n
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录