checkout.feature 2.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
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') {
14
        halt 406 unless request.env['HTTP_ACCEPT'] == 'application/vnd.github.v3+json;charset=utf-8'
15
        json :head => {
16
          :ref => "fixes",
17
          :repo => {
18
            :owner => { :login => "mislav" },
19
            :name => "jekyll",
20 21
            :private => false
          }
22 23 24 25 26 27
        }, :base => {
          :repo => {
            :name => 'jekyll',
            :html_url => 'https://github.com/mojombo/jekyll',
            :owner => { :login => "mojombo" },
          }
28 29 30 31
        }
      }
      """
    When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q`
32
    Then "git fetch origin pull/77/head:mislav-fixes" should be run
33
    And "git checkout -f mislav-fixes -q" should be run
34

35
  Scenario: No matching remotes for pull request base
36 37
    Given the GitHub API server:
      """
38 39
      get('/repos/mislav/jekyll/pulls/77') {
        json :base => {
40
          :repo => {
41 42
            :name => 'jekyll',
            :html_url => 'https://github.com/mislav/jekyll',
43
            :owner => { :login => "mislav" },
44 45 46 47
          }
        }
      }
      """
48 49 50
    When I run `hub checkout -f https://github.com/mislav/jekyll/pull/77 -q`
    Then the exit status should be 1
    And the stderr should contain exactly:
51
      """
52
      could not find git remote for mislav/jekyll\n
53 54
      """

55
  Scenario: Custom name for new branch
56 57 58 59
    Given the GitHub API server:
      """
      get('/repos/mojombo/jekyll/pulls/77') {
        json :head => {
60
          :ref => "fixes",
61
          :repo => {
62
            :name => "jekyll",
63
            :owner => { :login => "mislav" },
64
          }
65
        }, :base => {
66
          :repo => {
67 68 69
            :name => 'jekyll',
            :html_url => 'https://github.com/mojombo/jekyll',
            :owner => { :login => "mojombo" },
70
          }
71 72 73
        }
      }
      """
74 75 76
    When I run `hub checkout https://github.com/mojombo/jekyll/pull/77 fixes-from-mislav`
    Then "git fetch origin pull/77/head:fixes-from-mislav" should be run
    And "git checkout fixes-from-mislav" should be run