zenflow 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.zenflow +1 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +12 -1
  5. data/README.markdown +19 -13
  6. data/VERSION.yml +1 -1
  7. data/lib/zenflow/cli.rb +28 -20
  8. data/lib/zenflow/helpers/ask.rb +10 -0
  9. data/lib/zenflow/helpers/branch.rb +22 -3
  10. data/lib/zenflow/helpers/branch_command.rb +3 -2
  11. data/lib/zenflow/helpers/branch_commands/finish.rb +2 -3
  12. data/lib/zenflow/helpers/branch_commands/start.rb +2 -2
  13. data/lib/zenflow/helpers/branch_commands/update.rb +3 -3
  14. data/lib/zenflow/helpers/changelog.rb +1 -1
  15. data/lib/zenflow/helpers/github.rb +8 -6
  16. data/lib/zenflow/helpers/pull_request.rb +1 -1
  17. data/spec/fixtures/cassettes/create_bad_pull_request.yml +10 -10
  18. data/spec/fixtures/cassettes/create_pull_request.yml +14 -16
  19. data/spec/fixtures/cassettes/existing_pull_request.yml +30 -34
  20. data/spec/fixtures/cassettes/pull_request_by_ref.yml +30 -34
  21. data/spec/fixtures/cassettes/pull_request_find.yml +9 -11
  22. data/spec/fixtures/cassettes/pull_request_for_non-existent_ref.yml +30 -34
  23. data/spec/fixtures/cassettes/pull_request_list.yml +15 -17
  24. data/spec/fixtures/cassettes/unexisting_pull_request.yml +30 -34
  25. data/spec/spec_helper.rb +6 -0
  26. data/spec/zenflow/helpers/ask_spec.rb +4 -0
  27. data/spec/zenflow/helpers/branch_command_spec.rb +116 -38
  28. data/spec/zenflow/helpers/branch_spec.rb +40 -0
  29. data/spec/zenflow/helpers/changelog_spec.rb +2 -2
  30. data/spec/zenflow/helpers/cli_spec.rb +31 -10
  31. data/spec/zenflow/helpers/help_spec.rb +4 -3
  32. data/spec/zenflow/helpers/log_spec.rb +1 -1
  33. data/spec/zenflow/helpers/pull_request_spec.rb +31 -28
  34. metadata +3 -3
@@ -47,10 +47,42 @@ describe Zenflow::Branch do
47
47
 
48
48
  describe "self.update" do
49
49
  it "updates the branch" do
50
+ Zenflow::Config.should_receive(:[]).with(:merge_strategy).and_return('merge')
50
51
  Zenflow.should_receive(:Log).with("Updating the master branch")
51
52
  Zenflow::Shell.should_receive(:run).with("git checkout master && git pull")
52
53
  Zenflow::Branch.update('master')
53
54
  end
55
+
56
+ it "updates the branch using a rebase override" do
57
+ Zenflow::Config.should_receive(:[]).with(:merge_strategy).and_return('merge')
58
+ Zenflow.should_receive(:Log).with("Updating the master branch using pull with --rebase")
59
+ Zenflow::Shell.should_receive(:run).with("git checkout master && git pull --rebase")
60
+ Zenflow::Branch.update('master', true)
61
+ end
62
+ end
63
+
64
+ describe "self.apply_merge_strategy" do
65
+ it "merges the branch using the merge strategy" do
66
+ Zenflow::Config.should_receive(:[]).with(:merge_strategy).and_return('merge')
67
+ Zenflow::Branch.should_receive(:checkout).with("feature/testing-123")
68
+ Zenflow::Branch.should_receive(:merge).with('master')
69
+
70
+ Zenflow::Branch.apply_merge_strategy('feature', 'testing-123', 'master')
71
+ end
72
+
73
+ it "merges the branch using the rebase strategy" do
74
+ Zenflow::Config.should_receive(:[]).with(:merge_strategy).and_return('rebase')
75
+ Zenflow::Branch.should_receive(:rebase).with("feature/testing-123", 'master')
76
+
77
+ Zenflow::Branch.apply_merge_strategy('feature', 'testing-123', 'master')
78
+ end
79
+
80
+ it "optionally allows the merge strategy to be overridden by a --rebase flag when doing an update" do
81
+ Zenflow::Config.should_receive(:[]).with(:merge_strategy).and_return('merge')
82
+ Zenflow::Branch.should_receive(:rebase).with("feature/testing-123", 'master')
83
+
84
+ Zenflow::Branch.apply_merge_strategy('feature', 'testing-123', 'master', true)
85
+ end
54
86
  end
55
87
 
56
88
  describe "self.create" do
@@ -201,6 +233,14 @@ describe Zenflow::Branch do
201
233
  end
202
234
  end
203
235
 
236
+ describe "self.rebase" do
237
+ it "checks out the branch" do
238
+ Zenflow.should_receive(:Log).with("Rebasing feature/test-checkout on top of the master branch")
239
+ Zenflow::Shell.should_receive(:run).with("git rebase master feature/test-checkout")
240
+ Zenflow::Branch.rebase('feature/test-checkout', 'master')
241
+ end
242
+ end
243
+
204
244
  describe "self.merge" do
205
245
  it "merges in the specified branch" do
206
246
  Zenflow.should_receive(:Log).with("Merging in the feature/test-merging branch")
@@ -67,7 +67,7 @@ describe Zenflow::Changelog do
67
67
  file_handler.should_receive(:write).with('some other text I suppose')
68
68
  File.should_receive(:open).with("CHANGELOG.md", "w").and_yield(file_handler)
69
69
  Zenflow::Changelog.should_not_receive(:rotate)
70
- Zenflow::Shell.should_receive(:run).with("git add . && git commit -a -m 'Adding line to CHANGELOG: changed the world'")
70
+ Zenflow::Shell.should_receive(:run).with("git add CHANGELOG.md && git commit -a -m 'Adding line to CHANGELOG: changed the world'")
71
71
  Zenflow::Changelog.prepend_change_to_changelog('changed the world')
72
72
  end
73
73
  end
@@ -76,7 +76,7 @@ describe Zenflow::Changelog do
76
76
  it "prepends changes to the changelog" do
77
77
  File.should_receive(:open).with("CHANGELOG.md", "w")
78
78
  Zenflow::Changelog.should_receive(:rotate)
79
- Zenflow::Shell.should_receive(:run).with("git add . && git commit -a -m 'Adding line to CHANGELOG: changed the world'")
79
+ Zenflow::Shell.should_receive(:run).with("git add CHANGELOG.md && git commit -a -m 'Adding line to CHANGELOG: changed the world'")
80
80
  Zenflow::Changelog.prepend_change_to_changelog('changed the world', :rotate => true)
81
81
  end
82
82
  end
@@ -102,7 +102,7 @@ describe Zenflow::CLI do
102
102
  end
103
103
 
104
104
  describe "#already_configured" do
105
- let(:question) {['There is an existing config file. Overwrite it?', {:options => ["y", "N"], :default => "N"}]}
105
+ let(:question) {['There is an existing config file. Overwrite it?', {:options => ["y", "N"], :default => "n"}]}
106
106
  before do
107
107
  Zenflow.should_receive(:Log).with('Warning', :color => :red)
108
108
  end
@@ -133,7 +133,7 @@ describe Zenflow::CLI do
133
133
  describe "#configure_branch" do
134
134
  context "when the user wants to configure a staging branch" do
135
135
  before do
136
- Zenflow.should_receive(:Ask).with("Use a branch for staging releases and hotfixes?", :options => ["Y", "n"], :default => "Y").and_return('y')
136
+ Zenflow.should_receive(:Ask).with("Use a branch for staging releases and hotfixes?", :options => ["Y", "n"], :default => "y").and_return('y')
137
137
  end
138
138
 
139
139
  it 'names the staging branch whatever the user wants' do
@@ -145,7 +145,7 @@ describe Zenflow::CLI do
145
145
 
146
146
  context "when the user does not want to configure a staging branch" do
147
147
  before do
148
- Zenflow.should_receive(:Ask).with("Use a branch for staging releases and hotfixes?", :options => ["Y", "n"], :default => "Y").and_return('n')
148
+ Zenflow.should_receive(:Ask).with("Use a branch for staging releases and hotfixes?", :options => ["Y", "n"], :default => "y").and_return('n')
149
149
  end
150
150
 
151
151
  it 'names the staging branch whatever the user wants' do
@@ -155,6 +155,24 @@ describe Zenflow::CLI do
155
155
  end
156
156
  end
157
157
 
158
+ describe "#configure_merge_strategy" do
159
+ context "when the user wants to keep the default merge strategy of 'merge'" do
160
+ it 'sets the merge strategy to merge' do
161
+ Zenflow.should_receive(:Ask).with("What merge strategy would you prefer?", :options => ["merge", "rebase"], :default => "merge").and_return('merge')
162
+ Zenflow::Config.should_receive(:[]=).with(:merge_strategy, 'merge')
163
+ subject.configure_merge_strategy
164
+ end
165
+ end
166
+
167
+ context "when the user wants to change the default merge strategy to 'rebase'" do
168
+ it 'sets the merge strategy to rebase' do
169
+ Zenflow.should_receive(:Ask).with("What merge strategy would you prefer?", :options => ["merge", "rebase"], :default => "merge").and_return('rebase')
170
+ Zenflow::Config.should_receive(:[]=).with(:merge_strategy, 'rebase')
171
+ subject.configure_merge_strategy
172
+ end
173
+ end
174
+ end
175
+
158
176
  describe "#configure_project" do
159
177
  it 'asks the user to name their project' do
160
178
  Zenflow.should_receive(:Ask).with("What is the name of this project?", :required => true).and_return('zenflow')
@@ -177,7 +195,7 @@ describe Zenflow::CLI do
177
195
  describe "#configure_remotes" do
178
196
  context "when the user wants to configure a backup remote" do
179
197
  before do
180
- Zenflow.should_receive(:Ask).with("Use a backup remote?", :options => ["Y", "n"], :default => "n").and_return('y')
198
+ Zenflow.should_receive(:Ask).with("Use a backup remote?", :options => ["y", "N"], :default => "n").and_return('y')
181
199
  end
182
200
 
183
201
  it 'configures the primary remote and a backup remote' do
@@ -191,7 +209,7 @@ describe Zenflow::CLI do
191
209
 
192
210
  context "when the user does not want to configure a backup remote" do
193
211
  before do
194
- Zenflow.should_receive(:Ask).with("Use a backup remote?", :options => ["Y", "n"], :default => "n").and_return('n')
212
+ Zenflow.should_receive(:Ask).with("Use a backup remote?", :options => ["y", "N"], :default => "n").and_return('n')
195
213
  end
196
214
 
197
215
  it 'configures the primary remote and a backup remote' do
@@ -213,7 +231,7 @@ describe Zenflow::CLI do
213
231
 
214
232
  context "when the user wants to set up a changelog" do
215
233
  it 'sets up the changelog' do
216
- Zenflow.should_receive(:Ask).with("Set up a changelog?", :options => ["Y", "n"], :default => "Y").and_return('y')
234
+ Zenflow.should_receive(:Ask).with("Set up a changelog?", :options => ["Y", "n"], :default => "y").and_return('y')
217
235
  Zenflow::Changelog.should_receive(:create)
218
236
  subject.set_up_changelog
219
237
  end
@@ -221,7 +239,7 @@ describe Zenflow::CLI do
221
239
 
222
240
  context "when the user does not want to set up a changelog" do
223
241
  it 'does not set up the changelog' do
224
- Zenflow.should_receive(:Ask).with("Set up a changelog?", :options => ["Y", "n"], :default => "Y").and_return('n')
242
+ Zenflow.should_receive(:Ask).with("Set up a changelog?", :options => ["Y", "n"], :default => "y").and_return('n')
225
243
  Zenflow::Changelog.should_not_receive(:create)
226
244
  subject.set_up_changelog
227
245
  end
@@ -235,7 +253,7 @@ describe Zenflow::CLI do
235
253
 
236
254
  it 'does not set up the changelog' do
237
255
  Zenflow.should_not_receive(:Log).with("Changelog Management")
238
- Zenflow.should_not_receive(:Ask).with("Set up a changelog?", :options => ["Y", "n"], :default => "Y")
256
+ Zenflow.should_not_receive(:Ask).with("Set up a changelog?", :options => ["Y", "n"], :default => "y")
239
257
  Zenflow::Changelog.should_not_receive(:create)
240
258
  subject.set_up_changelog
241
259
  end
@@ -245,9 +263,9 @@ describe Zenflow::CLI do
245
263
  describe "#confirm_some_stuff" do
246
264
  it "confirms staging deployment and code review requirements" do
247
265
  Zenflow.should_receive(:Log).with("Confirmations")
248
- Zenflow.should_receive(:Ask).with("Require deployment to a staging environment?", :options => ["Y", "n"], :default => "Y").and_return('y')
266
+ Zenflow.should_receive(:Ask).with("Require deployment to a staging environment?", :options => ["Y", "n"], :default => "y").and_return('y')
249
267
  Zenflow::Config.should_receive(:[]=).with(:confirm_staging, true)
250
- Zenflow.should_receive(:Ask).with("Require code reviews?", :options => ["Y", "n"], :default => "Y").and_return('n')
268
+ Zenflow.should_receive(:Ask).with("Require code reviews?", :options => ["Y", "n"], :default => "y").and_return('n')
251
269
  Zenflow::Config.should_receive(:[]=).with(:confirm_review, false)
252
270
  subject.confirm_some_stuff
253
271
  end
@@ -265,6 +283,7 @@ describe Zenflow::CLI do
265
283
  subject.should_receive(:authorize_github)
266
284
  subject.should_receive(:configure_project)
267
285
  subject.should_receive(:configure_branches)
286
+ subject.should_receive(:configure_merge_strategy)
268
287
  subject.should_receive(:configure_remotes)
269
288
  subject.should_receive(:confirm_some_stuff)
270
289
  subject.should_receive(:set_up_changelog)
@@ -285,6 +304,7 @@ describe Zenflow::CLI do
285
304
  subject.should_receive(:authorize_github)
286
305
  subject.should_receive(:configure_project)
287
306
  subject.should_receive(:configure_branches)
307
+ subject.should_receive(:configure_merge_strategy)
288
308
  subject.should_receive(:configure_remotes)
289
309
  subject.should_receive(:confirm_some_stuff)
290
310
  subject.should_receive(:set_up_changelog)
@@ -305,6 +325,7 @@ describe Zenflow::CLI do
305
325
  subject.should_not_receive(:authorize_github)
306
326
  subject.should_not_receive(:configure_project)
307
327
  subject.should_not_receive(:configure_branches)
328
+ subject.should_not_receive(:configure_merge_strategy)
308
329
  subject.should_not_receive(:configure_remotes)
309
330
  subject.should_not_receive(:confirm_some_stuff)
310
331
  subject.should_not_receive(:set_up_changelog)
@@ -13,9 +13,10 @@ describe Zenflow::Help do
13
13
  :usage => "test-help (optional please)",
14
14
  :commands => ['test-help', 'spec-help'])}
15
15
 
16
- it "has an amazing banner" do
17
- expect(subject.banner).to eq("\e[36m- Summary ------------------------------\e[0m\ntests Zenflow::Help\n\n\e[36m- Usage --------------------------------\e[0m\ntest-help (optional please)\n\n\e[36m- Available Commands -------------------\e[0m\n[\"test-help\", \"spec-help\"]\n\n\e[36m- Options ------------------------------\e[0m")
18
- end
16
+ it{expect(subject.banner).to match(/Summary/)}
17
+ it{expect(subject.banner).to match(/Usage/)}
18
+ it{expect(subject.banner).to match(/Available Commands/)}
19
+ it{expect(subject.banner).to match(/Options/)}
19
20
 
20
21
  context "#unknown_command" do
21
22
  describe "when the command is missing" do
@@ -18,7 +18,7 @@ describe Zenflow do
18
18
  end
19
19
 
20
20
  it 'colorizes the text' do
21
- $stdout.should_receive(:puts).with(/\e\[34mfoo/)
21
+ $stdout.should_receive(:puts).with(/foo/)
22
22
  Zenflow.Log('foo', color: :blue, arrows: false)
23
23
  end
24
24
 
@@ -2,9 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Zenflow::PullRequest do
4
4
  before(:each){
5
- Zenflow::Github.stub(:user).and_return('github-user')
6
- Zenflow::Github.stub(:token).and_return('github-token')
7
5
  Zenflow::Github.stub(:zenflow_token).and_return('zenflow-token')
6
+ Zenflow::Github.stub(:user).and_return('github-user')
8
7
  Zenflow::GithubRequest.base_uri 'https://api.github.com/repos/zencoder/zenflow-example'
9
8
  }
10
9
 
@@ -63,8 +62,8 @@ describe Zenflow::PullRequest do
63
62
  end
64
63
  end
65
64
 
66
- describe '.create', vcr: { cassette_name: "create pull request" } do
67
- let(:request_options) do
65
+ context "creating pull requests" do
66
+ let(:good_request_options) do
68
67
  {
69
68
  base: 'master',
70
69
  head: 'feature/new-branch',
@@ -72,36 +71,40 @@ describe Zenflow::PullRequest do
72
71
  body: 'making a new pull request'
73
72
  }
74
73
  end
75
- it{ expect(Zenflow::PullRequest.create(request_options)).to(
76
- be_a_kind_of(Zenflow::PullRequest)
77
- ) }
78
- end
79
74
 
80
- describe '#valid?' do
81
- context 'good request', vcr: { cassette_name: "create pull request" } do
82
- let(:request){Zenflow::PullRequest.create({})}
83
- it{expect(request.valid?).to be_true}
75
+ let(:bad_request_options) do
76
+ {
77
+ base: 'master',
78
+ head: 'feature/phoney',
79
+ title: 'this feature does not exist',
80
+ body: 'gonna fail'
81
+ }
82
+ end
83
+
84
+ describe '.create', vcr: { cassette_name: "create pull request" } do
85
+ it{ expect(Zenflow::PullRequest.create(good_request_options)).to(
86
+ be_a_kind_of(Zenflow::PullRequest)
87
+ ) }
84
88
  end
85
89
 
86
- context 'bad request', vcr: { cassette_name: "create bad pull request" } do
87
- let(:request_options) do
88
- {
89
- base: 'master',
90
- head: 'feature/phoney',
91
- title: 'this feature does not exist',
92
- body: 'gonna fail'
93
- }
90
+ describe '#valid?' do
91
+ context 'good request', vcr: { cassette_name: "create pull request" } do
92
+ let(:request){Zenflow::PullRequest.create(good_request_options)}
93
+ it{expect(request.valid?).to be_true}
94
+ end
95
+
96
+ context 'bad request', vcr: { cassette_name: "create bad pull request" } do
97
+ let(:request){Zenflow::PullRequest.create(bad_request_options)}
98
+ it{expect(request.valid?).to be_false}
94
99
  end
95
- let(:request){Zenflow::PullRequest.create()}
96
- it{expect(request.valid?).to be_false}
97
100
  end
98
- end
99
101
 
100
- describe '#[]' do
101
- context 'good request', vcr: { cassette_name: "create pull request" } do
102
- let(:request){Zenflow::PullRequest.create({})}
103
- it{expect(request["comments"]).to_not be_nil}
104
- it{expect(request["fdsfa"]).to be_nil}
102
+ describe '#[]' do
103
+ context 'good request', vcr: { cassette_name: "create pull request" } do
104
+ let(:request){Zenflow::PullRequest.create(good_request_options)}
105
+ it{expect(request["comments"]).to_not be_nil}
106
+ it{expect(request["fdsfa"]).to be_nil}
107
+ end
105
108
  end
106
109
  end
107
110
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zenflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Kittelson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-07-18 00:00:00.000000000 Z
13
+ date: 2013-10-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -266,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
266
  version: '0'
267
267
  requirements: []
268
268
  rubyforge_project:
269
- rubygems_version: 2.0.3
269
+ rubygems_version: 2.0.6
270
270
  signing_key:
271
271
  specification_version: 4
272
272
  summary: Branch management and deployment tool.