git-pivotal-tracker-integration 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -2
- data/bin/git-finish +2 -2
- data/bin/git-release +1 -1
- data/bin/git-start +1 -1
- data/lib/git-pivotal-tracker-integration/command/base.rb +4 -4
- data/lib/git-pivotal-tracker-integration/command/command.rb +1 -1
- data/lib/git-pivotal-tracker-integration/command/configuration.rb +18 -18
- data/lib/git-pivotal-tracker-integration/command/finish.rb +7 -5
- data/lib/git-pivotal-tracker-integration/command/release.rb +6 -6
- data/lib/git-pivotal-tracker-integration/command/start.rb +10 -10
- data/lib/git-pivotal-tracker-integration/util/git.rb +39 -37
- data/lib/git-pivotal-tracker-integration/util/shell.rb +3 -3
- data/lib/git-pivotal-tracker-integration/util/story.rb +18 -22
- data/lib/git-pivotal-tracker-integration/util/util.rb +1 -1
- data/lib/git-pivotal-tracker-integration/version-update/gradle.rb +5 -5
- data/lib/git-pivotal-tracker-integration/version-update/version_update.rb +1 -1
- data/spec/git-pivotal-tracker-integration/command/base_spec.rb +6 -6
- data/spec/git-pivotal-tracker-integration/command/configuration_spec.rb +32 -32
- data/spec/git-pivotal-tracker-integration/command/finish_spec.rb +10 -10
- data/spec/git-pivotal-tracker-integration/command/release_spec.rb +18 -18
- data/spec/git-pivotal-tracker-integration/command/start_spec.rb +16 -16
- data/spec/git-pivotal-tracker-integration/util/git_spec.rb +98 -88
- data/spec/git-pivotal-tracker-integration/util/shell_spec.rb +11 -11
- data/spec/git-pivotal-tracker-integration/util/story_spec.rb +35 -35
- data/spec/git-pivotal-tracker-integration/version-update/gradle_spec.rb +18 -18
- metadata +6 -6
@@ -13,9 +13,9 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
16
|
+
require 'spec_helper'
|
17
|
+
require 'git-pivotal-tracker-integration/util/git'
|
18
|
+
require 'git-pivotal-tracker-integration/util/shell'
|
19
19
|
|
20
20
|
describe GitPivotalTrackerIntegration::Util::Git do
|
21
21
|
|
@@ -24,20 +24,20 @@ describe GitPivotalTrackerIntegration::Util::Git do
|
|
24
24
|
$stderr = StringIO.new
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
27
|
+
it 'should return the current branch name' do
|
28
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git branch').and_return(" master\n * dev_branch")
|
29
29
|
|
30
30
|
current_branch = GitPivotalTrackerIntegration::Util::Git.branch_name
|
31
31
|
|
32
|
-
expect(current_branch).to eq(
|
32
|
+
expect(current_branch).to eq('dev_branch')
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
35
|
+
it 'should return the repository root' do
|
36
36
|
Dir.mktmpdir do |root|
|
37
|
-
child_directory = File.expand_path
|
37
|
+
child_directory = File.expand_path 'child', root
|
38
38
|
Dir.mkdir child_directory
|
39
39
|
|
40
|
-
git_directory = File.expand_path
|
40
|
+
git_directory = File.expand_path '.git', root
|
41
41
|
Dir.mkdir git_directory
|
42
42
|
|
43
43
|
Dir.should_receive(:pwd).and_return(child_directory)
|
@@ -48,9 +48,9 @@ describe GitPivotalTrackerIntegration::Util::Git do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
51
|
+
it 'should raise an error there is no repository root' do
|
52
52
|
Dir.mktmpdir do |root|
|
53
|
-
child_directory = File.expand_path
|
53
|
+
child_directory = File.expand_path 'child', root
|
54
54
|
Dir.mkdir child_directory
|
55
55
|
|
56
56
|
Dir.should_receive(:pwd).and_return(child_directory)
|
@@ -59,167 +59,177 @@ describe GitPivotalTrackerIntegration::Util::Git do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
63
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return(
|
64
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
62
|
+
it 'should get configuration when :branch scope is specified' do
|
63
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('test_branch_name')
|
64
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git config branch.test_branch_name.test_key', false).and_return('test_value')
|
65
65
|
|
66
|
-
value = GitPivotalTrackerIntegration::Util::Git.get_config
|
66
|
+
value = GitPivotalTrackerIntegration::Util::Git.get_config 'test_key', :branch
|
67
67
|
|
68
|
-
expect(value).to eq(
|
68
|
+
expect(value).to eq('test_value')
|
69
69
|
end
|
70
70
|
|
71
|
-
it
|
72
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
71
|
+
it 'should get configuration when :inherited scope is specified' do
|
72
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git config test_key', false).and_return('test_value')
|
73
73
|
|
74
|
-
value = GitPivotalTrackerIntegration::Util::Git.get_config
|
74
|
+
value = GitPivotalTrackerIntegration::Util::Git.get_config 'test_key', :inherited
|
75
75
|
|
76
|
-
expect(value).to eq(
|
76
|
+
expect(value).to eq('test_value')
|
77
77
|
end
|
78
78
|
|
79
|
-
it
|
80
|
-
expect { GitPivotalTrackerIntegration::Util::Git.get_config
|
79
|
+
it 'should raise an error when an unknown scope is specified (get)' do
|
80
|
+
expect { GitPivotalTrackerIntegration::Util::Git.get_config 'test_key', :unknown }.to raise_error
|
81
81
|
end
|
82
82
|
|
83
|
-
it
|
84
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return(
|
85
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
83
|
+
it 'should set configuration when :branch scope is specified' do
|
84
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('test_branch_name')
|
85
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git config --local branch.test_branch_name.test_key test_value')
|
86
86
|
|
87
|
-
GitPivotalTrackerIntegration::Util::Git.set_config
|
87
|
+
GitPivotalTrackerIntegration::Util::Git.set_config 'test_key', 'test_value', :branch
|
88
88
|
end
|
89
89
|
|
90
|
-
it
|
91
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
90
|
+
it 'should set configuration when :global scope is specified' do
|
91
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git config --global test_key test_value')
|
92
92
|
|
93
|
-
GitPivotalTrackerIntegration::Util::Git.set_config
|
93
|
+
GitPivotalTrackerIntegration::Util::Git.set_config 'test_key', 'test_value', :global
|
94
94
|
end
|
95
95
|
|
96
|
-
it
|
97
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
96
|
+
it 'should set configuration when :local scope is specified' do
|
97
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git config --local test_key test_value')
|
98
98
|
|
99
|
-
GitPivotalTrackerIntegration::Util::Git.set_config
|
99
|
+
GitPivotalTrackerIntegration::Util::Git.set_config 'test_key', 'test_value', :local
|
100
100
|
end
|
101
101
|
|
102
|
-
it
|
103
|
-
expect { GitPivotalTrackerIntegration::Util::Git.set_config
|
102
|
+
it 'should raise an error when an unknown scope is specified (set)' do
|
103
|
+
expect { GitPivotalTrackerIntegration::Util::Git.set_config 'test_key', 'test_value', :unknown }.to raise_error
|
104
104
|
end
|
105
105
|
|
106
|
-
it
|
107
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return(
|
108
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with(
|
109
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
110
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).and_return(
|
111
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:set_config).with(
|
112
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:set_config).with(
|
106
|
+
it 'should create a branch and set the root_branch and root_remote properties on it' do
|
107
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('master')
|
108
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('remote', :branch).and_return('origin')
|
109
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git pull --quiet --ff-only')
|
110
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).and_return('git checkout --quiet -b dev_branch')
|
111
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:set_config).with('root-branch', 'master', :branch)
|
112
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:set_config).with('root-remote', 'origin', :branch)
|
113
113
|
|
114
|
-
GitPivotalTrackerIntegration::Util::Git.create_branch
|
114
|
+
GitPivotalTrackerIntegration::Util::Git.create_branch 'dev_branch'
|
115
115
|
end
|
116
116
|
|
117
|
-
it
|
117
|
+
it 'should not add a hook if it already exists' do
|
118
118
|
Dir.mktmpdir do |root|
|
119
119
|
GitPivotalTrackerIntegration::Util::Git.should_receive(:repository_root).and_return(root)
|
120
120
|
hook = "#{root}/.git/hooks/prepare-commit-msg"
|
121
121
|
File.should_receive(:exist?).with(hook).and_return(true)
|
122
122
|
|
123
|
-
GitPivotalTrackerIntegration::Util::Git.add_hook
|
123
|
+
GitPivotalTrackerIntegration::Util::Git.add_hook 'prepare-commit-msg', __FILE__
|
124
124
|
|
125
125
|
File.should_receive(:exist?).and_call_original
|
126
126
|
expect(File.exist?(hook)).to be_false
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
it
|
130
|
+
it 'should add a hook if it does not exist' do
|
131
131
|
Dir.mktmpdir do |root|
|
132
132
|
GitPivotalTrackerIntegration::Util::Git.should_receive(:repository_root).and_return(root)
|
133
133
|
hook = "#{root}/.git/hooks/prepare-commit-msg"
|
134
134
|
File.should_receive(:exist?).with(hook).and_return(false)
|
135
135
|
|
136
|
-
GitPivotalTrackerIntegration::Util::Git.add_hook
|
136
|
+
GitPivotalTrackerIntegration::Util::Git.add_hook 'prepare-commit-msg', __FILE__
|
137
137
|
|
138
138
|
File.should_receive(:exist?).and_call_original
|
139
139
|
expect(File.exist?(hook)).to be_true
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
-
it
|
143
|
+
it 'should add a hook if it already exists and overwrite is true' do
|
144
144
|
Dir.mktmpdir do |root|
|
145
145
|
GitPivotalTrackerIntegration::Util::Git.should_receive(:repository_root).and_return(root)
|
146
146
|
hook = "#{root}/.git/hooks/prepare-commit-msg"
|
147
147
|
|
148
|
-
GitPivotalTrackerIntegration::Util::Git.add_hook
|
148
|
+
GitPivotalTrackerIntegration::Util::Git.add_hook 'prepare-commit-msg', __FILE__, true
|
149
149
|
|
150
150
|
File.should_receive(:exist?).and_call_original
|
151
151
|
expect(File.exist?(hook)).to be_true
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
it
|
156
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return(
|
157
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with(
|
158
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
159
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
160
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
161
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
162
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
155
|
+
it 'should fail if root tip and common_ancestor do not match' do
|
156
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('development_branch')
|
157
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('root-branch', :branch).and_return('master')
|
158
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet master')
|
159
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git pull --quiet --ff-only')
|
160
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet development_branch')
|
161
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git rev-parse master').and_return('root_tip')
|
162
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git merge-base master development_branch').and_return('common_ancestor')
|
163
163
|
|
164
164
|
lambda { GitPivotalTrackerIntegration::Util::Git.trivial_merge? }.should raise_error(SystemExit)
|
165
165
|
|
166
166
|
expect($stderr.string).to match(/FAIL/)
|
167
167
|
end
|
168
168
|
|
169
|
-
it
|
170
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return(
|
171
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with(
|
172
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
173
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
174
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
175
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
176
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
169
|
+
it 'should pass if root tip and common ancestor match' do
|
170
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('development_branch')
|
171
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('root-branch', :branch).and_return('master')
|
172
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet master')
|
173
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git pull --quiet --ff-only')
|
174
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet development_branch')
|
175
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git rev-parse master').and_return('HEAD')
|
176
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git merge-base master development_branch').and_return('HEAD')
|
177
177
|
|
178
178
|
GitPivotalTrackerIntegration::Util::Git.trivial_merge?
|
179
179
|
|
180
180
|
expect($stdout.string).to match(/OK/)
|
181
181
|
end
|
182
182
|
|
183
|
-
it
|
184
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return(
|
185
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with(
|
186
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
183
|
+
it 'should merge and delete branches' do
|
184
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('development_branch')
|
185
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('root-branch', :branch).and_return('master')
|
186
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet master')
|
187
187
|
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with("git merge --quiet --no-ff -m \"Merge development_branch to master\n\n[Completes #12345678]\" development_branch")
|
188
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
188
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git branch --quiet -D development_branch')
|
189
189
|
|
190
|
-
GitPivotalTrackerIntegration::Util::Git.merge PivotalTracker::Story.new(:id => 12345678)
|
190
|
+
GitPivotalTrackerIntegration::Util::Git.merge PivotalTracker::Story.new(:id => 12345678), nil
|
191
191
|
end
|
192
192
|
|
193
|
-
it
|
194
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:
|
195
|
-
GitPivotalTrackerIntegration::Util::
|
193
|
+
it 'should suppress Completes statement' do
|
194
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('development_branch')
|
195
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('root-branch', :branch).and_return('master')
|
196
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet master')
|
197
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with("git merge --quiet --no-ff -m \"Merge development_branch to master\n\n[#12345678]\" development_branch")
|
198
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git branch --quiet -D development_branch')
|
199
|
+
|
200
|
+
GitPivotalTrackerIntegration::Util::Git.merge PivotalTracker::Story.new(:id => 12345678), true
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'should push changes without refs' do
|
204
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('remote', :branch).and_return('origin')
|
205
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git push --quiet origin ')
|
196
206
|
|
197
207
|
GitPivotalTrackerIntegration::Util::Git.push
|
198
208
|
end
|
199
209
|
|
200
|
-
it
|
201
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with(
|
202
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
210
|
+
it 'should push changes with refs' do
|
211
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('remote', :branch).and_return('origin')
|
212
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git push --quiet origin foo bar')
|
203
213
|
|
204
|
-
GitPivotalTrackerIntegration::Util::Git.push
|
214
|
+
GitPivotalTrackerIntegration::Util::Git.push 'foo', 'bar'
|
205
215
|
end
|
206
216
|
|
207
|
-
it
|
217
|
+
it 'should create a commit' do
|
208
218
|
story = PivotalTracker::Story.new(:id => 123456789)
|
209
219
|
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with("git commit --quiet --all --allow-empty --message \"test_message\n\n[#123456789]\"")
|
210
220
|
|
211
|
-
GitPivotalTrackerIntegration::Util::Git.create_commit
|
221
|
+
GitPivotalTrackerIntegration::Util::Git.create_commit 'test_message', story
|
212
222
|
end
|
213
223
|
|
214
|
-
it
|
224
|
+
it 'should create a release tag' do
|
215
225
|
story = PivotalTracker::Story.new(:id => 123456789)
|
216
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return(
|
217
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:create_branch).with(
|
218
|
-
GitPivotalTrackerIntegration::Util::Git.should_receive(:create_commit).with(
|
219
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
220
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
221
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with(
|
222
|
-
|
223
|
-
GitPivotalTrackerIntegration::Util::Git.create_release_tag
|
226
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('master')
|
227
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:create_branch).with('pivotal-tracker-release', false)
|
228
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:create_commit).with('1.0.0.RELEASE Release', story)
|
229
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git tag v1.0.0.RELEASE')
|
230
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet master')
|
231
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git branch --quiet -D pivotal-tracker-release')
|
232
|
+
|
233
|
+
GitPivotalTrackerIntegration::Util::Git.create_release_tag '1.0.0.RELEASE', story
|
224
234
|
end
|
225
235
|
end
|
@@ -13,8 +13,8 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
|
-
require
|
17
|
-
require
|
16
|
+
require 'spec_helper'
|
17
|
+
require 'git-pivotal-tracker-integration/util/shell'
|
18
18
|
|
19
19
|
describe GitPivotalTrackerIntegration::Util::Shell do
|
20
20
|
|
@@ -23,29 +23,29 @@ describe GitPivotalTrackerIntegration::Util::Shell do
|
|
23
23
|
$stderr = StringIO.new
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
27
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:`).with(
|
26
|
+
it 'should return result when exit code is 0' do
|
27
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:`).with('test_command').and_return('test_result')
|
28
28
|
$?.should_receive(:exitstatus).and_return(0)
|
29
29
|
|
30
|
-
result = GitPivotalTrackerIntegration::Util::Shell.exec
|
30
|
+
result = GitPivotalTrackerIntegration::Util::Shell.exec 'test_command'
|
31
31
|
|
32
|
-
expect(result).to eq(
|
32
|
+
expect(result).to eq('test_result')
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should abort with 'FAIL' when the exit code is not 0" do
|
36
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:`).with(
|
36
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:`).with('test_command')
|
37
37
|
$?.should_receive(:exitstatus).and_return(-1)
|
38
38
|
|
39
|
-
lambda { GitPivotalTrackerIntegration::Util::Shell.exec
|
39
|
+
lambda { GitPivotalTrackerIntegration::Util::Shell.exec 'test_command' }.should raise_error(SystemExit)
|
40
40
|
|
41
41
|
expect($stderr.string).to match(/FAIL/)
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
45
|
-
GitPivotalTrackerIntegration::Util::Shell.should_receive(:`).with(
|
44
|
+
it 'should return result when the exit code is not 0 and told not to abort on failure' do
|
45
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:`).with('test_command')
|
46
46
|
$?.should_receive(:exitstatus).and_return(-1)
|
47
47
|
|
48
|
-
GitPivotalTrackerIntegration::Util::Shell.exec
|
48
|
+
GitPivotalTrackerIntegration::Util::Shell.exec 'test_command', false
|
49
49
|
end
|
50
50
|
|
51
51
|
|
@@ -13,9 +13,9 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
16
|
+
require 'spec_helper'
|
17
|
+
require 'git-pivotal-tracker-integration/util/story'
|
18
|
+
require 'pivotal-tracker'
|
19
19
|
|
20
20
|
describe GitPivotalTrackerIntegration::Util::Story do
|
21
21
|
|
@@ -23,18 +23,18 @@ describe GitPivotalTrackerIntegration::Util::Story do
|
|
23
23
|
$stdout = StringIO.new
|
24
24
|
$stderr = StringIO.new
|
25
25
|
|
26
|
-
@project = double(
|
27
|
-
@stories = double(
|
28
|
-
@story = double(
|
29
|
-
@menu = double(
|
26
|
+
@project = double('project')
|
27
|
+
@stories = double('stories')
|
28
|
+
@story = double('story')
|
29
|
+
@menu = double('menu')
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
33
|
-
story = double(
|
32
|
+
it 'should pretty print story information' do
|
33
|
+
story = double('story')
|
34
34
|
story.should_receive(:name)
|
35
35
|
story.should_receive(:description).and_return("description-1\ndescription-2")
|
36
36
|
PivotalTracker::Note.should_receive(:all).and_return([
|
37
|
-
PivotalTracker::Note.new(:noted_at => Date.new, :text =>
|
37
|
+
PivotalTracker::Note.new(:noted_at => Date.new, :text => 'note-1')
|
38
38
|
])
|
39
39
|
|
40
40
|
GitPivotalTrackerIntegration::Util::Story.pretty_print story
|
@@ -47,8 +47,8 @@ describe GitPivotalTrackerIntegration::Util::Story do
|
|
47
47
|
"\n")
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
51
|
-
story = double(
|
50
|
+
it 'should not pretty print description or notes if there are none (empty)' do
|
51
|
+
story = double('story')
|
52
52
|
story.should_receive(:name)
|
53
53
|
story.should_receive(:description)
|
54
54
|
PivotalTracker::Note.should_receive(:all).and_return([])
|
@@ -60,10 +60,10 @@ describe GitPivotalTrackerIntegration::Util::Story do
|
|
60
60
|
"\n")
|
61
61
|
end
|
62
62
|
|
63
|
-
it
|
64
|
-
story = double(
|
63
|
+
it 'should not pretty print description or notes if there are none (nil)' do
|
64
|
+
story = double('story')
|
65
65
|
story.should_receive(:name)
|
66
|
-
story.should_receive(:description).and_return(
|
66
|
+
story.should_receive(:description).and_return('')
|
67
67
|
PivotalTracker::Note.should_receive(:all).and_return([])
|
68
68
|
|
69
69
|
GitPivotalTrackerIntegration::Util::Story.pretty_print story
|
@@ -73,60 +73,60 @@ describe GitPivotalTrackerIntegration::Util::Story do
|
|
73
73
|
"\n")
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
76
|
+
it 'should select a story directly if the filter is a number' do
|
77
77
|
@project.should_receive(:stories).and_return(@stories)
|
78
78
|
@stories.should_receive(:find).with(12345678).and_return(@story)
|
79
79
|
|
80
|
-
story = GitPivotalTrackerIntegration::Util::Story.select_story @project,
|
80
|
+
story = GitPivotalTrackerIntegration::Util::Story.select_story @project, '12345678'
|
81
81
|
|
82
82
|
expect(story).to be(@story)
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
85
|
+
it 'should select a story if the result of the query is a single story' do
|
86
86
|
@project.should_receive(:stories).and_return(@stories)
|
87
87
|
@stories.should_receive(:all).with(
|
88
|
-
:current_state =>
|
88
|
+
:current_state => %w(rejected unstarted unscheduled),
|
89
89
|
:limit => 1,
|
90
|
-
:story_type =>
|
90
|
+
:story_type => 'release'
|
91
91
|
).and_return([@story])
|
92
92
|
|
93
|
-
story = GitPivotalTrackerIntegration::Util::Story.select_story @project,
|
93
|
+
story = GitPivotalTrackerIntegration::Util::Story.select_story @project, 'release', 1
|
94
94
|
|
95
95
|
expect(story).to be(@story)
|
96
96
|
end
|
97
97
|
|
98
|
-
it
|
98
|
+
it 'should prompt the user for a story if the result of the query is more than a single story' do
|
99
99
|
@project.should_receive(:stories).and_return(@stories)
|
100
100
|
@stories.should_receive(:all).with(
|
101
|
-
:current_state =>
|
101
|
+
:current_state => %w(rejected unstarted unscheduled),
|
102
102
|
:limit => 5,
|
103
|
-
:story_type =>
|
103
|
+
:story_type => 'feature'
|
104
104
|
).and_return([
|
105
|
-
PivotalTracker::Story.new(:name =>
|
106
|
-
PivotalTracker::Story.new(:name =>
|
105
|
+
PivotalTracker::Story.new(:name => 'name-1'),
|
106
|
+
PivotalTracker::Story.new(:name => 'name-2')
|
107
107
|
])
|
108
108
|
@menu.should_receive(:prompt=)
|
109
|
-
@menu.should_receive(:choice).with(
|
110
|
-
@menu.should_receive(:choice).with(
|
109
|
+
@menu.should_receive(:choice).with('name-1')
|
110
|
+
@menu.should_receive(:choice).with('name-2')
|
111
111
|
GitPivotalTrackerIntegration::Util::Story.should_receive(:choose) { |&arg| arg.call @menu }.and_return(@story)
|
112
112
|
|
113
|
-
story = GitPivotalTrackerIntegration::Util::Story.select_story @project,
|
113
|
+
story = GitPivotalTrackerIntegration::Util::Story.select_story @project, 'feature'
|
114
114
|
|
115
115
|
expect(story).to be(@story)
|
116
116
|
end
|
117
117
|
|
118
|
-
it
|
118
|
+
it 'should prompt the user with the story type if no filter is specified' do
|
119
119
|
@project.should_receive(:stories).and_return(@stories)
|
120
120
|
@stories.should_receive(:all).with(
|
121
|
-
:current_state =>
|
121
|
+
:current_state => %w(rejected unstarted unscheduled),
|
122
122
|
:limit => 5
|
123
123
|
).and_return([
|
124
|
-
PivotalTracker::Story.new(:story_type =>
|
125
|
-
PivotalTracker::Story.new(:story_type =>
|
124
|
+
PivotalTracker::Story.new(:story_type => 'chore', :name => 'name-1'),
|
125
|
+
PivotalTracker::Story.new(:story_type => 'bug', :name => 'name-2')
|
126
126
|
])
|
127
127
|
@menu.should_receive(:prompt=)
|
128
|
-
@menu.should_receive(:choice).with(
|
129
|
-
@menu.should_receive(:choice).with(
|
128
|
+
@menu.should_receive(:choice).with('CHORE name-1')
|
129
|
+
@menu.should_receive(:choice).with('BUG name-2')
|
130
130
|
GitPivotalTrackerIntegration::Util::Story.should_receive(:choose) { |&arg| arg.call @menu }.and_return(@story)
|
131
131
|
|
132
132
|
story = GitPivotalTrackerIntegration::Util::Story.select_story @project
|