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

port `checkout` tests to cukes

上级 3a852e9f
Feature: hub checkout <PULLREQ-URL>
Background:
Given I am in "git://github.com/mojombo/jekyll.git" git repo
And I am "mislav" on github.com with OAuth token "OTOKEN"
Scenario: Unchanged command
When I run `hub checkout master`
Then "git checkout master" should be run
Scenario: Checkout a pull request
Given the GitHub API server:
"""
get('/repos/mojombo/jekyll/pulls/77') {
json :head => {
:label => 'mislav:fixes',
:repo => { :private => false }
}
}
"""
When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q`
Then "git remote add -f -t fixes mislav git://github.com/mislav/jekyll.git" should be run
And "git checkout -f --track -B mislav-fixes mislav/fixes -q" should be run
Scenario: Custom name for new branch
Given the GitHub API server:
"""
get('/repos/mojombo/jekyll/pulls/77') {
json :head => {
:label => 'mislav:fixes',
:repo => { :private => false }
}
}
"""
When I run `hub checkout https://github.com/mojombo/jekyll/pull/77 fixes-from-mislav`
Then "git remote add -f -t fixes mislav git://github.com/mislav/jekyll.git" should be run
And "git checkout --track -B fixes-from-mislav mislav/fixes" should be run
Scenario: Private pull request
Given the GitHub API server:
"""
get('/repos/mojombo/jekyll/pulls/77') {
json :head => {
:label => 'mislav:fixes',
:repo => { :private => true }
}
}
"""
When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q`
Then "git remote add -f -t fixes mislav git@github.com:mislav/jekyll.git" should be run
And "git checkout -f --track -B mislav-fixes mislav/fixes -q" should be run
Scenario: Custom name for new branch
Given the GitHub API server:
"""
get('/repos/mojombo/jekyll/pulls/77') {
json :head => {
:label => 'mislav:fixes',
:repo => { :private => false }
}
}
"""
When I run `hub checkout https://github.com/mojombo/jekyll/pull/77 fixes-from-mislav`
Then "git remote add -f -t fixes mislav git://github.com/mislav/jekyll.git" should be run
And "git checkout --track -B fixes-from-mislav mislav/fixes" should be run
Scenario: Remote for user already exists
Given the GitHub API server:
"""
get('/repos/mojombo/jekyll/pulls/77') {
json :head => {
:label => 'mislav:fixes',
:repo => { :private => false }
}
}
"""
And the "mislav" remote has url "git://github.com/mislav/jekyll.git"
When I run `hub checkout https://github.com/mojombo/jekyll/pull/77`
Then "git remote set-branches --add mislav fixes" should be run
And "git fetch mislav +refs/heads/fixes:refs/remotes/mislav/fixes" should be run
And "git checkout --track -B mislav-fixes mislav/fixes" should be run
......@@ -444,49 +444,6 @@ class HubTest < Test::Unit::TestCase
assert_output expected, "pull-request hereyougo -b feature -f"
end
def test_checkout_no_changes
assert_forwarded "checkout master"
end
def test_checkout_pullrequest
stub_request(:get, "https://api.github.com/repos/defunkt/hub/pulls/73").
to_return(:body => mock_pull_response('blueyed:feature'))
assert_commands 'git remote add -f -t feature blueyed git://github.com/blueyed/hub.git',
'git checkout -f --track -B blueyed-feature blueyed/feature -q',
"checkout -f https://github.com/defunkt/hub/pull/73/files -q"
end
def test_checkout_private_pullrequest
stub_request(:get, "https://api.github.com/repos/defunkt/hub/pulls/73").
to_return(:body => mock_pull_response('blueyed:feature', :private))
assert_commands 'git remote add -f -t feature blueyed git@github.com:blueyed/hub.git',
'git checkout --track -B blueyed-feature blueyed/feature',
"checkout https://github.com/defunkt/hub/pull/73/files"
end
def test_checkout_pullrequest_custom_branch
stub_request(:get, "https://api.github.com/repos/defunkt/hub/pulls/73").
to_return(:body => mock_pull_response('blueyed:feature'))
assert_commands 'git remote add -f -t feature blueyed git://github.com/blueyed/hub.git',
'git checkout --track -B review blueyed/feature',
"checkout https://github.com/defunkt/hub/pull/73/files review"
end
def test_checkout_pullrequest_existing_remote
stub_command_output 'remote', "origin\nblueyed"
stub_request(:get, "https://api.github.com/repos/defunkt/hub/pulls/73").
to_return(:body => mock_pull_response('blueyed:feature'))
assert_commands 'git remote set-branches --add blueyed feature',
'git fetch blueyed +refs/heads/feature:refs/remotes/blueyed/feature',
'git checkout --track -B blueyed-feature blueyed/feature',
"checkout https://github.com/defunkt/hub/pull/73/files"
end
def test_version
out = hub('--version')
assert_includes "git version 1.7.0.4", out
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册