Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
7f583557
H
hub
项目概览
github
/
hub
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
7f583557
编写于
10月 19, 2010
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
simplify webmock stubs for repo create requests
Also, new version of webmock deprecates including the "WebMock" module
上级
58ecb29d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
22 deletion
+27
-22
test/hub_test.rb
test/hub_test.rb
+27
-22
未找到文件。
test/hub_test.rb
浏览文件 @
7f583557
...
...
@@ -2,8 +2,18 @@ $LOAD_PATH.unshift File.dirname(__FILE__)
require
'helper'
require
'webmock/test_unit'
WebMock
::
BodyPattern
.
class_eval
do
undef
normalize_hash
# override normalizing hash since it otherwise requires JSON
def
normalize_hash
(
hash
)
hash
end
end
class
HubTest
<
Test
::
Unit
::
TestCase
include
WebMock
if
defined?
WebMock
::
API
include
WebMock
::
API
else
include
WebMock
end
COMMANDS
=
[]
...
...
@@ -385,10 +395,9 @@ class HubTest < Test::Unit::TestCase
def
test_create
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"github.com/api/v2/yaml/repos/create"
).
with
{
|
req
|
params
=
Hash
[
*
req
.
body
.
split
(
/[&=]/
)]
params
==
{
'login'
=>
'tpw'
,
'token'
=>
'abc123'
,
'name'
=>
'hub'
}
}
stub_request
(
:post
,
"github.com/api/v2/yaml/repos/create"
).
with
(
:body
=>
{
'login'
=>
'tpw'
,
'token'
=>
'abc123'
,
'name'
=>
'hub'
})
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'
}
...
...
@@ -397,10 +406,9 @@ class HubTest < Test::Unit::TestCase
def
test_create_private_repository
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"github.com/api/v2/yaml/repos/create"
).
with
{
|
req
|
params
=
Hash
[
*
req
.
body
.
split
(
/[&=]/
)]
params
==
{
'login'
=>
'tpw'
,
'token'
=>
'abc123'
,
'name'
=>
'hub'
,
'public'
=>
'0'
}
}
stub_request
(
:post
,
"github.com/api/v2/yaml/repos/create"
).
with
(
:body
=>
{
'login'
=>
'tpw'
,
'token'
=>
'abc123'
,
'name'
=>
'hub'
,
'public'
=>
'0'
})
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'
}
...
...
@@ -409,13 +417,14 @@ class HubTest < Test::Unit::TestCase
def
test_create_with_description_and_homepage
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"github.com/api/v2/yaml/repos/create"
).
with
{
|
req
|
params
=
Hash
[
*
req
.
body
.
split
(
/[&=]/
)]
params
==
{
'login'
=>
'tpw'
,
'token'
=>
'abc123'
,
'name'
=>
'hub'
,
'description'
=>
'description'
,
'homepage'
=>
'http%3a%2f%2fgithub.com%2ftpw%2fhub.git'
}
}
stub_request
(
:post
,
"github.com/api/v2/yaml/repos/create"
).
with
(
:body
=>
{
'login'
=>
'tpw'
,
'token'
=>
'abc123'
,
'name'
=>
'hub'
,
'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
description -h http://github.com/tpw/hub.git
"
)
{
ENV
[
'GIT'
]
=
'echo'
}
assert_equal
expected
,
hub
(
"create -d
toyproject -h http://example.com
"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_with_existing_repository
...
...
@@ -443,10 +452,8 @@ class HubTest < Test::Unit::TestCase
def
test_create_origin_already_exists
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"github.com/api/v2/yaml/repos/create"
).
with
{
|
req
|
params
=
Hash
[
*
req
.
body
.
split
(
/[&=]/
)]
params
==
{
'login'
=>
'tpw'
,
'token'
=>
'abc123'
,
'name'
=>
'hub'
}
}
stub_request
(
:post
,
"github.com/api/v2/yaml/repos/create"
).
with
(
:body
=>
{
'login'
=>
'tpw'
,
'token'
=>
'abc123'
,
'name'
=>
'hub'
})
expected
=
"remote -v
\n
created repository: tpw/hub
\n
"
assert_equal
expected
,
hub
(
"create"
)
{
ENV
[
'GIT'
]
=
'echo'
}
...
...
@@ -454,10 +461,8 @@ class HubTest < Test::Unit::TestCase
def
test_fork
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"github.com/api/v2/yaml/repos/fork/defunkt/hub"
).
with
{
|
req
|
params
=
Hash
[
*
req
.
body
.
split
(
/[&=]/
)]
params
==
{
'login'
=>
'tpw'
,
'token'
=>
'abc123'
}
}
stub_request
(
:post
,
"github.com/api/v2/yaml/repos/fork/defunkt/hub"
).
with
(
:body
=>
{
'login'
=>
'tpw'
,
'token'
=>
'abc123'
})
expected
=
"remote add -f tpw git@github.com:tpw/hub.git
\n
"
expected
<<
"new remote: tpw
\n
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录