2019-05-18 22:48:38 +03:00
|
|
|
Feature: hub pr show
|
2019-06-14 16:33:50 +03:00
|
|
|
Background:
|
|
|
|
Given I am in "git://github.com/ashemesh/hub.git" git repo
|
|
|
|
And I am "ashemesh" on github.com with OAuth token "OTOKEN"
|
2019-05-18 22:48:38 +03:00
|
|
|
|
2019-06-14 16:33:50 +03:00
|
|
|
Scenario: Current branch
|
|
|
|
Given I am on the "topic" branch
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/ashemesh/hub/pulls'){
|
|
|
|
assert :state => "open",
|
|
|
|
:head => "ashemesh:topic"
|
|
|
|
json [
|
|
|
|
{ :html_url => "https://github.com/ashemesh/hub/pull/102" },
|
|
|
|
]
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I successfully run `hub pr show`
|
|
|
|
Then "open https://github.com/ashemesh/hub/pull/102" should be run
|
|
|
|
|
|
|
|
Scenario: Current branch output URL
|
|
|
|
Given I am on the "topic" branch
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/ashemesh/hub/pulls'){
|
|
|
|
assert :state => "open",
|
|
|
|
:head => "ashemesh:topic"
|
|
|
|
json [
|
|
|
|
{ :html_url => "https://github.com/ashemesh/hub/pull/102" },
|
|
|
|
]
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I successfully run `hub pr show -u`
|
|
|
|
Then "open https://github.com/ashemesh/hub/pull/102" should not be run
|
|
|
|
And the output should contain exactly:
|
|
|
|
"""
|
|
|
|
https://github.com/ashemesh/hub/pull/102\n
|
|
|
|
"""
|
2019-05-18 22:48:38 +03:00
|
|
|
|
2019-06-14 16:33:50 +03:00
|
|
|
Scenario: Current branch in fork
|
|
|
|
Given the "upstream" remote has url "git@github.com:github/hub.git"
|
2019-06-14 17:05:45 +03:00
|
|
|
And I am on the "topic" branch pushed to "origin/topic"
|
2019-05-18 22:48:38 +03:00
|
|
|
Given the GitHub API server:
|
2019-06-14 16:33:50 +03:00
|
|
|
"""
|
|
|
|
get('/repos/github/hub/pulls'){
|
|
|
|
assert :state => "open",
|
|
|
|
:head => "ashemesh:topic"
|
|
|
|
json [
|
|
|
|
{ :html_url => "https://github.com/github/hub/pull/102" },
|
|
|
|
]
|
|
|
|
}
|
|
|
|
"""
|
2019-05-18 22:48:38 +03:00
|
|
|
When I successfully run `hub pr show`
|
2019-06-14 16:33:50 +03:00
|
|
|
Then "open https://github.com/github/hub/pull/102" should be run
|
2019-05-18 22:48:38 +03:00
|
|
|
|
2019-06-14 16:33:50 +03:00
|
|
|
Scenario: Explicit head branch
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/ashemesh/hub/pulls'){
|
|
|
|
assert :state => "open",
|
|
|
|
:head => "ashemesh:topic"
|
|
|
|
json [
|
|
|
|
{ :html_url => "https://github.com/ashemesh/hub/pull/102" },
|
|
|
|
]
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I successfully run `hub pr show --head topic`
|
|
|
|
Then "open https://github.com/ashemesh/hub/pull/102" should be run
|
2019-05-18 22:48:38 +03:00
|
|
|
|
2019-06-14 16:33:50 +03:00
|
|
|
Scenario: Explicit head branch with owner
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/ashemesh/hub/pulls'){
|
|
|
|
assert :state => "open",
|
|
|
|
:head => "github:topic"
|
|
|
|
json [
|
|
|
|
{ :html_url => "https://github.com/ashemesh/hub/pull/102" },
|
|
|
|
]
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I successfully run `hub pr show --head github:topic`
|
|
|
|
Then "open https://github.com/ashemesh/hub/pull/102" should be run
|
2019-06-14 17:08:13 +03:00
|
|
|
|
|
|
|
Scenario: No pull request found
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/ashemesh/hub/pulls'){
|
|
|
|
json []
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I run `hub pr show --head topic`
|
|
|
|
Then the exit status should be 1
|
|
|
|
And the stderr should contain exactly:
|
|
|
|
"""
|
|
|
|
no open pull requests found for branch 'ashemesh:topic'\n
|
|
|
|
"""
|
2019-06-14 17:32:58 +03:00
|
|
|
|
|
|
|
Scenario: Show pull request by number
|
|
|
|
When I successfully run `hub pr show 102`
|
|
|
|
Then "open https://github.com/ashemesh/hub/pull/102" should be run
|
|
|
|
|
|
|
|
Scenario: Show pull request by invalid number
|
|
|
|
When I run `hub pr show XYZ`
|
|
|
|
Then the exit status should be 1
|
|
|
|
And the stderr should contain exactly:
|
|
|
|
"""
|
|
|
|
invalid pull request number: 'XYZ'\n
|
|
|
|
"""
|