github.com/pengwynn/gh@v1.0.1-0.20140118055701-14327ca3942e/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 => nil 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: GitHub repo already exists 102 Given the GitHub API server: 103 """ 104 get('/repos/mislav/dotfiles') { json :url => "foo" } 105 """ 106 When I successfully run `hub create` 107 Then the output should contain "mislav/dotfiles already exists on github.com\n" 108 And the url for "origin" should be "git@github.com:mislav/dotfiles.git" 109 110 Scenario: API response changes the clone URL 111 Given the GitHub API server: 112 """ 113 post('/user/repos') { 114 json :full_name => 'Mooslav/myconfig' 115 } 116 """ 117 When I successfully run `hub create` 118 Then the url for "origin" should be "git@github.com:Mooslav/myconfig.git" 119 And the output should contain exactly "created repository: Mooslav/myconfig\n" 120 121 Scenario: Current directory contains spaces 122 Given I am in "my dot files" git repo 123 Given the GitHub API server: 124 """ 125 post('/user/repos') { 126 assert :name => 'my-dot-files' 127 json :full_name => 'mislav/my-dot-files' 128 } 129 """ 130 When I successfully run `hub create` 131 Then the url for "origin" should be "git@github.com:mislav/my-dot-files.git"