pivotal-integration 1.6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +15 -0
  2. data/LICENSE +202 -0
  3. data/NOTICE +2 -0
  4. data/README.md +331 -0
  5. data/bin/pivotal +81 -0
  6. data/lib/pivotal-integration/command/assign.rb +50 -0
  7. data/lib/pivotal-integration/command/base.rb +63 -0
  8. data/lib/pivotal-integration/command/command.rb +20 -0
  9. data/lib/pivotal-integration/command/comment.rb +31 -0
  10. data/lib/pivotal-integration/command/configuration.rb +129 -0
  11. data/lib/pivotal-integration/command/estimate.rb +53 -0
  12. data/lib/pivotal-integration/command/finish.rb +50 -0
  13. data/lib/pivotal-integration/command/info.rb +30 -0
  14. data/lib/pivotal-integration/command/label.rb +33 -0
  15. data/lib/pivotal-integration/command/mark.rb +44 -0
  16. data/lib/pivotal-integration/command/new.rb +52 -0
  17. data/lib/pivotal-integration/command/open.rb +31 -0
  18. data/lib/pivotal-integration/command/prepare-commit-msg.sh +26 -0
  19. data/lib/pivotal-integration/command/release.rb +54 -0
  20. data/lib/pivotal-integration/command/start.rb +82 -0
  21. data/lib/pivotal-integration/command/switch.rb +44 -0
  22. data/lib/pivotal-integration/util/git.rb +280 -0
  23. data/lib/pivotal-integration/util/label.rb +72 -0
  24. data/lib/pivotal-integration/util/shell.rb +36 -0
  25. data/lib/pivotal-integration/util/story.rb +170 -0
  26. data/lib/pivotal-integration/util/util.rb +20 -0
  27. data/lib/pivotal-integration/version-update/gradle.rb +64 -0
  28. data/lib/pivotal-integration/version-update/version_update.rb +20 -0
  29. data/lib/pivotal_integration.rb +18 -0
  30. data/spec/git-pivotal-tracker-integration/command/assign_spec.rb +55 -0
  31. data/spec/git-pivotal-tracker-integration/command/base_spec.rb +38 -0
  32. data/spec/git-pivotal-tracker-integration/command/configuration_spec.rb +119 -0
  33. data/spec/git-pivotal-tracker-integration/command/finish_spec.rb +45 -0
  34. data/spec/git-pivotal-tracker-integration/command/label_spec.rb +44 -0
  35. data/spec/git-pivotal-tracker-integration/command/mark_spec.rb +49 -0
  36. data/spec/git-pivotal-tracker-integration/command/release_spec.rb +57 -0
  37. data/spec/git-pivotal-tracker-integration/command/start_spec.rb +55 -0
  38. data/spec/git-pivotal-tracker-integration/util/git_spec.rb +235 -0
  39. data/spec/git-pivotal-tracker-integration/util/label_spec.rb +193 -0
  40. data/spec/git-pivotal-tracker-integration/util/shell_spec.rb +52 -0
  41. data/spec/git-pivotal-tracker-integration/util/story_spec.rb +158 -0
  42. data/spec/git-pivotal-tracker-integration/version-update/gradle_spec.rb +74 -0
  43. metadata +241 -0
@@ -0,0 +1,20 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require_relative '../../pivotal_integration'
17
+
18
+ # A module encapsulating utilities for the project
19
+ module PivotalIntegration::Util
20
+ end
@@ -0,0 +1,64 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require_relative 'version_update'
17
+
18
+ # A version updater for dealing with _typical_ Gradle projects. This updater
19
+ # assumes that the version of the current project is stored within a
20
+ # +gradle.properties+ file in the root of the repository. This properties
21
+ # file should have an entry with a key of +version+ and version number as the key.
22
+ class PivotalIntegration::VersionUpdate::Gradle
23
+
24
+ # Creates an instance of this updater
25
+ #
26
+ # @param [String] root The root of the repository
27
+ def initialize(root)
28
+ @gradle_properties = File.expand_path 'gradle.properties', root
29
+
30
+ if File.exist? @gradle_properties
31
+ groups = nil
32
+ File.open(@gradle_properties, 'r') do |file|
33
+ groups = file.read().scan(/version[=:](.*)/)
34
+ end
35
+ @version = groups[0] ? groups[0][0]: nil
36
+ end
37
+ end
38
+
39
+ # Whether this updater supports updating this project
40
+ #
41
+ # @return [Boolean] +true+ if a valid version number was found on
42
+ # initialization, +false+ otherwise
43
+ def supports?
44
+ !@version.nil?
45
+ end
46
+
47
+ # The current version of the project
48
+ #
49
+ # @return [String] the current version of the project
50
+ def current_version
51
+ @version
52
+ end
53
+
54
+ # Update the version of the project
55
+ #
56
+ # @param [String] new_version the version to update the project to
57
+ # @return [void]
58
+ def update_version(new_version)
59
+ contents = File.read(@gradle_properties)
60
+ contents = contents.gsub(/(version[=:])#{@version}/, "\\1#{new_version}")
61
+ File.open(@gradle_properties, 'w') { |file| file.write(contents) }
62
+ end
63
+
64
+ end
@@ -0,0 +1,20 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require_relative '../../pivotal_integration'
17
+
18
+ # A module encapsulating version update implementations
19
+ module PivotalIntegration::VersionUpdate
20
+ end
@@ -0,0 +1,18 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # The root module for the project
17
+ module PivotalIntegration
18
+ end
@@ -0,0 +1,55 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'spec_helper'
17
+ require 'git-pivotal-tracker-integration/command/configuration'
18
+ require 'git-pivotal-tracker-integration/command/assign'
19
+ require 'git-pivotal-tracker-integration/util/git'
20
+ require 'pivotal-tracker'
21
+
22
+ describe PivotalIntegration::Command::Assign do
23
+
24
+ before do
25
+ $stdout = StringIO.new
26
+ $stderr = StringIO.new
27
+
28
+ @project = double('project')
29
+ @story = double('story')
30
+ PivotalIntegration::Util::Git.should_receive(:repository_root)
31
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:api_token)
32
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:project_id)
33
+ PivotalTracker::Project.should_receive(:find).and_return(@project)
34
+ @assign = PivotalIntegration::Command::Assign.new
35
+ end
36
+
37
+ it 'should run' do
38
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:story).and_return(@story)
39
+
40
+ menu = double('menu')
41
+ menu.should_receive(:prompt=)
42
+ menu.should_receive(:choice).with('Username')
43
+
44
+ @assign.should_receive(:choose) { |&arg| arg.call menu }.and_return('Username')
45
+
46
+ memberships = double('memberships')
47
+ membership = double('membership')
48
+ @project.should_receive(:memberships).and_return(memberships)
49
+ memberships.should_receive(:all).and_return([membership])
50
+ membership.should_receive(:name).and_return('Username')
51
+ PivotalIntegration::Util::Story.should_receive(:assign).with(@story, 'Username')
52
+
53
+ @assign.run(nil)
54
+ end
55
+ end
@@ -0,0 +1,38 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'spec_helper'
17
+ require 'git-pivotal-tracker-integration/command/base'
18
+ require 'git-pivotal-tracker-integration/command/configuration'
19
+ require 'git-pivotal-tracker-integration/util/git'
20
+
21
+ describe PivotalIntegration::Command::Base do
22
+
23
+ before do
24
+ $stdout = StringIO.new
25
+ $stderr = StringIO.new
26
+
27
+ @project = double('project')
28
+ PivotalIntegration::Util::Git.should_receive(:repository_root)
29
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:api_token)
30
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:project_id)
31
+ PivotalTracker::Project.should_receive(:find).and_return(@project)
32
+ @base = PivotalIntegration::Command::Base.new
33
+ end
34
+
35
+ it 'should not run' do
36
+ lambda { @base.run }.should raise_error
37
+ end
38
+ end
@@ -0,0 +1,119 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'spec_helper'
17
+ require 'git-pivotal-tracker-integration/command/configuration'
18
+ require 'git-pivotal-tracker-integration/util/git'
19
+ require 'pivotal-tracker'
20
+
21
+ describe PivotalIntegration::Command::Configuration do
22
+
23
+ before do
24
+ $stdout = StringIO.new
25
+ $stderr = StringIO.new
26
+ @configuration = PivotalIntegration::Command::Configuration.new
27
+ end
28
+
29
+ it 'should not prompt the user for the API token if it is already configured' do
30
+ PivotalIntegration::Util::Git.should_receive(:get_config).with('pivotal.api-token', :inherited).and_return('test_api_token')
31
+
32
+ api_token = @configuration.api_token
33
+
34
+ expect(api_token).to eq('test_api_token')
35
+ end
36
+
37
+ it 'should prompt the user for the API token if it is not configured' do
38
+ PivotalIntegration::Util::Git.should_receive(:get_config).with('pivotal.api-token', :inherited).and_return('')
39
+ @configuration.should_receive(:ask).and_return('test_api_token')
40
+ PivotalIntegration::Util::Git.should_receive(:set_config).with('pivotal.api-token', 'test_api_token', :global)
41
+
42
+ api_token = @configuration.api_token
43
+
44
+ expect(api_token).to eq('test_api_token')
45
+ end
46
+
47
+ it 'should not prompt the user for the project if it is already configured' do
48
+ project = double('project')
49
+ PivotalIntegration::Util::Git.should_receive(:get_config).with('pivotal.project-id', :inherited).and_return('test_project_id')
50
+ PivotalTracker::Project.should_receive(:find).with('test_project_id').and_return(project)
51
+
52
+ expect(@configuration.project).to eq(project)
53
+ end
54
+
55
+ it 'should prompt the user for the project if it is not configured' do
56
+ project = double('project')
57
+ menu = double('menu')
58
+ PivotalIntegration::Util::Git.should_receive(:get_config).with('pivotal.project-id', :inherited).and_return('')
59
+ menu.should_receive(:prompt=)
60
+ PivotalTracker::Project.should_receive(:all).and_return([
61
+ PivotalTracker::Project.new(:id => 'id-2', :name => 'name-2'),
62
+ PivotalTracker::Project.new(:id => 'id-1', :name => 'name-1')])
63
+ menu.should_receive(:choice).with('name-1')
64
+ menu.should_receive(:choice).with('name-2')
65
+ @configuration.should_receive(:choose) { |&arg| arg.call menu }.and_return('test_project_id')
66
+ PivotalIntegration::Util::Git.should_receive(:set_config).with('pivotal.project-id', 'test_project_id', :local)
67
+ PivotalTracker::Project.should_receive(:find).with('test_project_id').and_return(project)
68
+
69
+ expect(@configuration.project).to eq(project)
70
+ end
71
+
72
+ it 'should not prompt the user for his Pivotal Tracker user name if it is already configured' do
73
+ user = 'User Name'
74
+ PivotalIntegration::Util::Git.should_receive(:get_config).with('pivotal.user', :inherited).and_return(user)
75
+
76
+ expect(@configuration.user).to eq(user)
77
+ end
78
+
79
+ it 'should prompt the user for his Pivotal Tracker user name if it is not configured' do
80
+ user = 'User Name'
81
+ menu = double('menu')
82
+ projects = [double('project')]
83
+ users = [[user]]
84
+ PivotalIntegration::Util::Git.should_receive(:get_config).with('pivotal.user', :inherited).and_return('')
85
+ menu.should_receive(:prompt=)
86
+ PivotalTracker::Project.should_receive(:all).and_return(projects)
87
+ projects.should_receive(:map).and_return(users)
88
+ menu.should_receive(:choice).with(user)
89
+ @configuration.should_receive(:choose) { |&arg| arg.call menu }.and_return(user)
90
+ PivotalIntegration::Util::Git.should_receive(:set_config).with('pivotal.user', user.inspect, :local)
91
+
92
+ expect(@configuration.user).to eq(user)
93
+ end
94
+
95
+ it 'should persist the story when requested' do
96
+ PivotalIntegration::Util::Git.should_receive(:set_config).with('pivotal-story-id', 12345678, :branch)
97
+
98
+ @configuration.story = PivotalTracker::Story.new(:id => 12345678)
99
+ end
100
+
101
+ it 'should return a story when requested' do
102
+ story_id = '12345678'
103
+ project = double('project')
104
+ stories = double('stories')
105
+ story = double('story')
106
+ PivotalIntegration::Util::Git.should_receive(:get_config).with('pivotal-story-id', :branch).and_return(story_id)
107
+ @configuration.should_receive(:project).and_return(project)
108
+ project.should_receive(:stories).and_return(stories)
109
+ stories.should_receive(:find).with(story_id).and_return(story)
110
+
111
+ expect(@configuration.story).to be(story)
112
+ end
113
+
114
+ it 'should abort when story is requested but no branch is started' do
115
+ PivotalIntegration::Util::Git.should_receive(:get_config).with('pivotal-story-id', :branch).and_return("")
116
+ lambda { @configuration.story }.should raise_error SystemExit
117
+ end
118
+
119
+ end
@@ -0,0 +1,45 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'spec_helper'
17
+ require 'git-pivotal-tracker-integration/command/configuration'
18
+ require 'git-pivotal-tracker-integration/command/finish'
19
+ require 'git-pivotal-tracker-integration/util/git'
20
+ require 'pivotal-tracker'
21
+
22
+ describe PivotalIntegration::Command::Finish do
23
+
24
+ before do
25
+ $stdout = StringIO.new
26
+ $stderr = StringIO.new
27
+
28
+ @project = double('project')
29
+ PivotalIntegration::Util::Git.should_receive(:repository_root)
30
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:api_token)
31
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:project_id)
32
+ PivotalTracker::Project.should_receive(:find).and_return(@project)
33
+ @finish = PivotalIntegration::Command::Finish.new
34
+ end
35
+
36
+ it 'should run' do
37
+ PivotalIntegration::Util::Git.should_receive(:trivial_merge?)
38
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:story)
39
+ PivotalIntegration::Util::Git.should_receive(:merge)
40
+ PivotalIntegration::Util::Git.should_receive(:branch_name).and_return('master')
41
+ PivotalIntegration::Util::Git.should_receive(:push).with('master')
42
+
43
+ @finish.run nil
44
+ end
45
+ end
@@ -0,0 +1,44 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'spec_helper'
17
+ require 'git-pivotal-tracker-integration/command/configuration'
18
+ require 'git-pivotal-tracker-integration/command/label'
19
+ require 'git-pivotal-tracker-integration/util/git'
20
+ require 'pivotal-tracker'
21
+
22
+ describe PivotalIntegration::Command::Label do
23
+
24
+ before do
25
+ $stdout = StringIO.new
26
+ $stderr = StringIO.new
27
+
28
+ @project = double('project')
29
+ @story = double('story')
30
+ PivotalIntegration::Util::Git.should_receive(:repository_root)
31
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:api_token)
32
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:project_id)
33
+ PivotalTracker::Project.should_receive(:find).and_return(@project)
34
+ @label = PivotalIntegration::Command::Label.new
35
+ end
36
+
37
+ it 'should run' do
38
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:story).and_return(@story)
39
+
40
+ PivotalIntegration::Util::Label.should_receive(:send).with('add', @story, 'on_qa')
41
+
42
+ @label.run('add', 'on_qa')
43
+ end
44
+ end
@@ -0,0 +1,49 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'spec_helper'
17
+ require 'git-pivotal-tracker-integration/command/configuration'
18
+ require 'git-pivotal-tracker-integration/command/mark'
19
+ require 'git-pivotal-tracker-integration/util/git'
20
+ require 'pivotal-tracker'
21
+
22
+ describe PivotalIntegration::Command::Mark do
23
+
24
+ before do
25
+ $stdout = StringIO.new
26
+ $stderr = StringIO.new
27
+
28
+ @project = double('project')
29
+ @story = double('story')
30
+ PivotalIntegration::Util::Git.should_receive(:repository_root)
31
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:api_token)
32
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:project_id)
33
+ PivotalTracker::Project.should_receive(:find).and_return(@project)
34
+ @mark = PivotalIntegration::Command::Mark.new
35
+ end
36
+
37
+ it 'should run' do
38
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:story).and_return(@story)
39
+
40
+ menu = double('menu')
41
+ menu.should_receive(:prompt=)
42
+ PivotalIntegration::Command::Mark::STATES.each { |state| menu.should_receive(:choice).with(state) }
43
+ @mark.should_receive(:choose) { |&arg| arg.call menu }.and_return('finished')
44
+
45
+ PivotalIntegration::Util::Story.should_receive(:mark).with(@story, 'finished')
46
+
47
+ @mark.run(nil)
48
+ end
49
+ end
@@ -0,0 +1,57 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'spec_helper'
17
+ require 'git-pivotal-tracker-integration/command/configuration'
18
+ require 'git-pivotal-tracker-integration/command/release'
19
+ require 'git-pivotal-tracker-integration/util/git'
20
+ require 'git-pivotal-tracker-integration/util/story'
21
+ require 'pivotal-tracker'
22
+
23
+ describe PivotalIntegration::Command::Release do
24
+
25
+ before do
26
+ $stdout = StringIO.new
27
+ $stderr = StringIO.new
28
+
29
+ @project = double('project')
30
+ PivotalIntegration::Util::Git.should_receive(:repository_root)
31
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:api_token)
32
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:project_id)
33
+ PivotalTracker::Project.should_receive(:find).and_return(@project)
34
+ @release = PivotalIntegration::Command::Release.new
35
+ end
36
+
37
+ it 'should run' do
38
+ story = PivotalTracker::Story.new(:id => 12345678)
39
+ updater = double('updater')
40
+ PivotalIntegration::Util::Story.should_receive(:select_story).and_return(story)
41
+ PivotalIntegration::Util::Story.should_receive(:pretty_print)
42
+ PivotalIntegration::VersionUpdate::Gradle.should_receive(:new).and_return(updater)
43
+ updater.should_receive(:supports?).and_return(true)
44
+ updater.should_receive(:current_version).and_return('test_current_version')
45
+ @release.should_receive(:ask).and_return('test_release_version')
46
+ @release.should_receive(:ask).and_return('test_next_version')
47
+ updater.should_receive(:update_version).with('test_release_version')
48
+ PivotalIntegration::Util::Git.should_receive(:create_release_tag).with('test_release_version', story)
49
+ updater.should_receive(:update_version).with('test_next_version')
50
+ PivotalIntegration::Util::Git.should_receive(:create_commit).with('test_next_version Development', story)
51
+ PivotalIntegration::Util::Git.should_receive(:branch_name).and_return('master')
52
+ PivotalIntegration::Util::Git.should_receive(:push).with('master', 'vtest_release_version')
53
+
54
+ @release.run(nil)
55
+ end
56
+
57
+ end
@@ -0,0 +1,55 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'spec_helper'
17
+ require 'git-pivotal-tracker-integration/command/configuration'
18
+ require 'git-pivotal-tracker-integration/command/start'
19
+ require 'git-pivotal-tracker-integration/util/git'
20
+ require 'git-pivotal-tracker-integration/util/story'
21
+ require 'pivotal-tracker'
22
+
23
+ describe PivotalIntegration::Command::Start do
24
+
25
+ before do
26
+ $stdout = StringIO.new
27
+ $stderr = StringIO.new
28
+
29
+ @project = double('project')
30
+ @story = double('story')
31
+ PivotalIntegration::Util::Git.should_receive(:repository_root)
32
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:api_token)
33
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:project_id)
34
+ PivotalTracker::Project.should_receive(:find).and_return(@project)
35
+ @start = PivotalIntegration::Command::Start.new
36
+ end
37
+
38
+ it 'should run' do
39
+ PivotalIntegration::Util::Story.should_receive(:select_story).with(@project, 'test_filter').and_return(@story)
40
+ PivotalIntegration::Util::Story.should_receive(:pretty_print)
41
+ @story.should_receive(:id).twice.and_return(12345678)
42
+ @story.should_receive(:story_type).twice.and_return('type')
43
+ @start.should_receive(:ask).and_return('development_branch')
44
+ PivotalIntegration::Util::Git.should_receive(:create_branch).with('type/12345678-development_branch')
45
+ PivotalIntegration::Command::Configuration.any_instance.should_receive(:story=)
46
+ PivotalIntegration::Util::Git.should_receive(:add_hook)
47
+ PivotalIntegration::Util::Git.should_receive(:get_config).with('user.name').and_return('test_owner')
48
+ @story.should_receive(:update).with(
49
+ :current_state => 'started',
50
+ :owned_by => 'test_owner'
51
+ )
52
+
53
+ @start.run 'test_filter'
54
+ end
55
+ end