Browse files

New branch scenario, fixing ready scenario, stubbing out Launchy.open

  • Loading branch information...
1 parent 121f6eb commit 082ec96a15ad9322db52d95e40277394c0a7a224 @winton committed Feb 20, 2012
Showing with 47 additions and 11 deletions.
  1. +27 −2 features/branch.feature
  2. +3 −3 features/discuss.feature
  3. +2 −0 features/ready.feature
  4. +11 −2 features/steps/gitcycle_steps.rb
  5. +4 −4 lib/gitcycle.rb
View
29 features/branch.feature
@@ -8,8 +8,8 @@ Scenario: Yes to all (easiest route)
And gitcycle runs
Then output includes
"""
- Retrieving branch information from gitcycle.
Your work will eventually merge into 'master'. Is this correct? (y/n)
+ Retrieving branch information from gitcycle.
Would you like to name your branch 'ticket.id'? (y/n)
Adding remote repo 'config.owner/config.repo'.
Fetching remote 'config.owner'.
@@ -30,8 +30,8 @@ Scenario: Custom branch name
And gitcycle runs
Then output includes
"""
- Retrieving branch information from gitcycle.
Your work will eventually merge into 'master'. Is this correct? (y/n)
+ Retrieving branch information from gitcycle.
Would you like to name your branch 'ticket.id'? (y/n)
What would you like to name your branch?
Adding remote repo 'config.owner/config.repo'.
@@ -41,4 +41,29 @@ Scenario: Custom branch name
Pushing 'origin/ticket.id-rename'.
Sending branch information to gitcycle.
"""
+ And redis entries valid
+
+Scenario: Change source branch
+ Given a fresh set of repositories
+ When I cd to the user repo
+ And I create a new branch "some_branch"
+ And I checkout some_branch
+ And I execute gitcycle branch with a new URL or string
+ And I enter "n"
+ And I enter "master"
+ And I enter "y"
+ And gitcycle runs
+ Then output includes
+ """
+ Your work will eventually merge into 'some_branch'. Is this correct? (y/n)
+ What branch would you like to eventually merge into?
+ Retrieving branch information from gitcycle.
+ Would you like to name your branch 'ticket.id'? (y/n)
+ Adding remote repo 'config.owner/config.repo'.
+ Fetching remote 'config.owner'.
+ Checking out remote branch 'ticket.id' from 'config.owner/config.repo/master'.
+ Fetching remote 'origin'.
+ Pushing 'origin/ticket.id'.
+ Sending branch information to gitcycle.
+ """
And redis entries valid
View
6 features/discuss.feature
@@ -1,6 +1,6 @@
Feature: Discuss
-Scenario: Discuss commits w/ no parameters and nothing committed
+Scenario: No parameters and nothing committed
Given a fresh set of repositories
When I cd to the user repo
And I execute gitcycle branch with a new URL or string
@@ -15,7 +15,7 @@ Scenario: Discuss commits w/ no parameters and nothing committed
"""
And redis entries valid
-Scenario: Discuss commits w/ no parameters and something committed
+Scenario: No parameters and something committed
Given a fresh set of repositories
When I cd to the user repo
And I execute gitcycle branch with a new URL or string
@@ -34,7 +34,7 @@ Scenario: Discuss commits w/ no parameters and something committed
And URL is a valid issue
And redis entries valid
-Scenario: Discuss commits w/ parameters
+Scenario: Parameters
When I cd to the user repo
And I execute gitcycle with "discuss issue.id"
And gitcycle runs
View
2 features/ready.feature
@@ -12,6 +12,8 @@ Scenario: Ready issue
Then output includes
"""
Retrieving branch information from gitcycle.
+ Adding remote repo 'config.owner/config.repo'.
+ Fetching remote 'config.owner'.
Merging remote branch 'master' from 'config.owner/config.repo'.
Adding remote repo 'config.user/config.repo'.
Fetching remote 'config.user'.
View
13 features/steps/gitcycle_steps.rb
@@ -17,7 +17,12 @@
$redis = Redis.new
Before do |scenario|
- Launchy.stub(:open) { |url| $github_url = url }
+ Launchy.stub :open do |url|
+ if url =~ /https:\/\/github.com\/.+\/issues\/\d+/
+ $github_url = url
+ end
+ $url = url
+ end
@scenario_title = scenario.title
$execute = []
$input = []
@@ -160,6 +165,10 @@ def type(text)
repos(true)
end
+When /^I create a new branch "([^\"]*)"$/ do |branch|
+ `git branch #{branch}`
+end
+
When /^I execute gitcycle with nothing$/ do
$execute << nil
end
@@ -296,7 +305,7 @@ def type(text)
'user' => config['user'],
'source' => 'master'
}
- if @scenario_title == 'Discuss commits w/ no parameters and something committed'
+ if @scenario_title == 'No parameters and something committed'
should['issue_url'] = $github_url
end
branch.should == should
View
8 lib/gitcycle.rb
@@ -67,6 +67,10 @@ def branch(*args)
exec_git(:branch, args)
end
+ unless yes?("\nYour work will eventually merge into '#{params['branch[source]']}'. Is this correct?")
+ params['branch[source]'] = q("What branch would you like to eventually merge into?")
+ end
+
puts "\nRetrieving branch information from gitcycle.\n".green
branch = get('branch', params)
name = branch['name']
@@ -75,10 +79,6 @@ def branch(*args)
owner, repo = branch['repo'].split(':')
branch['home'] = @git_login
- unless yes?("\nYour work will eventually merge into '#{branch['source']}'. Is this correct?")
- branch['source'] = q("What branch would you like to eventually merge into?")
- end
-
if branch['source'].include?('/')
branch['home'], branch['source'] = branch['source'].split('/')
end

0 comments on commit 082ec96

Please sign in to comment.