git_pivotal_tracker_x 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,100 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe GitPivotalTracker::Finish do
4
+
5
+ before do
6
+ stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123').
7
+ to_return :body => File.read("#{FIXTURES_PATH}/project.xml")
8
+ stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123/stories/1234567890').
9
+ to_return :body => File.read("#{FIXTURES_PATH}/story.xml")
10
+ @current_head = finish.repository.head
11
+ end
12
+
13
+ after do
14
+ puts finish.repository.git.checkout({}, @current_head.name)
15
+ puts finish.repository.git.reset({}, @current_head.commit.sha)
16
+ end
17
+
18
+ let(:finish) { GitPivotalTracker::Finish.new("-t", "8a8a8a8", "-p", "123") }
19
+
20
+ context "given I am not on a topic branch" do
21
+ before do
22
+ @new_branch = 'invalid-topic-branch'
23
+ finish.repository.git.branch({:D => true}, @new_branch)
24
+ finish.repository.git.checkout({:b => true, :raise => true}, @new_branch)
25
+ end
26
+
27
+ it "fails" do
28
+ finish.run!.should == 1
29
+ end
30
+ end
31
+
32
+ context "given I am on a topic branch with a commit" do
33
+ before do
34
+ finish.options[:integration_branch] = @current_head.name
35
+
36
+ finish_xml = File.read("#{FIXTURES_PATH}/finish_story.xml")
37
+ stub_request(:put, 'http://www.pivotaltracker.com/services/v3/projects/123/stories/1234567890').
38
+ with(:body => finish_xml).to_return(:body => finish_xml)
39
+
40
+ @repo = finish.repository
41
+ @new_branch = "testing-1234567890-branch_name"
42
+ @repo.git.branch({:D => true}, @new_branch)
43
+ @repo.git.checkout({:b => true, :raise => true}, @new_branch)
44
+
45
+ index = @repo.index
46
+ index.read_tree @new_branch
47
+ message = "Test commit: #{rand()}"
48
+ index.add('test.txt', message)
49
+ @sha = index.commit(message, [@repo.heads.detect { |h| h.name == @new_branch }.commit], nil, nil, @new_branch)
50
+
51
+ @repo.git.should_receive(:push).with({:raise => true}, 'origin', @current_head.name)
52
+ end
53
+
54
+ it "merges the topic branch into the integration branch with a merge commit" do
55
+ finish.run!.should == 0
56
+ @repo.head.name.should == @current_head.name
57
+ @repo.commits.first.parents.should have(2).items
58
+ @repo.heads.detect { |h| h.name == @current_head.name }.commit.sha.should == @sha
59
+ end
60
+
61
+ it "does not delete story branch" do
62
+ finish.run!.should == 0
63
+ @repo.git.branch.should match @new_branch
64
+ end
65
+
66
+ context "when I have rebase turned on" do
67
+ before do
68
+ finish.options[:rebase] = 1
69
+ finish.repository.git.should_receive(:pull).with(:raise => true)
70
+ finish.repository.git.should_receive(:rebase).with({:raise => true}, @current_head.name, @new_branch)
71
+ end
72
+
73
+ it "succeeds" do
74
+ finish.run!.should == 0
75
+ end
76
+ end
77
+
78
+ context "when I have fast forward turned on" do
79
+ before do
80
+ finish.options[:fast_forward] = 1
81
+ end
82
+
83
+ it "merges the topic branch without a merge commit" do
84
+ finish.run!.should == 0
85
+ @repo.heads.detect { |h| h.name == @current_head.name }.commit.sha.should == @sha
86
+ end
87
+ end
88
+
89
+ context "when I have delete branch turned on" do
90
+ before do
91
+ finish.options[:delete_branch] = 1
92
+ end
93
+
94
+ it "deletes the story branch after merging" do
95
+ finish.run!.should == 0
96
+ @repo.git.branch.should_not match @new_branch
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,18 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe GitPivotalTracker::Story do
4
+ describe "#run!" do
5
+ context "given no story ID is found" do
6
+ before do
7
+ stub_git_config
8
+ @subject = GitPivotalTracker::Info.new
9
+ @subject.stub!(:story_id).and_return(nil)
10
+ end
11
+
12
+ it "fails" do
13
+ @subject.run!.should == 1
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,130 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe GitPivotalTracker::Story do
4
+ describe "#run!" do
5
+ before do
6
+ stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123').
7
+ to_return :body => File.read("#{FIXTURES_PATH}/project.xml")
8
+ @story = GitPivotalTracker::Story.new("-t", "8a8a8a8", "-p", "123")
9
+ end
10
+
11
+ context "given there are no stories" do
12
+ before do
13
+ stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123/stories?filter=current_state:unstarted&limit=1').
14
+ to_return :body => File.read("#{FIXTURES_PATH}/no_stories.xml")
15
+ end
16
+
17
+ it "fails" do
18
+ @story.run!.should == 1
19
+ end
20
+ end
21
+
22
+ context "given there is a story" do
23
+ before do
24
+ start_xml = File.read("#{FIXTURES_PATH}/start_story.xml")
25
+ stub_request(:put, 'http://www.pivotaltracker.com/services/v3/projects/123/stories/1234567890').
26
+ with(:body => start_xml).to_return(:body => start_xml)
27
+
28
+ @current_branch = @story.repository.head.name
29
+
30
+ @expected_branch = 'feature-1234567890-pause_the_film'
31
+ @story.repository.git.branch({:D => true}, @expected_branch)
32
+ end
33
+
34
+ context "when the include-rejected flag is set" do
35
+ before do
36
+ @story = GitPivotalTracker::Story.new("-t", "8a8a8a8", "-p", "123", "--include-rejected")
37
+
38
+ stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123/stories?filter=current_state:unstarted,rejected&limit=1').
39
+ to_return :body => File.read("#{FIXTURES_PATH}/one_story.xml")
40
+ end
41
+
42
+ it "succeeds" do
43
+ @story.should_receive(:gets).and_return "\n"
44
+ @story.run!.should == 0
45
+ end
46
+ end
47
+
48
+ context "when the only-mine flag is set" do
49
+ before do
50
+ @story = GitPivotalTracker::Story.new("-t", "8a8a8a8", "-p", "123", "--full-name", "Ben Lindsey", "--only-mine")
51
+ stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123/stories?filter=current_state:unstarted%20owned_by:%22Ben%20Lindsey%22&limit=1').
52
+ to_return :body => File.read("#{FIXTURES_PATH}/one_story.xml")
53
+ end
54
+
55
+ it "succeeds" do
56
+ @story.should_receive(:gets).and_return "\n"
57
+ @story.run!.should == 0
58
+ end
59
+ end
60
+
61
+ context "when the default options are used" do
62
+ before do
63
+ stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123/stories?filter=current_state:unstarted&limit=1').
64
+ to_return :body => File.read("#{FIXTURES_PATH}/one_story.xml")
65
+ end
66
+
67
+ context "then I accept the default branch suffix" do
68
+ before do
69
+ @story.should_receive(:gets).and_return "\n"
70
+ @story.run!
71
+ end
72
+
73
+ it "creates a new branch" do
74
+ @story.repository.head.name.should == @expected_branch
75
+ end
76
+ end
77
+
78
+ context "then I customize the branch suffix" do
79
+ before do
80
+ @expected_branch = 'feature-1234567890-new_name'
81
+ @story.repository.git.branch({:D => true}, @expected_branch)
82
+
83
+ @story.should_receive(:gets).and_return "new_name\n"
84
+ @story.run!
85
+ end
86
+
87
+ it "creates a new branch" do
88
+ @story.repository.head.name.should == @expected_branch
89
+ end
90
+ end
91
+ end
92
+
93
+ after do
94
+ @story.repository.git.checkout({:raise => true}, @current_branch)
95
+ end
96
+ end
97
+
98
+ end
99
+
100
+ describe "#type" do
101
+ it "is a story" do
102
+ GitPivotalTracker::Story.new.type.should == 'story'
103
+ end
104
+ end
105
+ end
106
+
107
+ describe GitPivotalTracker::Bug do
108
+ describe "#type" do
109
+ it "is a bug" do
110
+ GitPivotalTracker::Bug.new.type.should == 'bug'
111
+ end
112
+ end
113
+ end
114
+
115
+ describe GitPivotalTracker::Feature do
116
+ describe "#type" do
117
+ it "is a feature" do
118
+ GitPivotalTracker::Feature.new.type.should == 'feature'
119
+ end
120
+ end
121
+ end
122
+
123
+ describe GitPivotalTracker::Chore do
124
+ describe "#type" do
125
+ it "is a chore" do
126
+ GitPivotalTracker::Chore.new.type.should == 'chore'
127
+ end
128
+ end
129
+ end
130
+
@@ -0,0 +1,27 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'git_pivotal_tracker'
5
+ require 'rspec'
6
+ require 'webmock/rspec'
7
+
8
+ FIXTURES_PATH = File.join(File.dirname(__FILE__), 'fixtures')
9
+
10
+ RSpec.configure do |config|
11
+ # == Mock Framework
12
+ #
13
+ # RSpec uses it's own mocking framework by default. If you prefer to
14
+ # use mocha, flexmock or RR, uncomment the appropriate line:
15
+ #
16
+ # config.mock_with :mocha
17
+ # config.mock_with :flexmock
18
+ # config.mock_with :rr
19
+ end
20
+
21
+ def stub_git_config(opts = {})
22
+ git_options = {
23
+ "pivotal.api-token" => "8a8a8a8",
24
+ "pivotal.project-id" => "123"
25
+ }.merge opts
26
+ Grit::Repo.stub!(:new).and_return mock('Grit::Repo', :config => git_options)
27
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git_pivotal_tracker_x
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.1
6
+ platform: ruby
7
+ authors:
8
+ - Philippe Huibonhoa
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-10-27 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: grit
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: pivotal-tracker
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: bundler
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.0
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: jeweler
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 1.6.4
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rcov
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: rspec
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: cucumber
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: webmock
95
+ requirement: &id008 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
101
+ type: :development
102
+ prerelease: false
103
+ version_requirements: *id008
104
+ description: Provides a set of git workflow tools to start and finish Pivotal Tracker stories in topic branches
105
+ email: phuibonhoa@gmail.com
106
+ executables:
107
+ - commit-msg
108
+ - git-bug
109
+ - git-chore
110
+ - git-feature
111
+ - git-finish
112
+ - git-info
113
+ - git-story
114
+ extensions: []
115
+
116
+ extra_rdoc_files:
117
+ - LICENSE
118
+ - README.md
119
+ files:
120
+ - .rvmrc
121
+ - Gemfile
122
+ - LICENSE
123
+ - README.md
124
+ - Rakefile
125
+ - VERSION
126
+ - bin/commit-msg
127
+ - bin/git-bug
128
+ - bin/git-chore
129
+ - bin/git-feature
130
+ - bin/git-finish
131
+ - bin/git-info
132
+ - bin/git-story
133
+ - cucumber.yml
134
+ - features/diagnostics.feature
135
+ - features/getting_started.feature
136
+ - features/hooks/aruba.rb
137
+ - features/step_definitions/git_steps.rb
138
+ - features/support/env.rb
139
+ - git_pivotal_tracker_x.gemspec
140
+ - lib/git_pivotal_tracker.rb
141
+ - lib/git_pivotal_tracker/base.rb
142
+ - lib/git_pivotal_tracker/finish.rb
143
+ - lib/git_pivotal_tracker/info.rb
144
+ - lib/git_pivotal_tracker/story.rb
145
+ - spec/fixtures/finish_story.xml
146
+ - spec/fixtures/no_stories.xml
147
+ - spec/fixtures/one_story.xml
148
+ - spec/fixtures/project.xml
149
+ - spec/fixtures/start_story.xml
150
+ - spec/fixtures/story.xml
151
+ - spec/git_pivotal_tracker/base_spec.rb
152
+ - spec/git_pivotal_tracker/finish_spec.rb
153
+ - spec/git_pivotal_tracker/info_spec.rb
154
+ - spec/git_pivotal_tracker/story_spec.rb
155
+ - spec/spec_helper.rb
156
+ has_rdoc: true
157
+ homepage: http://github.com/phuibonhoa/git_pivotal_tracker
158
+ licenses:
159
+ - MIT
160
+ post_install_message:
161
+ rdoc_options: []
162
+
163
+ require_paths:
164
+ - lib
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ none: false
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ hash: 4111066582648077166
171
+ segments:
172
+ - 0
173
+ version: "0"
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: "0"
180
+ requirements: []
181
+
182
+ rubyforge_project:
183
+ rubygems_version: 1.6.2
184
+ signing_key:
185
+ specification_version: 3
186
+ summary: A git workflow integrated with Pivotal Tracker
187
+ test_files: []
188
+