forked from mislav/hub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite
clone
, remote add
, submodule add
tests as cukes
- Loading branch information
Showing
5 changed files
with
280 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
Feature: hub clone | ||
Scenario: Clone a public repo | ||
When I successfully run `hub clone rtomayko/ronn` | ||
Then it should clone "git://github.com/rtomayko/ronn.git" | ||
And there should be no output | ||
|
||
Scenario: Clone a public repo with period in name | ||
When I successfully run `hub clone hookio/hook.js` | ||
Then it should clone "git://github.com/hookio/hook.js.git" | ||
And there should be no output | ||
|
||
Scenario: Clone a public repo with HTTPS | ||
Given HTTPS is preferred | ||
When I successfully run `hub clone rtomayko/ronn` | ||
Then it should clone "https://github.com/rtomayko/ronn.git" | ||
And there should be no output | ||
|
||
Scenario: Clone command aliased | ||
When I successfully run `git config --global alias.c "clone --bare"` | ||
And I successfully run `hub c rtomayko/ronn` | ||
Then "git clone --bare git://github.com/rtomayko/ronn.git" should be run | ||
And there should be no output | ||
|
||
Scenario: Unchanged public clone | ||
When I successfully run `hub clone git://github.com/rtomayko/ronn.git` | ||
Then the git command should be unchanged | ||
|
||
Scenario: Unchanged public clone with path | ||
When I successfully run `hub clone git://github.com/rtomayko/ronn.git ronnie` | ||
Then the git command should be unchanged | ||
And there should be no output | ||
|
||
Scenario: Unchanged private clone | ||
When I successfully run `hub clone git@github.com:rtomayko/ronn.git` | ||
Then the git command should be unchanged | ||
And there should be no output | ||
|
||
Scenario: Unchanged clone with complex arguments | ||
When I successfully run `hub clone --template=one/two git://github.com/defunkt/resque.git --origin master resquetastic` | ||
Then the git command should be unchanged | ||
And there should be no output | ||
|
||
Scenario: Unchanged local clone | ||
When I successfully run `hub clone ./dotfiles` | ||
Then the git command should be unchanged | ||
And there should be no output | ||
|
||
Scenario: Unchanged local clone with destination | ||
When I successfully run `hub clone -l . ../copy` | ||
Then the git command should be unchanged | ||
And there should be no output | ||
|
||
Scenario: Unchanged clone with host alias | ||
When I successfully run `hub clone shortcut:git/repo.git` | ||
Then the git command should be unchanged | ||
And there should be no output | ||
|
||
Scenario: Preview cloning a private repo | ||
When I successfully run `hub --noop clone -p rtomayko/ronn` | ||
Then the output should contain exactly "git clone git@github.com:rtomayko/ronn.git\n" | ||
But nothing should be run | ||
|
||
Scenario: Clone a private repo | ||
When I successfully run `hub clone -p rtomayko/ronn` | ||
Then it should clone "git@github.com:rtomayko/ronn.git" | ||
And there should be no output | ||
|
||
Scenario: Clone my repo | ||
Given I am "mislav" on GitHub.com | ||
When I successfully run `hub clone dotfiles` | ||
Then it should clone "git@github.com:mislav/dotfiles.git" | ||
And there should be no output | ||
|
||
Scenario: Clone my repo with arguments | ||
Given I am "mislav" on GitHub.com | ||
When I successfully run `hub clone --bare -o master dotfiles` | ||
Then "git clone --bare -o master git@github.com:mislav/dotfiles.git" should be run | ||
And there should be no output | ||
|
||
Scenario: Clone my Enterprise repo | ||
Given I am "mifi" on git.my.org | ||
And $GITHUB_HOST is "git.my.org" | ||
When I successfully run `hub clone myrepo` | ||
Then it should clone "git@git.my.org:mifi/myrepo.git" | ||
And there should be no output | ||
|
||
Scenario: Clone from existing directory is a local clone | ||
Given a directory named "dotfiles" | ||
When I successfully run `hub clone dotfiles` | ||
Then the git command should be unchanged | ||
And there should be no output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
Feature: hub remote add | ||
Background: | ||
Given I am in "dotfiles" git repo | ||
|
||
Scenario: Add origin remote for my own repo | ||
Given I am "mislav" on GitHub.com | ||
And there are no remotes | ||
When I successfully run `hub remote add origin` | ||
Then the url for "origin" should be "git://github.com/mislav/dotfiles.git" | ||
And there should be no output | ||
|
||
Scenario: Add private origin remote for my own repo | ||
Given I am "mislav" on GitHub.com | ||
And there are no remotes | ||
When I successfully run `hub remote add -p origin` | ||
Then the url for "origin" should be "git@github.com:mislav/dotfiles.git" | ||
And there should be no output | ||
|
||
Scenario: Unchanged public remote add | ||
When I successfully run `hub remote add origin http://github.com/defunkt/resque.git` | ||
Then the url for "origin" should be "http://github.com/defunkt/resque.git" | ||
And there should be no output | ||
|
||
Scenario: Unchanged private remote add | ||
When I successfully run `hub remote add origin git@github.com:defunkt/resque.git` | ||
Then the url for "origin" should be "git@github.com:defunkt/resque.git" | ||
And there should be no output | ||
|
||
Scenario: Unchanged local path remote add | ||
When I successfully run `hub remote add myremote ./path` | ||
Then the git command should be unchanged | ||
And there should be no output | ||
|
||
Scenario: Unchanged local absolute path remote add | ||
When I successfully run `hub remote add myremote /path` | ||
Then the git command should be unchanged | ||
And there should be no output | ||
|
||
Scenario: Unchanged remote add with host alias | ||
When I successfully run `hub remote add myremote server:/git/repo.git` | ||
Then the git command should be unchanged | ||
And there should be no output | ||
|
||
Scenario: Add new remote for Enterprise repo | ||
Given "git.my.org" is a whitelisted Enterprise host | ||
And the "origin" remote has url "git@git.my.org:mislav/topsekrit.git" | ||
When I successfully run `hub remote add another` | ||
Then the url for "another" should be "git@git.my.org:another/topsekrit.git" | ||
And there should be no output | ||
|
||
Scenario: Add public remote | ||
When I successfully run `hub remote add mislav` | ||
Then the url for "mislav" should be "git://github.com/mislav/dotfiles.git" | ||
And there should be no output | ||
|
||
Scenario: Add private remote | ||
When I successfully run `hub remote add -p mislav` | ||
Then the url for "mislav" should be "git@github.com:mislav/dotfiles.git" | ||
And there should be no output | ||
|
||
Scenario: Add remote with arguments | ||
When I successfully run `hub remote add -f mislav` | ||
Then "git remote add -f mislav git://github.com/mislav/dotfiles.git" should be run | ||
And there should be no output | ||
|
||
Scenario: Add HTTPS protocol remote | ||
Given HTTPS is preferred | ||
When I successfully run `hub remote add mislav` | ||
Then the url for "mislav" should be "https://github.com/mislav/dotfiles.git" | ||
And there should be no output | ||
|
||
Scenario: Add named public remote | ||
When I successfully run `hub remote add mm mislav` | ||
Then the url for "mm" should be "git://github.com/mislav/dotfiles.git" | ||
And there should be no output | ||
|
||
Scenario: Add public remote including repo name | ||
When I successfully run `hub remote add mislav/dotfilez.js` | ||
Then the url for "mislav" should be "git://github.com/mislav/dotfilez.js.git" | ||
And there should be no output | ||
|
||
Scenario: Add named public remote including repo name | ||
When I successfully run `hub remote add mm mislav/dotfilez.js` | ||
Then the url for "mm" should be "git://github.com/mislav/dotfilez.js.git" | ||
And there should be no output | ||
|
||
Scenario: Add named private remote | ||
When I successfully run `hub remote add -p mm mislav` | ||
Then the url for "mm" should be "git@github.com:mislav/dotfiles.git" | ||
And there should be no output | ||
|
||
Scenario: Add private remote including repo name | ||
When I successfully run `hub remote add -p mislav/dotfilez.js` | ||
Then the url for "mislav" should be "git@github.com:mislav/dotfilez.js.git" | ||
And there should be no output | ||
|
||
Scenario: Add named private remote including repo name | ||
When I successfully run `hub remote add -p mm mislav/dotfilez.js` | ||
Then the url for "mm" should be "git@github.com:mislav/dotfilez.js.git" | ||
And there should be no output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
Given /^HTTPS is preferred$/ do | ||
run_silent %(git config --global hub.protocol https) | ||
end | ||
|
||
Given /^there are no remotes$/ do | ||
run_silent('git remote').should be_empty | ||
end | ||
|
||
Given /^"([^"]*)" is a whitelisted Enterprise host$/ do |host| | ||
run_silent %(git config --global --add hub.host "#{host}") | ||
end | ||
|
||
Given /^the "([^"]*)" remote has url "([^"]*)"$/ do |remote_name, url| | ||
run_silent %(git remote add #{remote_name} "#{url}") | ||
end | ||
|
||
Given /^I am "([^"]*)" on ([\w.-]+)$/ do |name, host| | ||
edit_hub_config do |cfg| | ||
cfg[host.downcase] = [{'user' => name}] | ||
end | ||
end | ||
|
||
Given /^\$(\w+) is "([^"]*)"$/ do |name, value| | ||
set_env name, value | ||
end | ||
|
||
Given /^I am in "([^"]*)" git repo$/ do |dir_name| | ||
step %(a git repo in "#{dir_name}") | ||
step %(I cd to "#{dir_name}") | ||
end | ||
|
||
Given /^a git repo in "([^"]*)"$/ do |dir_name| | ||
step %(a directory named "#{dir_name}") | ||
dirs << dir_name | ||
step %(I successfully run `git init --quiet`) | ||
dirs.pop | ||
end | ||
|
||
Then /^"([^"]*)" should be run$/ do |cmd| | ||
assert_command_run cmd | ||
end | ||
|
||
Then /^it should clone "([^"]*)"$/ do |repo| | ||
step %("git clone #{repo}" should be run) | ||
end | ||
|
||
Then /^nothing should be run$/ do | ||
history.should be_empty | ||
end | ||
|
||
Then /^there should be no output$/ do | ||
assert_exact_output('', all_output) | ||
end | ||
|
||
Then /^the git command should be unchanged$/ do | ||
@commands.should_not be_empty | ||
assert_command_run @commands.last.sub(/^hub\b/, 'git') | ||
end | ||
|
||
Then /^the url for "([^"]*)" should be "([^"]*)"$/ do |name, url| | ||
found = run_silent %(git config --get-all remote.#{name}.url) | ||
found.should eql(url) | ||
end | ||
|
||
Then /^the "([^"]*)" submodule url should be "([^"]*)"$/ do |name, url| | ||
found = run_silent %(git config --get-all submodule."#{name}".url) | ||
found.should eql(url) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Feature: hub submodule add | ||
Background: | ||
Given I am in "dotfiles" git repo | ||
# make existing repo in subdirectory so git clone isn't triggered | ||
Given a git repo in "vendor/grit" | ||
|
||
Scenario: Add public submodule | ||
When I successfully run `hub submodule add mojombo/grit vendor/grit` | ||
Then the "vendor/grit" submodule url should be "git://github.com/mojombo/grit.git" | ||
And the output should contain exactly: | ||
""" | ||
Adding existing repo at 'vendor/grit' to the index\n | ||
""" | ||
|
||
Scenario: Add private submodule | ||
When I successfully run `hub submodule add -p mojombo/grit vendor/grit` | ||
Then the "vendor/grit" submodule url should be "git@github.com:mojombo/grit.git" | ||
|
||
Scenario: Add submodule with arguments | ||
When I successfully run `hub submodule add -b foo mojombo/grit vendor/grit` | ||
Then "git submodule add -b foo git://github.com/mojombo/grit.git vendor/grit" should be run |
Oops, something went wrong.