github.com/scorpionis/hub@v2.2.1+incompatible/features/create.feature (about) 1 Feature: hub create 2 Background: 3 Given I am in "dotfiles" git repo 4 And I am "mislav" on github.com with OAuth token "OTOKEN" 5 6 Scenario: Create repo 7 Given the GitHub API server: 8 """ 9 post('/user/repos') { 10 assert :private => false 11 json :full_name => 'mislav/dotfiles' 12 } 13 """ 14 When I successfully run `hub create` 15 Then the url for "origin" should be "git@github.com:mislav/dotfiles.git" 16 And the output should contain exactly "created repository: mislav/dotfiles\n" 17 18 Scenario: Create private repo 19 Given the GitHub API server: 20 """ 21 post('/user/repos') { 22 assert :private => true 23 json :full_name => 'mislav/dotfiles' 24 } 25 """ 26 When I successfully run `hub create -p` 27 Then the url for "origin" should be "git@github.com:mislav/dotfiles.git" 28 29 Scenario: HTTPS is preferred 30 Given the GitHub API server: 31 """ 32 post('/user/repos') { 33 json :full_name => 'mislav/dotfiles' 34 } 35 """ 36 And HTTPS is preferred 37 When I successfully run `hub create` 38 Then the url for "origin" should be "https://github.com/mislav/dotfiles.git" 39 40 Scenario: Create in organization 41 Given the GitHub API server: 42 """ 43 post('/orgs/acme/repos') { 44 json :full_name => 'acme/dotfiles' 45 } 46 """ 47 When I successfully run `hub create acme/dotfiles` 48 Then the url for "origin" should be "git@github.com:acme/dotfiles.git" 49 And the output should contain exactly "created repository: acme/dotfiles\n" 50 51 Scenario: Creating repo failed 52 Given the GitHub API server: 53 """ 54 post('/user/repos') { status 500 } 55 """ 56 When I run `hub create` 57 Then the stderr should contain "Error creating repository: Internal Server Error (HTTP 500)" 58 And the exit status should be 1 59 And there should be no "origin" remote 60 61 Scenario: With custom name 62 Given the GitHub API server: 63 """ 64 post('/user/repos') { 65 assert :name => 'myconfig' 66 json :full_name => 'mislav/myconfig' 67 } 68 """ 69 When I successfully run `hub create myconfig` 70 Then the url for "origin" should be "git@github.com:mislav/myconfig.git" 71 72 Scenario: With description and homepage 73 Given the GitHub API server: 74 """ 75 post('/user/repos') { 76 assert :description => 'mydesc', 77 :homepage => 'http://example.com' 78 json :full_name => 'mislav/dotfiles' 79 } 80 """ 81 When I successfully run `hub create -d mydesc -h http://example.com` 82 Then the url for "origin" should be "git@github.com:mislav/dotfiles.git" 83 84 Scenario: Not in git repo 85 Given the current dir is not a repo 86 When I run `hub create` 87 Then the stderr should contain "'create' must be run from inside a git repository" 88 And the exit status should be 1 89 90 Scenario: Origin remote already exists 91 Given the GitHub API server: 92 """ 93 post('/user/repos') { 94 json :full_name => 'mislav/dotfiles' 95 } 96 """ 97 And the "origin" remote has url "git://github.com/mislav/dotfiles.git" 98 When I successfully run `hub create` 99 Then the url for "origin" should be "git://github.com/mislav/dotfiles.git" 100 101 Scenario: Another remote already exists 102 Given the GitHub API server: 103 """ 104 post('/user/repos') { 105 json :full_name => 'mislav/dotfiles' 106 } 107 """ 108 And the "github" remote has url "git://github.com/mislav/dotfiles.git" 109 When I successfully run `hub create` 110 Then the url for "origin" should be "git@github.com:mislav/dotfiles.git" 111 112 Scenario: GitHub repo already exists 113 Given the GitHub API server: 114 """ 115 get('/repos/mislav/dotfiles') { status 200 } 116 """ 117 When I successfully run `hub create` 118 Then the output should contain "mislav/dotfiles already exists on github.com\n" 119 And the url for "origin" should be "git@github.com:mislav/dotfiles.git" 120 121 Scenario: API response changes the clone URL 122 Given the GitHub API server: 123 """ 124 post('/user/repos') { 125 json :full_name => 'Mooslav/myconfig' 126 } 127 """ 128 When I successfully run `hub create` 129 Then the url for "origin" should be "git@github.com:Mooslav/myconfig.git" 130 And the output should contain exactly "created repository: Mooslav/myconfig\n" 131 132 Scenario: Current directory contains spaces 133 Given I am in "my dot files" git repo 134 Given the GitHub API server: 135 """ 136 post('/user/repos') { 137 assert :name => 'my-dot-files' 138 json :full_name => 'mislav/my-dot-files' 139 } 140 """ 141 When I successfully run `hub create` 142 Then the url for "origin" should be "git@github.com:mislav/my-dot-files.git" 143 144 Scenario: Verbose API output 145 Given the GitHub API server: 146 """ 147 get('/repos/mislav/dotfiles') { status 404 } 148 post('/user/repos') { 149 response['location'] = 'http://disney.com' 150 json :full_name => 'mislav/dotfiles' 151 } 152 """ 153 And $HUB_VERBOSE is "on" 154 When I successfully run `hub create` 155 Then the stderr should contain: 156 """ 157 > GET https://api.github.com/repos/mislav/dotfiles 158 > Authorization: token [REDACTED] 159 < HTTP 404 160 """ 161 And the stderr should contain: 162 """ 163 > POST https://api.github.com/user/repos 164 > Authorization: token [REDACTED] 165 """ 166 And the stderr should contain: 167 """ 168 < HTTP 200 169 < Location: http://disney.com 170 {"full_name":"mislav/dotfiles"}\n 171 """