abak-flow 0.3.2 → 1.0.0

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.
@@ -0,0 +1,353 @@
1
+ # coding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe Abak::Flow::PullRequest do
5
+ describe "Interface" do
6
+ subject { described_class.new }
7
+
8
+ it { should respond_to :valid? }
9
+ it { should respond_to :invalid? }
10
+ it { should respond_to :publish }
11
+ it { should respond_to :publish! }
12
+
13
+ it { should respond_to :recommendations }
14
+ it { should respond_to :github_link }
15
+ it { should respond_to :exception }
16
+ end
17
+
18
+ describe "Initialize process" do
19
+ let(:attributes) { {target: "develop", title: "Fix some problem", body: "Check this request"} }
20
+ let(:request) { described_class.new attributes }
21
+
22
+ before do
23
+ Abak::Flow::System.any_instance.stub(:ready).and_return true
24
+ Abak::Flow::System.any_instance.stub(:recommendations).and_return []
25
+ end
26
+
27
+ subject { request }
28
+ its(:options) { should_not be_nil }
29
+
30
+ describe "#recommendations" do
31
+ subject { request.recommendations }
32
+
33
+ its(:first) { should be_empty }
34
+ its(:last) { should be_empty }
35
+ end
36
+ end
37
+
38
+ describe "#title" do
39
+ before { Abak::Flow::Branches.stub(:current_branch).and_return branch }
40
+
41
+ context "when have only branch name" do
42
+ let(:branch) { double("Branch", tracker_task: "hello") }
43
+ subject { described_class.new }
44
+
45
+ its(:title) { should eq "hello" }
46
+ end
47
+
48
+ context "when have only option task" do
49
+ let(:branch) { double("Branch", tracker_task: nil) }
50
+ subject { described_class.new(title: "megusta") }
51
+
52
+ its(:title) { should eq "megusta" }
53
+ end
54
+
55
+ context "when have option task and branch name" do
56
+ let(:branch) { double("Branch", tracker_task: "tako") }
57
+ subject { described_class.new(title: "burito") }
58
+
59
+ its(:title) { should eq "tako :: burito" }
60
+ end
61
+ end
62
+
63
+ describe "#comment" do
64
+ before { Abak::Flow::Branches.stub(:current_branch).and_return branch }
65
+
66
+ describe "when have nothing" do
67
+ let(:branch) { double("Branch", tracker_task: nil, task?: false) }
68
+
69
+ before { Abak::Flow::Messages.any_instance.should_receive(:t).with(:forgot_task).and_return "I forgot my task" }
70
+ subject { described_class.new }
71
+
72
+ its(:comment) { should eq "I forgot my task" }
73
+ end
74
+
75
+ describe "when have only branch name" do
76
+ let(:branch) { double("Branch", tracker_task: "hello", task?: true) }
77
+
78
+ before { described_class.any_instance.stub(:default_comment).and_return "Default comment" }
79
+ subject { described_class.new }
80
+
81
+ its(:comment) { should eq "Default comment" }
82
+ end
83
+
84
+ describe "when have only option comment" do
85
+ let(:branch) { double("Branch", tracker_task: "hello", task?: false) }
86
+
87
+ subject { described_class.new(comment: "megusta") }
88
+
89
+ its(:comment) { should eq "megusta" }
90
+ end
91
+
92
+ describe "when have option comment and branch name" do
93
+ let(:branch) { double("Branch", tracker_task: "tako", task?: true) }
94
+
95
+ before { described_class.any_instance.stub(:default_comment).and_return "Default comment" }
96
+ subject { described_class.new(comment: "burito") }
97
+
98
+ its(:comment) { should include "Default comment" }
99
+ its(:comment) { should include "burito" }
100
+ end
101
+ end
102
+
103
+ describe "#branch" do
104
+ before { Abak::Flow::Branches.stub(:current_branch).and_return branch }
105
+
106
+ describe "when have only option branch" do
107
+ let(:branch) { double("Branch", tracker_task: nil) }
108
+ subject { described_class.new(branch: "tako") }
109
+
110
+ its(:branch) { should eq "tako" }
111
+ end
112
+
113
+ describe "when have only feature branch" do
114
+ let(:branch) { double("Branch", tracker_task: "tako", hotfix?: false, feature?: true) }
115
+
116
+ subject { described_class.new }
117
+
118
+ its(:branch) { should eq "develop" }
119
+ end
120
+
121
+ describe "when have only hotfix branch" do
122
+ let(:branch) { double("Branch", tracker_task: "tako", feature?: false, hotfix?: true) }
123
+
124
+ subject { described_class.new }
125
+
126
+ its(:branch) { should eq "master" }
127
+ end
128
+
129
+ describe "when have hotfix branch and option branch" do
130
+ let(:branch) { double("Branch", tracker_task: "tako", feature?: false, hotfix?: true) }
131
+
132
+ subject { described_class.new(branch: "pewpew") }
133
+
134
+ its(:branch) { should eq "pewpew" }
135
+ end
136
+ end
137
+
138
+
139
+ describe "Publishing process" do
140
+ let(:pull_request) { Abak::Flow::PullRequest.new }
141
+
142
+ subject { pull_request }
143
+
144
+ describe "when something goes wrong" do
145
+ describe "when system is not ready" do
146
+ before { Abak::Flow::System.any_instance.stub(:ready).and_return false }
147
+ before { pull_request.stub(:invalid?).and_return true }
148
+
149
+ its(:publish) { should be_false }
150
+
151
+ describe "#exception" do
152
+ before { pull_request.publish }
153
+
154
+ its(:exception) { should_not be_nil }
155
+ end
156
+ end
157
+
158
+ describe "when pull request is invalid" do
159
+ before { Abak::Flow::System.any_instance.stub(:ready).and_return true }
160
+ before { pull_request.stub(:invalid?).and_return true }
161
+
162
+ its(:publish) { should be_false }
163
+ end
164
+
165
+ describe "when something raise exception" do
166
+ before do
167
+ Abak::Flow::System.any_instance.stub(:ready).and_return true
168
+ pull_request.stub(:invalid?).and_return false
169
+ pull_request.stub(:publish_pull_request).and_raise Exception
170
+ end
171
+
172
+ it { expect { pull_request.publish }.not_to raise_error }
173
+
174
+ describe "#exception" do
175
+ before { pull_request.publish }
176
+
177
+ its(:exception) { should_not be_nil }
178
+ end
179
+ end
180
+ end
181
+
182
+ describe "when all right" do
183
+ before do
184
+ Abak::Flow::System.any_instance.stub(:ready).and_return true
185
+ pull_request.stub(:invalid?).and_return false
186
+ pull_request.stub(:publish_pull_request).and_return double("Result").as_null_object
187
+ end
188
+
189
+ its(:publish) { should be_true }
190
+ end
191
+
192
+ describe "when use bang! method" do
193
+ describe "when something goes wrong" do
194
+ describe "when we raise exception" do
195
+ before { Abak::Flow::System.any_instance.stub(:ready).and_return false }
196
+
197
+ it { expect { pull_request.publish! }.to raise_error Exception }
198
+ end
199
+
200
+ describe "when something raise exception" do
201
+ before { Abak::Flow::System.any_instance.stub(:ready).and_return false }
202
+ before { pull_request.stub(:publish_pull_request).and_raise Exception }
203
+
204
+ it { expect { pull_request.publish! }.to raise_error Exception }
205
+ end
206
+ end
207
+
208
+ describe "when all right" do
209
+ before do
210
+ Abak::Flow::System.any_instance.stub(:ready).and_return true
211
+ pull_request.stub(:invalid?).and_return false
212
+ pull_request.stub(:publish_pull_request).and_return double("Result").as_null_object
213
+ end
214
+
215
+ it { expect { pull_request.publish! }.not_to raise_error }
216
+ end
217
+ end
218
+
219
+ describe "#github_link" do
220
+ describe "when request not published" do
221
+ its(:github_link) { should be_nil }
222
+ end
223
+
224
+ describe "when request successfully published" do
225
+ before do
226
+ Abak::Flow::System.any_instance.stub(:ready).and_return true
227
+ pull_request.stub(:invalid?).and_return false
228
+ pull_request.stub(:publish_pull_request).and_return double("Result", href: "wow").as_null_object
229
+
230
+ pull_request.publish
231
+ end
232
+
233
+ its(:github_link) { should eq "wow" }
234
+ end
235
+ end
236
+ end
237
+
238
+ # describe "Validation process" do
239
+ # describe "when system is not ready" do
240
+ # before do
241
+ # Abak::Flow::PullRequest::System.ready = false
242
+ # Abak::Flow::PullRequest::System.recommendations = %w[one two three]
243
+ # end
244
+ #
245
+ # subject { Abak::Flow::PullRequest.new }
246
+ #
247
+ # describe "when pull request is valid" do
248
+ # it "should not be valid pull request" do
249
+ # subject.stub(:requirements_satisfied?, true) do
250
+ # subject.valid?.must_equal false
251
+ # end
252
+ # end
253
+ #
254
+ # it "should be invalid request" do
255
+ # subject.stub(:requirements_satisfied?, true) do
256
+ # subject.invalid?.must_equal true
257
+ # end
258
+ # end
259
+ #
260
+ # it "should have system recommendations" do
261
+ # subject.stub(:requirements_satisfied?, true) do
262
+ # subject.valid?
263
+ # subject.recommendations[0].wont_be_empty
264
+ # end
265
+ # end
266
+ # end
267
+ #
268
+ # describe "when pull request is invalid" do
269
+ # it "should have only system recommendations" do
270
+ # subject.stub(:requirements_satisfied?, false) do
271
+ # subject.valid?
272
+ # subject.recommendations[0].wont_be_empty
273
+ # subject.recommendations[1].must_be_empty
274
+ # end
275
+ # end
276
+ # end
277
+ # end
278
+ #
279
+ # describe "when system is ready" do
280
+ # before do
281
+ # Abak::Flow::PullRequest::System.ready = true
282
+ # Abak::Flow::PullRequest::System.recommendations = []
283
+ # end
284
+ #
285
+ # subject { Abak::Flow::PullRequest.new }
286
+ #
287
+ # describe "when pull request is valid" do
288
+ # it "should be valid pull request" do
289
+ # subject.stub(:requirements_satisfied?, true) do
290
+ # subject.valid?.must_equal true
291
+ # end
292
+ # end
293
+ #
294
+ # it "should not be invalid request" do
295
+ # subject.stub(:requirements_satisfied?, true) do
296
+ # subject.invalid?.must_equal false
297
+ # end
298
+ # end
299
+ #
300
+ # it "should not have system recommendations" do
301
+ # subject.stub(:requirements_satisfied?, true) do
302
+ # subject.valid?
303
+ # subject.recommendations[0].must_be_empty
304
+ # end
305
+ # end
306
+ # end
307
+ #
308
+ # describe "when pull request is invalid" do
309
+ # describe "when title not specified" do
310
+ # let(:branch) { CurrentBranchMock.new(nil, "hotfix") }
311
+ # before { Abak::Flow::PullRequest::Branches.current_branch = branch }
312
+ #
313
+ # it "should not satisfy requirements" do
314
+ # subject.send(:requirements_satisfied?).must_equal false
315
+ # end
316
+ #
317
+ # it "should have recommendations" do
318
+ # subject.valid?
319
+ # subject.recommendations[1].wont_be_empty
320
+ # end
321
+ # end
322
+ #
323
+ # describe "when branch not specified" do
324
+ # let(:branch) { CurrentBranchMock.new("SG-001", "pewpew") }
325
+ # before { Abak::Flow::PullRequest::Branches.current_branch = branch }
326
+ #
327
+ # it "should not satisfy requirements" do
328
+ # subject.send(:requirements_satisfied?).must_equal false
329
+ # end
330
+ #
331
+ # it "should have recommendations" do
332
+ # subject.valid?
333
+ # subject.recommendations[1].wont_be_empty
334
+ # end
335
+ # end
336
+ #
337
+ # describe "when branch and title not specified" do
338
+ # let(:branch) { CurrentBranchMock.new(nil, "pewpew") }
339
+ # before { Abak::Flow::PullRequest::Branches.current_branch = branch }
340
+ #
341
+ # it "should not satisfy requirements" do
342
+ # subject.send(:requirements_satisfied?).must_equal false
343
+ # end
344
+ #
345
+ # it "should have recommendations" do
346
+ # subject.valid?
347
+ # subject.recommendations[1].wont_be_empty
348
+ # end
349
+ # end
350
+ # end
351
+ # end
352
+ # end
353
+ end
@@ -0,0 +1,97 @@
1
+ # coding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe Abak::Flow::System do
5
+ let(:instance) { described_class.clone.instance }
6
+ let(:remotes) { {origin: "origin_repo", upstream: "upstream_repo"} }
7
+ let(:params) { double("Params", oauth_user: "User", oauth_token: "Token", proxy_server: "http://proxy.com", locale: "en") }
8
+ let(:empty_params) { double("Params", oauth_user: nil, oauth_token: nil, proxy_server: nil, locale: nil) }
9
+
10
+ describe "#ready?" do
11
+ subject { instance.ready? }
12
+
13
+ context "when all requirements is not set" do
14
+ before do
15
+ Abak::Flow::Project.any_instance.stub(:remotes).and_return({})
16
+ Abak::Flow::Configuration.any_instance.stub(:params).and_return empty_params
17
+ end
18
+
19
+ it { should be_false }
20
+ end
21
+
22
+ context "when upstream is not set" do
23
+ before do
24
+ Abak::Flow::Project.any_instance.stub(:remotes).and_return({origin: "not_nil"})
25
+ Abak::Flow::Configuration.any_instance.stub(:params).and_return params
26
+ end
27
+
28
+ it { should be_false }
29
+ end
30
+
31
+ context "when origin is not set" do
32
+ before do
33
+ Abak::Flow::Project.any_instance.stub(:remotes).and_return({upstream: "not_nil"})
34
+ Abak::Flow::Configuration.any_instance.stub(:params).and_return params
35
+ end
36
+
37
+ it { should be_false }
38
+ end
39
+
40
+ context "when all config params is not set" do
41
+ before do
42
+ Abak::Flow::Project.any_instance.stub(:remotes).and_return remotes
43
+ Abak::Flow::Configuration.any_instance.stub(:params).and_return empty_params
44
+ end
45
+
46
+ it { should be_false }
47
+ end
48
+
49
+ context "when proxy server config is not set" do
50
+ before do
51
+ params.stub(:proxy).and_return nil
52
+
53
+ Abak::Flow::Project.any_instance.stub(:remotes).and_return remotes
54
+ Abak::Flow::Configuration.any_instance.stub(:params).and_return params
55
+ end
56
+
57
+ it { should be_true }
58
+ end
59
+
60
+ context "when all config params is set" do
61
+ before do
62
+ Abak::Flow::Project.any_instance.stub(:remotes).and_return remotes
63
+ Abak::Flow::Configuration.any_instance.stub(:params).and_return params
64
+ end
65
+
66
+ it { should be_true }
67
+ end
68
+ end
69
+
70
+ describe "#information" do
71
+ context "when proxy is set" do
72
+ before do
73
+ Abak::Flow::Project.any_instance.stub(:remotes).and_return remotes
74
+ Abak::Flow::Configuration.any_instance.stub(:params).and_return params
75
+ end
76
+
77
+ before { instance.ready? }
78
+ subject { instance.information }
79
+
80
+ it { should_not be_empty }
81
+ end
82
+
83
+ context "when proxy is not set" do
84
+ before do
85
+ params.stub(:proxy_server).and_return nil
86
+
87
+ Abak::Flow::Project.any_instance.stub(:remotes).and_return remotes
88
+ Abak::Flow::Configuration.any_instance.stub(:params).and_return params
89
+ end
90
+
91
+ before { instance.ready? }
92
+ subject { instance.information }
93
+
94
+ it { should be_empty }
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,17 @@
1
+ # coding: utf-8
2
+ if ENV["COVERAGE"]
3
+ require "simplecov"
4
+
5
+ SimpleCov.minimum_coverage 95
6
+ SimpleCov.start :test_frameworks do
7
+ add_filter "/spec/"
8
+ end
9
+ end
10
+
11
+ require "abak-flow"
12
+
13
+ Dir["spec/support/**/*.rb"].sort.each { |f| require f }
14
+
15
+ RSpec.configure do |config|
16
+ # ...
17
+ end
metadata CHANGED
@@ -1,64 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abak-flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Strech (aka Sergey Fedorov)
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-21 00:00:00.000000000 Z
11
+ date: 2013-11-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: hub
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
14
+ version_requirements: !ruby/object:Gem::Requirement
18
15
  requirements:
19
16
  - - ~>
20
17
  - !ruby/object:Gem::Version
21
- version: 1.10.3
18
+ version: 1.19.0
22
19
  type: :runtime
23
20
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
21
+ name: octokit
22
+ requirement: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 1.10.3
26
+ version: 1.19.0
30
27
  - !ruby/object:Gem::Dependency
31
- name: commander
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
28
+ version_requirements: !ruby/object:Gem::Requirement
34
29
  requirements:
35
30
  - - ~>
36
31
  - !ruby/object:Gem::Version
37
- version: 4.1.2
32
+ version: 1.2.5
38
33
  type: :runtime
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
35
+ name: git
36
+ requirement: !ruby/object:Gem::Requirement
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: 4.1.2
40
+ version: 1.2.5
46
41
  - !ruby/object:Gem::Dependency
47
- name: octokit
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 4.1.3
47
+ type: :runtime
48
+ prerelease: false
49
+ name: commander
48
50
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
51
  requirements:
51
- - - ~>
52
+ - - ! '>='
52
53
  - !ruby/object:Gem::Version
53
- version: 1.19.0
54
+ version: 4.1.3
55
+ - !ruby/object:Gem::Dependency
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: 1.4.2
54
61
  type: :runtime
55
62
  prerelease: false
63
+ name: ruler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.4.2
69
+ - !ruby/object:Gem::Dependency
56
70
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
71
  requirements:
59
- - - ~>
72
+ - - ! '>='
60
73
  - !ruby/object:Gem::Version
61
- version: 1.19.0
74
+ version: 0.6.1
75
+ type: :runtime
76
+ prerelease: false
77
+ name: i18n
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.6.1
83
+ - !ruby/object:Gem::Dependency
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: 1.4.3
89
+ type: :runtime
90
+ prerelease: false
91
+ name: ansi
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.4.3
62
97
  description: Простой набор правил и комманд, заточеных для работы в git-flow с использование
63
98
  в качестве удаленного репозитория github
64
99
  email:
@@ -69,6 +104,7 @@ extensions: []
69
104
  extra_rdoc_files: []
70
105
  files:
71
106
  - .gitignore
107
+ - .travis.yml
72
108
  - Gemfile
73
109
  - README.md
74
110
  - Rakefile
@@ -76,34 +112,49 @@ files:
76
112
  - abak-flow.gemspec
77
113
  - bin/request
78
114
  - lib/abak-flow.rb
79
- - lib/abak-flow/config.rb
80
- - lib/abak-flow/extensions.rb
81
- - lib/abak-flow/github_client.rb
115
+ - lib/abak-flow/branch.rb
116
+ - lib/abak-flow/branches.rb
117
+ - lib/abak-flow/configuration.rb
118
+ - lib/abak-flow/locales/en.yml
119
+ - lib/abak-flow/locales/ru.yml
120
+ - lib/abak-flow/manager.rb
121
+ - lib/abak-flow/messages.rb
82
122
  - lib/abak-flow/pull_request.rb
123
+ - lib/abak-flow/repository.rb
83
124
  - lib/abak-flow/request.rb
84
125
  - lib/abak-flow/version.rb
126
+ - lib/abak-flow/visitor.rb
127
+ - spec/abak-flow/branch_spec.rb
128
+ - spec/abak-flow/branches_spec.rb
129
+ - spec/abak-flow/configuration_spec.rb
130
+ - spec/abak-flow/git_spec.rb
131
+ - spec/abak-flow/github_client_spec.rb
132
+ - spec/abak-flow/messages_spec.rb
133
+ - spec/abak-flow/project_spec.rb
134
+ - spec/abak-flow/pull_request_spec.rb
135
+ - spec/abak-flow/system_spec.rb
136
+ - spec/spec_helper.rb
85
137
  homepage: https://github.com/Strech/abak-flow
86
138
  licenses: []
139
+ metadata: {}
87
140
  post_install_message:
88
141
  rdoc_options: []
89
142
  require_paths:
90
143
  - lib
91
144
  required_ruby_version: !ruby/object:Gem::Requirement
92
- none: false
93
145
  requirements:
94
146
  - - ! '>='
95
147
  - !ruby/object:Gem::Version
96
148
  version: '0'
97
149
  required_rubygems_version: !ruby/object:Gem::Requirement
98
- none: false
99
150
  requirements:
100
151
  - - ! '>='
101
152
  - !ruby/object:Gem::Version
102
153
  version: '0'
103
154
  requirements: []
104
155
  rubyforge_project: abak-flow
105
- rubygems_version: 1.8.24
156
+ rubygems_version: 2.0.5
106
157
  signing_key:
107
- specification_version: 3
158
+ specification_version: 4
108
159
  summary: Совмещение 2-х подходов разработки Git-flow & Github-flow
109
160
  test_files: []
@@ -1,20 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- module Abak::Flow
3
- class Config < Struct.new(:api_user, :api_token, :proxy)
4
- [:api_user, :api_token, :proxy].each {|attribute| define_method("#{attribute}?") { !send(attribute).to_s.empty? } }
5
-
6
- def self.current
7
- return @current_config unless @current_config.nil?
8
-
9
- HighLine.color_scheme = HighLine::SampleColorScheme.new
10
- git_reader = Hub::Commands.send(:git_reader)
11
-
12
- api_user = git_reader.read_config('abak.apiuser')
13
- api_token = git_reader.read_config('abak.apitoken')
14
- proxy = git_reader.read_config('abak.proxy')
15
- env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
16
-
17
- @current_config = new(api_user, api_token, proxy || env_proxy)
18
- end
19
- end
20
- end