git_reflow 0.8.9 → 0.9.3

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 (87) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/multi-ruby-tests.yml +33 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +2 -0
  5. data/.ruby-version +1 -0
  6. data/Appraisals +1 -6
  7. data/CHANGELOG.md +466 -348
  8. data/Gemfile.lock +99 -72
  9. data/LICENSE +20 -20
  10. data/README.md +481 -0
  11. data/Rakefile +15 -8
  12. data/Workflow +3 -0
  13. data/_config.yml +1 -0
  14. data/bin/console +7 -7
  15. data/bin/setup +6 -6
  16. data/exe/git-reflow +20 -36
  17. data/git_reflow.gemspec +26 -30
  18. data/lib/git_reflow.rb +3 -15
  19. data/lib/git_reflow/config.rb +48 -13
  20. data/lib/git_reflow/git_helpers.rb +69 -22
  21. data/lib/git_reflow/git_server.rb +63 -63
  22. data/lib/git_reflow/git_server/base.rb +68 -68
  23. data/lib/git_reflow/git_server/bit_bucket.rb +101 -101
  24. data/lib/git_reflow/git_server/bit_bucket/pull_request.rb +84 -84
  25. data/lib/git_reflow/git_server/git_hub.rb +53 -41
  26. data/lib/git_reflow/git_server/git_hub/pull_request.rb +16 -14
  27. data/lib/git_reflow/git_server/pull_request.rb +4 -2
  28. data/lib/git_reflow/merge_error.rb +9 -9
  29. data/lib/git_reflow/rspec.rb +3 -2
  30. data/lib/git_reflow/rspec/command_line_helpers.rb +23 -6
  31. data/lib/git_reflow/rspec/stub_helpers.rb +13 -13
  32. data/lib/git_reflow/rspec/workflow_helpers.rb +18 -0
  33. data/lib/git_reflow/sandbox.rb +16 -6
  34. data/lib/git_reflow/version.rb +1 -1
  35. data/lib/git_reflow/workflow.rb +304 -9
  36. data/lib/git_reflow/workflows/FlatMergeWorkflow +38 -0
  37. data/lib/git_reflow/workflows/core.rb +364 -238
  38. data/spec/fixtures/authentication_failure.json +3 -0
  39. data/spec/fixtures/awesome_workflow.rb +3 -7
  40. data/spec/fixtures/git/git_config +7 -7
  41. data/spec/fixtures/issues/comment.json.erb +27 -27
  42. data/spec/fixtures/issues/comments.json +29 -29
  43. data/spec/fixtures/issues/comments.json.erb +15 -15
  44. data/spec/fixtures/pull_requests/comment.json.erb +45 -45
  45. data/spec/fixtures/pull_requests/comments.json +47 -47
  46. data/spec/fixtures/pull_requests/comments.json.erb +15 -15
  47. data/spec/fixtures/pull_requests/commits.json +29 -29
  48. data/spec/fixtures/pull_requests/external_pull_request.json +145 -145
  49. data/spec/fixtures/pull_requests/pull_request.json +142 -142
  50. data/spec/fixtures/pull_requests/pull_request.json.erb +142 -142
  51. data/spec/fixtures/pull_requests/pull_request_branch_nonexistent_error.json +32 -0
  52. data/spec/fixtures/pull_requests/pull_request_exists_error.json +32 -32
  53. data/spec/fixtures/pull_requests/pull_requests.json +136 -136
  54. data/spec/fixtures/repositories/commit.json +53 -53
  55. data/spec/fixtures/repositories/commit.json.erb +53 -53
  56. data/spec/fixtures/repositories/commits.json.erb +13 -13
  57. data/spec/fixtures/repositories/statuses.json +31 -31
  58. data/spec/fixtures/users/user.json +32 -0
  59. data/spec/lib/git_reflow/git_helpers_spec.rb +115 -12
  60. data/spec/lib/git_reflow/git_server/bit_bucket_spec.rb +81 -81
  61. data/spec/lib/git_reflow/git_server/git_hub/pull_request_spec.rb +10 -10
  62. data/spec/lib/git_reflow/git_server/git_hub_spec.rb +77 -3
  63. data/spec/lib/git_reflow/git_server/pull_request_spec.rb +9 -3
  64. data/spec/lib/git_reflow/git_server_spec.rb +101 -101
  65. data/spec/lib/git_reflow/sandbox_spec.rb +1 -1
  66. data/spec/lib/git_reflow/workflow_spec.rb +304 -59
  67. data/spec/lib/git_reflow/workflows/core_spec.rb +225 -67
  68. data/spec/lib/git_reflow/workflows/flat_merge_spec.rb +71 -59
  69. data/spec/lib/git_reflow_spec.rb +2 -25
  70. data/spec/spec_helper.rb +3 -0
  71. data/spec/support/fixtures.rb +54 -54
  72. data/spec/support/github_helpers.rb +99 -109
  73. data/spec/support/mock_pull_request.rb +17 -17
  74. data/spec/support/web_mocks.rb +39 -39
  75. metadata +51 -74
  76. data/README.rdoc +0 -461
  77. data/circle.yml +0 -26
  78. data/lib/git_reflow/commands/deliver.rb +0 -10
  79. data/lib/git_reflow/commands/refresh.rb +0 -20
  80. data/lib/git_reflow/commands/review.rb +0 -13
  81. data/lib/git_reflow/commands/setup.rb +0 -11
  82. data/lib/git_reflow/commands/stage.rb +0 -9
  83. data/lib/git_reflow/commands/start.rb +0 -18
  84. data/lib/git_reflow/commands/status.rb +0 -7
  85. data/lib/git_reflow/os_detector.rb +0 -23
  86. data/lib/git_reflow/workflows/flat_merge.rb +0 -10
  87. data/spec/fixtures/workflow_with_super.rb +0 -8
@@ -9,7 +9,7 @@ RSpec.describe GitReflow::Sandbox do
9
9
 
10
10
  it "when blocking is flagged off, the command exits silently" do
11
11
  allow(GitReflow::Sandbox).to receive(:run).and_call_original
12
- expect { GitReflow::Sandbox.run("ls wtf", blocking: false) }.to_not raise_error SystemExit
12
+ expect { GitReflow::Sandbox.run("ls wtf", blocking: false) }.to_not raise_error
13
13
  end
14
14
  end
15
15
  end
@@ -1,59 +1,304 @@
1
- require 'spec_helper'
2
-
3
- describe GitReflow::Workflow do
4
-
5
- class DummyWorkflow
6
- include GitReflow::Workflow
7
- end
8
-
9
- let(:workflow) { DummyWorkflow }
10
- let(:loader) { double() }
11
-
12
- describe ".current" do
13
- subject { GitReflow::Workflow.current }
14
-
15
- context "when no workflow is set" do
16
- before { allow(GitReflow::Config).to receive(:get).with("reflow.workflow").and_return('') }
17
- specify { expect( subject ).to eql(GitReflow::Workflows::Core) }
18
- end
19
-
20
- context "when a workflow is set" do
21
- let(:workflow_path) { File.join(File.expand_path("../../../fixtures", __FILE__), "/awesome_workflow.rb") }
22
-
23
- before { allow(GitReflow::Config).to receive(:get).with("reflow.workflow").and_return(workflow_path) }
24
- specify { expect( subject ).to eql(GitReflow::Workflow::AwesomeWorkflow) }
25
- end
26
- end
27
-
28
- describe ".command" do
29
- it "creates a class method for a bogus command" do
30
- class DummyWorkflow
31
- include GitReflow::Workflow
32
- end
33
- workflow.command :bogus do
34
- "Woohoo"
35
- end
36
-
37
- expect(DummyWorkflow.bogus).to eql("Woohoo")
38
- end
39
-
40
- it "creates a method for a bogus command with arguments" do
41
- workflow.command :bogus, arguments: [:feature_branch] do |**params|
42
- "Woohoo #{params[:feature_branch]}!"
43
- end
44
-
45
- expect(DummyWorkflow.bogus(feature_branch: "donuts")).to eql("Woohoo donuts!")
46
- end
47
-
48
- it "creates a class method for a bogus command with default options" do
49
- workflow.command :bogus, arguments: [:feature_branch], defaults: {decoration: 'sprinkles'} do |**params|
50
- donut_excitement = "Woohoo #{params[:feature_branch]}"
51
- donut_excitement += " with #{params[:decoration]}" if params[:decoration]
52
- "#{donut_excitement}!"
53
- end
54
-
55
- expect(DummyWorkflow.bogus(feature_branch: "donuts")).to eql("Woohoo donuts with sprinkles!")
56
- end
57
- end
58
-
59
- end
1
+ require 'spec_helper'
2
+
3
+ describe GitReflow::Workflow do
4
+
5
+ class DummyWorkflow
6
+ include GitReflow::Workflow
7
+ end
8
+
9
+ class DummyBundler
10
+ def gemfile(&block)
11
+ instance_eval &block
12
+ end
13
+
14
+ def source(name); end
15
+ def gem(name, *args); end
16
+ end
17
+
18
+ class DummyGemifiedWorkflow
19
+ include GitReflow::Workflow
20
+
21
+ command :whirl do
22
+ puts "whirl"
23
+ end
24
+ end
25
+
26
+ let(:workflow) { DummyWorkflow }
27
+ let(:loader) { double() }
28
+
29
+ describe ".current" do
30
+ subject { GitReflow::Workflow.current }
31
+
32
+ before do
33
+ allow(GitReflow::Workflows::Core).to receive(:load_raw_workflow)
34
+ end
35
+
36
+ context "when no workflow is set" do
37
+ before { allow(GitReflow::Config).to receive(:get).with("reflow.workflow").and_return('') }
38
+ specify { expect( subject ).to eql(GitReflow::Workflows::Core) }
39
+ end
40
+
41
+ context "when a global workflow is set" do
42
+ let(:workflow_path) { File.join(File.expand_path("../../../fixtures", __FILE__), "/awesome_workflow.rb") }
43
+
44
+ before { allow(GitReflow::Config).to receive(:get).with("reflow.workflow").and_return(workflow_path) }
45
+ specify { expect( subject ).to eql(GitReflow::Workflows::Core) }
46
+ end
47
+
48
+ context "when a local workflow is set" do
49
+ let(:workflow_content) do
50
+ <<~WORKFLOW_CONTENT
51
+ command :dummy do
52
+ GitReflow.say "derp"
53
+ end
54
+ WORKFLOW_CONTENT
55
+ end
56
+
57
+ before do
58
+ allow(File).to receive(:exists?).with("#{GitReflow.git_root_dir}/Workflow").and_return(true)
59
+ allow(File).to receive(:read).with("#{GitReflow.git_root_dir}/Workflow").and_return(workflow_content)
60
+ expect(GitReflow::Workflows::Core).to receive(:load_raw_workflow).with(workflow_content).and_call_original
61
+ end
62
+
63
+ specify { expect( subject ).to respond_to(:dummy) }
64
+ specify { expect( subject ).to eql(GitReflow::Workflows::Core) }
65
+ end
66
+
67
+ context "when both a local and a global workflow are set" do
68
+ let(:workflow_path) { File.join(File.expand_path("../../../fixtures", __FILE__), "/awesome_workflow.rb") }
69
+ let(:workflow_content) do
70
+ <<~WORKFLOW_CONTENT
71
+ command :dummy do
72
+ GitReflow.say "derp"
73
+ end
74
+ WORKFLOW_CONTENT
75
+ end
76
+
77
+ before do
78
+ allow(File).to receive(:exists?).with("#{GitReflow.git_root_dir}/Workflow").and_return(true)
79
+ allow(File).to receive(:read).with("#{GitReflow.git_root_dir}/Workflow").and_return(workflow_content)
80
+ allow(GitReflow::Config).to receive(:get).with("reflow.workflow").and_return(workflow_path)
81
+ allow(GitReflow::Workflows::Core).to receive(:load_raw_workflow).and_call_original
82
+ end
83
+
84
+ specify { expect(subject).to respond_to(:dummy) }
85
+ specify { expect(subject).to eql(GitReflow::Workflows::Core) }
86
+ end
87
+ end
88
+
89
+ describe ".before" do
90
+ it "executes the block before the command" do
91
+ GitReflow::Workflows::Core.load_raw_workflow <<~WORKFLOW_CONTENT
92
+ command :yips do
93
+ puts "Yips."
94
+ end
95
+
96
+ before :yips do
97
+ puts "Would you like a donut?"
98
+ end
99
+ WORKFLOW_CONTENT
100
+
101
+ allow(GitReflow::Workflows::Core).to receive(:load_workflow).and_return(true)
102
+
103
+ expect { GitReflow.workflow.yips }.to have_output "Would you like a donut?\nYips."
104
+ end
105
+
106
+ it "executes blocks sequentially by order of appearance" do
107
+ GitReflow::Workflows::Core.load_raw_workflow <<~WORKFLOW_CONTENT
108
+ command :yips do
109
+ puts "Yips."
110
+ end
111
+
112
+ before :yips do
113
+ puts "Cupcake?"
114
+ end
115
+
116
+ before :yips do
117
+ puts "Would you like a donut?"
118
+ end
119
+ WORKFLOW_CONTENT
120
+
121
+ allow(GitReflow::Workflows::Core).to receive(:load_workflow).and_return(true)
122
+
123
+ expect { GitReflow.workflow.yips }.to have_output "Cupcake?\nWould you like a donut?\nYips."
124
+ end
125
+
126
+ it "proxies any arguments returned to the command" do
127
+ GitReflow::Workflows::Core.load_raw_workflow <<~WORKFLOW_CONTENT
128
+ command :yips, arguments: { spiced: false } do |**params|
129
+ puts params[:spiced] ? "Too spicy." : "Yips."
130
+ end
131
+
132
+ before :yips do
133
+ puts "Wasabe?"
134
+ { spiced: true }
135
+ end
136
+ WORKFLOW_CONTENT
137
+
138
+ allow(GitReflow::Workflows::Core).to receive(:load_workflow).and_return(true)
139
+
140
+ expect { GitReflow.workflow.yips }.to have_output "Wasabe?\nToo spicy."
141
+ end
142
+ end
143
+
144
+ describe ".after" do
145
+ it "executes the block after the command" do
146
+ GitReflow::Workflows::Core.load_raw_workflow <<~WORKFLOW_CONTENT
147
+ command :vroom do
148
+ puts "Vroom"
149
+ end
150
+
151
+ after :vroom do
152
+ puts "VROOOOM"
153
+ end
154
+ WORKFLOW_CONTENT
155
+
156
+ allow(GitReflow::Workflows::Core).to receive(:load_workflow).and_return(true)
157
+
158
+ expect { GitReflow.workflow.vroom }.to have_output "Vroom\nVROOOOM"
159
+ end
160
+
161
+ it "executes blocks sequentially by order of appearance" do
162
+ GitReflow::Workflows::Core.load_raw_workflow <<~WORKFLOW_CONTENT
163
+ command :vroom do
164
+ puts "Vroom"
165
+ end
166
+
167
+ after :vroom do
168
+ puts "Vrooom"
169
+ end
170
+
171
+ after :vroom do
172
+ puts "VROOOOM"
173
+ end
174
+ WORKFLOW_CONTENT
175
+
176
+ allow(GitReflow::Workflows::Core).to receive(:load_workflow).and_return(true)
177
+
178
+ expect { GitReflow.workflow.vroom }.to have_output "Vroom\nVrooom\nVROOOOM"
179
+ end
180
+ end
181
+
182
+ describe ".command" do
183
+ it "creates a class method for a bogus command" do
184
+ workflow.command :bogus do
185
+ GitReflow.say "Woohoo"
186
+ end
187
+
188
+ expect { DummyWorkflow.bogus }.to have_said("Woohoo")
189
+ end
190
+
191
+ it "creates a method for a bogus command with arguments" do
192
+ workflow.command :bogus, arguments: { feature_branch: nil } do |**params|
193
+ GitReflow.say "Woohoo #{params[:feature_branch]}!"
194
+ end
195
+
196
+ expect { DummyWorkflow.bogus(feature_branch: "arguments") }.to have_said("Woohoo arguments!")
197
+ end
198
+
199
+ it "creates a class method for a bogus command with default arguments" do
200
+ workflow.command :bogus, arguments: { feature_branch: nil, decoration: "sprinkles" } do |**params|
201
+ donut_excitement = "Woohoo #{params[:feature_branch]}"
202
+ donut_excitement += " with #{params[:decoration]}" if params[:decoration]
203
+ GitReflow.say "#{donut_excitement}!"
204
+ end
205
+
206
+ expect { DummyWorkflow.bogus(feature_branch: "donuts") }.to have_said("Woohoo donuts with sprinkles!")
207
+ end
208
+
209
+ it "creates a class method for a bogus command with flags" do
210
+ workflow.command :bogus, flags: { feature_branch: nil } do |**params|
211
+ GitReflow.say "Woohoo #{params[:feature_branch]}!"
212
+ end
213
+
214
+ expect { DummyWorkflow.bogus(feature_branch: "flags") }.to have_said("Woohoo flags!")
215
+ end
216
+
217
+ it "creates a class method for a bogus command with default flags" do
218
+ workflow.command :bogus, flags: { feature_branch: "donuts" } do |**params|
219
+ GitReflow.say "Woohoo #{params[:feature_branch]}!"
220
+ end
221
+
222
+ expect { DummyWorkflow.bogus }.to have_said("Woohoo donuts!")
223
+ end
224
+
225
+ it "creates a class method for a bogus command with switches" do
226
+ workflow.command :bogus, switches: { feature_branch: nil } do |**params|
227
+ GitReflow.say "Woohoo #{params[:feature_branch]}!"
228
+ end
229
+
230
+ expect { DummyWorkflow.bogus(feature_branch: "switches") }.to have_said("Woohoo switches!")
231
+ end
232
+
233
+ it "creates a class method for a bogus command with default switches" do
234
+ workflow.command :bogus, switches: { feature_branch: "donuts" } do |**params|
235
+ GitReflow.say "Woohoo #{params[:feature_branch]}!"
236
+ end
237
+
238
+ expect { DummyWorkflow.bogus }.to have_said("Woohoo donuts!")
239
+ end
240
+ end
241
+
242
+ describe ".use(workflow_name)" do
243
+ it "Uses a pre-existing workflow as a basis" do
244
+ allow(GitReflow::Workflows::Core).to receive(:load_workflow)
245
+ expect(GitReflow::Workflows::Core).to receive(:load_workflow)
246
+ .with(workflow.workflows["FlatMergeWorkflow"])
247
+ .and_return(true)
248
+ workflow.use "FlatMergeWorkflow"
249
+ end
250
+ end
251
+
252
+ describe ".use_gem(name, *ags)" do
253
+ let(:mock_bundler) { DummyBundler.new }
254
+
255
+ before do
256
+ allow(DummyGemifiedWorkflow).to receive(:gemfile) do |&block|
257
+ mock_bundler.gemfile(&block)
258
+ end
259
+ stub_run_for(DummyGemifiedWorkflow)
260
+ end
261
+
262
+ it "Installs a gem using Bundler's inline gemfile" do
263
+ stub_command(command: "gem list -ie whirly", options: { loud: false, raise: true }, return_value: "false")
264
+ expect(mock_bundler).to receive(:source).with("https://rubygems.org")
265
+ expect(mock_bundler).to receive(:gem).with("whirly", "0.2.6")
266
+
267
+ DummyGemifiedWorkflow.class_eval do
268
+ use_gem "whirly", "0.2.6"
269
+ end
270
+ end
271
+
272
+ it "Uses an existing gem if it's already installed" do
273
+ stub_command(command: "gem list -ie whirly", options: { loud: false, raise: false }, return_value: "true")
274
+ expect(DummyGemifiedWorkflow).to_not receive(:gemfile)
275
+
276
+ DummyGemifiedWorkflow.class_eval do
277
+ use_gem "whirly", "0.2.6"
278
+ end
279
+ end
280
+ end
281
+
282
+ describe ".use_gemfile(&block)" do
283
+ let(:mock_bundler) { DummyBundler.new }
284
+
285
+ before do
286
+ allow(DummyGemifiedWorkflow).to receive(:gemfile) do |&block|
287
+ mock_bundler.gemfile(&block)
288
+ end
289
+ stub_run_for(DummyGemifiedWorkflow)
290
+ end
291
+
292
+ it "runs bundler's inline gemfile with the provided block" do
293
+ expect(mock_bundler).to receive(:source).with("https://rubygems.org")
294
+ expect(mock_bundler).to receive(:gem).with("standard")
295
+
296
+ DummyGemifiedWorkflow.class_eval do
297
+ use_gemfile do
298
+ source "https://rubygems.org"
299
+ gem "standard"
300
+ end
301
+ end
302
+ end
303
+ end
304
+ end
@@ -5,14 +5,51 @@ describe GitReflow::Workflows::Core do
5
5
  let(:existing_pull_requests) { Fixture.new('pull_requests/pull_requests.json').to_json_hashie }
6
6
  let(:existing_gh_pull_request) { GitReflow::GitServer::GitHub::PullRequest.new existing_pull_requests.first }
7
7
  let(:pull_request_message_file) { "#{GitReflow.git_root_dir}/.git/GIT_REFLOW_PR_MSG" }
8
+ let(:workflow) { described_class }
8
9
 
9
10
  before do
10
- allow(GitReflow).to receive(:current_branch).and_return(feature_branch)
11
+ allow(workflow).to receive(:current_branch).and_return(feature_branch)
11
12
  allow_any_instance_of(HighLine).to receive(:choose)
12
13
  end
13
14
 
15
+ describe ".load_workflow(workflow_path)" do
16
+ let(:workflow_path) { "/tmp/Workflow" }
17
+ subject { GitReflow::Workflows::Core.load_workflow(workflow_path) }
18
+
19
+ before { allow(GitReflow::Workflows::Core).to receive(:load_workflow).and_call_original }
20
+
21
+ it "returns `nil` if the workflow path doesn't exist" do
22
+ allow(File).to receive(:exists?).and_return(false)
23
+ expect(subject).to be_nil
24
+ end
25
+
26
+ it "evaluates the workflow file in the context of the class" do
27
+ workflow_content = "# testing"
28
+ allow(File).to receive(:exists?).with("#{GitReflow.git_root_dir}/Workflow").and_return(false)
29
+ allow(File).to receive(:exists?).with(workflow_path).and_return(true)
30
+ expect(File).to receive(:read).with(workflow_path).and_return(workflow_content)
31
+ expect(GitReflow::Workflows::Core).to receive(:load_raw_workflow).with(workflow_content)
32
+ subject
33
+ end
34
+ end
35
+
36
+ describe ".load_raw_workflow(workflow_string)" do
37
+ before { allow(GitReflow::Workflows::Core).to receive(:load_workflow).and_call_original }
38
+ it "evaluates the raw string in the context of the Core workflow" do
39
+ workflow_content = <<~WORKFLOW_CONTENT
40
+ command :dummy do
41
+ puts "Dummy"
42
+ end
43
+ WORKFLOW_CONTENT
44
+ fake_binding = instance_double(Binding)
45
+ expect(fake_binding).to receive(:eval).with(workflow_content)
46
+ expect(described_class).to receive(:binding).and_return(fake_binding)
47
+ GitReflow::Workflows::Core.load_raw_workflow(workflow_content)
48
+ end
49
+ end
50
+
14
51
  describe ".setup" do
15
- subject { GitReflow::Workflows::Core.setup }
52
+ subject { workflow.setup }
16
53
 
17
54
  before do
18
55
  allow(File).to receive(:exist?).and_return(false)
@@ -27,7 +64,8 @@ describe GitReflow::Workflows::Core do
27
64
  context "core.editor git config has already been set" do
28
65
  before do
29
66
  allow(GitReflow::Config).to receive(:get) { "" }
30
- allow(GitReflow::Config).to receive(:get).with('core.editor').and_return('emacs')
67
+ allow(workflow.git_config).to receive(:get) { "" }
68
+ allow(workflow.git_config).to receive(:get).with('core.editor').and_return('emacs')
31
69
  end
32
70
 
33
71
  specify { expect { subject }.to_not have_run_command_silently "git config -f #{GitReflow::Config::CONFIG_FILE_PATH} --replace-all core.editor \"#{GitReflow.default_editor}\"", blocking: false }
@@ -36,8 +74,7 @@ describe GitReflow::Workflows::Core do
36
74
  context "git-reflow has not been setup before" do
37
75
  it "notifies the user of global setup" do
38
76
  expect { subject }.to have_said "We'll walk you through setting up git-reflow's defaults for all your projects.", :notice
39
- expect { subject }.to have_said "In the future, you can run \`git-reflow setup\` from the root of any project you want to setup differently.", :notice
40
- expect { subject }.to have_said "To adjust these settings globally, you can run \`git-reflow setup --global\`.", :notice
77
+ expect { subject }.to have_said "In the future, you can run \`git-reflow setup --local\` from the root of any project you want to setup differently.", :notice
41
78
  end
42
79
 
43
80
  it "creates a .gitconfig.reflow file and includes it in the user's global git config" do
@@ -84,9 +121,9 @@ describe GitReflow::Workflows::Core do
84
121
 
85
122
  describe ".start" do
86
123
  let(:feature_branch) { 'new_feature' }
87
- subject { GitReflow::Workflows::Core.start feature_branch: feature_branch }
124
+ subject { workflow.start feature_branch: feature_branch }
88
125
 
89
- it "updates the local repo and starts creates a new branch" do
126
+ it "updates the local repo and creates a new branch" do
90
127
  expect { subject }.to have_run_commands_in_order [
91
128
  "git checkout master",
92
129
  "git pull origin master",
@@ -108,13 +145,23 @@ describe GitReflow::Workflows::Core do
108
145
  end
109
146
 
110
147
  it "starts from a different base branch when one is supplied" do
111
- expect { GitReflow::Workflows::Core.start feature_branch: feature_branch, base: 'development' }.to have_run_commands_in_order [
148
+ expect { workflow.start feature_branch: feature_branch, base: 'development' }.to have_run_commands_in_order [
112
149
  "git checkout development",
113
150
  "git pull origin development",
114
151
  "git push origin development:refs/heads/#{feature_branch}",
115
152
  "git checkout --track -b #{feature_branch} origin/#{feature_branch}"
116
153
  ]
117
154
  end
155
+
156
+ it "starts from a different base branch when one is configured" do
157
+ allow(GitReflow::Config).to receive(:get).with("reflow.base-branch").and_return("sudo-master")
158
+ expect { workflow.start feature_branch: feature_branch }.to have_run_commands_in_order [
159
+ "git checkout sudo-master",
160
+ "git pull origin sudo-master",
161
+ "git push origin sudo-master:refs/heads/#{feature_branch}",
162
+ "git checkout --track -b #{feature_branch} origin/#{feature_branch}"
163
+ ]
164
+ end
118
165
  end
119
166
 
120
167
  describe ".review" do
@@ -125,11 +172,11 @@ describe GitReflow::Workflows::Core do
125
172
  let(:inputs) { {} }
126
173
 
127
174
  before do
128
- allow(GitReflow).to receive(:remote_user).and_return(user)
175
+ allow(workflow).to receive(:remote_user).and_return(user)
129
176
  allow(GitReflow).to receive(:git_server).and_return(GitReflow::GitServer)
130
- allow(GitReflow.git_server).to receive(:get_build_status).and_return(Struct.new(:state, :description, :url, :target_url).new)
131
- allow(GitReflow.git_server).to receive(:find_open_pull_request).and_return(nil)
132
- allow(GitReflow.git_server).to receive(:create_pull_request).and_return(existing_gh_pull_request)
177
+ allow(workflow.git_server).to receive(:get_build_status).and_return(Struct.new(:state, :description, :url, :target_url).new)
178
+ allow(workflow.git_server).to receive(:find_open_pull_request).and_return(nil)
179
+ allow(workflow.git_server).to receive(:create_pull_request).and_return(existing_gh_pull_request)
133
180
  allow(File).to receive(:open).with(pull_request_message_file, 'w')
134
181
  allow(File).to receive(:read).with(pull_request_message_file).and_return("bingo")
135
182
  allow(File).to receive(:delete)
@@ -139,7 +186,7 @@ describe GitReflow::Workflows::Core do
139
186
  })
140
187
  end
141
188
 
142
- subject { GitReflow::Workflows::Core.review inputs }
189
+ subject { workflow.review inputs }
143
190
 
144
191
  it "fetches updates to the base branch" do
145
192
  expect { subject }.to have_run_command "git fetch origin master"
@@ -152,7 +199,7 @@ describe GitReflow::Workflows::Core do
152
199
  it "uses the current branch name as the text for the PR" do
153
200
  fake_file = double
154
201
  expect(File).to receive(:open).with(pull_request_message_file, "w").and_yield(fake_file)
155
- expect(fake_file).to receive(:write).with(GitReflow.current_branch)
202
+ expect(fake_file).to receive(:write).with(workflow.current_branch)
156
203
  subject
157
204
  end
158
205
 
@@ -176,7 +223,7 @@ describe GitReflow::Workflows::Core do
176
223
  context "and a PR template exists" do
177
224
  let(:template_content) { "hey now" }
178
225
  before do
179
- allow(GitReflow).to receive(:pull_request_template).and_return(template_content)
226
+ allow(workflow).to receive(:pull_request_template).and_return(template_content)
180
227
  end
181
228
 
182
229
  it "uses the template's content for the PR" do
@@ -185,7 +232,6 @@ describe GitReflow::Workflows::Core do
185
232
  expect(fake_file).to receive(:write).with(template_content)
186
233
  subject
187
234
  end
188
-
189
235
  end
190
236
 
191
237
  context "providing a base branch" do
@@ -198,7 +244,7 @@ describe GitReflow::Workflows::Core do
198
244
  end
199
245
 
200
246
  it "creates a pull request using the custom base branch" do
201
- expect(GitReflow.git_server).to receive(:create_pull_request).with({
247
+ expect(workflow.git_server).to receive(:create_pull_request).with({
202
248
  title: 'bingo',
203
249
  body: "\n",
204
250
  head: "#{user}:#{feature_branch}",
@@ -208,6 +254,25 @@ describe GitReflow::Workflows::Core do
208
254
  end
209
255
  end
210
256
 
257
+ context 'when a base branch is configured' do
258
+ before do
259
+ stub_command_line_inputs('Submit pull request? (Y)' => 'yes')
260
+ allow(GitReflow::Config).to receive(:get).and_call_original
261
+ allow(GitReflow::Config).to receive(:get).with('reflow.base-branch').and_return('racecar')
262
+ inputs.delete(:base)
263
+ end
264
+
265
+ it 'creates a pull request using the custom base branch' do
266
+ expect(GitReflow.git_server).to receive(:create_pull_request).with({
267
+ title: 'bingo',
268
+ body: "\n",
269
+ head: "#{user}:#{feature_branch}",
270
+ base: 'racecar'
271
+ })
272
+ subject
273
+ end
274
+ end
275
+
211
276
  context "providing only a title" do
212
277
  let(:inputs) {{ title: "Amazing new feature" }}
213
278
 
@@ -218,7 +283,7 @@ describe GitReflow::Workflows::Core do
218
283
  end
219
284
 
220
285
  it "creates a pull request with only the given title" do
221
- expect(GitReflow.git_server).to receive(:create_pull_request).with({
286
+ expect(workflow.git_server).to receive(:create_pull_request).with({
222
287
  title: inputs[:title],
223
288
  body: nil,
224
289
  head: "#{user}:#{feature_branch}",
@@ -236,7 +301,7 @@ describe GitReflow::Workflows::Core do
236
301
  end
237
302
 
238
303
  context "providing only a body" do
239
- let(:inputs) {{ body: "Please pull this in!" }}
304
+ let(:inputs) {{ message: "Please pull this in!" }}
240
305
 
241
306
  before do
242
307
  stub_command_line_inputs({
@@ -245,9 +310,9 @@ describe GitReflow::Workflows::Core do
245
310
  end
246
311
 
247
312
  it "creates a pull request with the body as both title and body" do
248
- expect(GitReflow.git_server).to receive(:create_pull_request).with({
249
- title: inputs[:body],
250
- body: inputs[:body],
313
+ expect(workflow.git_server).to receive(:create_pull_request).with({
314
+ title: inputs[:message],
315
+ body: inputs[:message],
251
316
  head: "#{user}:#{feature_branch}",
252
317
  base: 'master'
253
318
  })
@@ -256,7 +321,7 @@ describe GitReflow::Workflows::Core do
256
321
  end
257
322
 
258
323
  context "providing both title and body" do
259
- let(:inputs) {{ title: "Amazing new feature", body: "Please pull this in!" }}
324
+ let(:inputs) {{ title: "Amazing new feature", message: "Please pull this in!" }}
260
325
 
261
326
  before do
262
327
  stub_command_line_inputs({
@@ -265,9 +330,9 @@ describe GitReflow::Workflows::Core do
265
330
  end
266
331
 
267
332
  it "creates a pull request with only the given title" do
268
- expect(GitReflow.git_server).to receive(:create_pull_request).with({
333
+ expect(workflow.git_server).to receive(:create_pull_request).with({
269
334
  title: inputs[:title],
270
- body: inputs[:body],
335
+ body: inputs[:message],
271
336
  head: "#{user}:#{feature_branch}",
272
337
  base: 'master'
273
338
  })
@@ -277,7 +342,7 @@ describe GitReflow::Workflows::Core do
277
342
 
278
343
  context "with existing pull request" do
279
344
  before do
280
- expect(GitReflow.git_server).to receive(:find_open_pull_request).and_return(existing_gh_pull_request)
345
+ expect(workflow.git_server).to receive(:find_open_pull_request).and_return(existing_gh_pull_request)
281
346
  allow(existing_gh_pull_request).to receive(:display_pull_request_summary)
282
347
  end
283
348
 
@@ -297,7 +362,7 @@ describe GitReflow::Workflows::Core do
297
362
  end
298
363
 
299
364
  it "creates a pull request" do
300
- expect(GitReflow.git_server).to receive(:create_pull_request).with({
365
+ expect(workflow.git_server).to receive(:create_pull_request).with({
301
366
  title: 'bingo',
302
367
  body: "\n",
303
368
  head: "#{user}:#{feature_branch}",
@@ -307,9 +372,27 @@ describe GitReflow::Workflows::Core do
307
372
  end
308
373
 
309
374
  it "notifies the user that the pull request was created" do
310
- expect(GitReflow.git_server).to receive(:create_pull_request).and_return(existing_gh_pull_request)
375
+ expect(workflow.git_server).to receive(:create_pull_request).and_return(existing_gh_pull_request)
311
376
  expect{ subject }.to have_said "Successfully created pull request ##{existing_gh_pull_request.number}: #{existing_gh_pull_request.title}\nPull Request URL: #{existing_gh_pull_request.html_url}\n", :success
312
377
  end
378
+
379
+ context "when pull request creation fails" do
380
+ let(:github_error) { Github::Error::UnprocessableEntity.new(eval(Fixture.new('pull_requests/pull_request_branch_nonexistent_error.json').to_s)) }
381
+
382
+ it "retries creating a pull request" do
383
+ call_count = 0
384
+ allow(workflow.git_server).to receive(:create_pull_request) do
385
+ call_count += 1
386
+ (call_count <= 1) ? raise(github_error) : existing_gh_pull_request
387
+ end
388
+ expect{ subject }.to have_said "Successfully created pull request ##{existing_gh_pull_request.number}: #{existing_gh_pull_request.title}\nPull Request URL: #{existing_gh_pull_request.html_url}\n", :success
389
+ end
390
+
391
+ it "reports failures even after retrying" do
392
+ allow(workflow.git_server).to receive(:create_pull_request).and_raise github_error
393
+ expect { subject }.to have_said "Github Error: #{github_error.to_s}", :error
394
+ end
395
+ end
313
396
  end
314
397
 
315
398
  context "aborting during PR template review" do
@@ -320,7 +403,7 @@ describe GitReflow::Workflows::Core do
320
403
  end
321
404
 
322
405
  it "does not create a pull request" do
323
- expect(GitReflow.git_server).to_not receive(:create_pull_request)
406
+ expect(workflow.git_server).to_not receive(:create_pull_request)
324
407
  subject
325
408
  end
326
409
 
@@ -334,17 +417,17 @@ describe GitReflow::Workflows::Core do
334
417
  let(:feature_branch) { 'new-feature' }
335
418
  let(:destination_branch) { nil }
336
419
 
337
- subject { GitReflow::Workflows::Core.status destination_branch: destination_branch }
420
+ subject { workflow.status destination_branch: destination_branch }
338
421
 
339
422
  before do
340
423
  allow(GitReflow).to receive(:git_server).and_return(GitReflow::GitServer)
341
- allow(GitReflow.git_server).to receive(:get_build_status).and_return(Struct.new(:state, :description, :url, :target_url).new)
424
+ allow(workflow.git_server).to receive(:get_build_status).and_return(Struct.new(:state, :description, :url, :target_url).new)
342
425
  allow(GitReflow).to receive(:current_branch).and_return(feature_branch)
343
426
  allow(existing_gh_pull_request).to receive(:display_pull_request_summary)
344
427
  end
345
428
 
346
429
  context "with no existing pull request" do
347
- before { allow(GitReflow.git_server).to receive(:find_open_pull_request).with({from: feature_branch, to: 'master'}).and_return(nil) }
430
+ before { allow(workflow.git_server).to receive(:find_open_pull_request).with({from: feature_branch, to: 'master'}).and_return(nil) }
348
431
  it { expect{ subject }.to have_said "No pull request exists for #{feature_branch} -> master", :notice }
349
432
  it { expect{ subject }.to have_said "Run 'git reflow review master' to start the review process", :notice }
350
433
  end
@@ -352,7 +435,7 @@ describe GitReflow::Workflows::Core do
352
435
  context "with an existing pull request" do
353
436
  let(:destination_branch) { 'master' }
354
437
  before do
355
- allow(GitReflow.git_server).to receive(:find_open_pull_request).and_return(existing_gh_pull_request)
438
+ allow(workflow.git_server).to receive(:find_open_pull_request).and_return(existing_gh_pull_request)
356
439
  end
357
440
 
358
441
  it "displays a summary of the pull request" do
@@ -364,7 +447,19 @@ describe GitReflow::Workflows::Core do
364
447
  let(:destination_branch) { 'develop' }
365
448
 
366
449
  it "uses the custom destination branch to lookup the pull request" do
367
- expect(GitReflow.git_server).to receive(:find_open_pull_request).with({from: feature_branch, to: destination_branch}).and_return(existing_gh_pull_request)
450
+ expect(workflow.git_server).to receive(:find_open_pull_request).with({from: feature_branch, to: destination_branch}).and_return(existing_gh_pull_request)
451
+ subject
452
+ end
453
+ end
454
+
455
+ context "when custom base-branch is configured" do
456
+ before do
457
+ allow(GitReflow::Config).to receive(:get).and_call_original
458
+ allow(GitReflow::Config).to receive(:get).with('reflow.base-branch').and_return('racecar')
459
+ end
460
+ subject { workflow.status }
461
+ it "uses the custom configured base-branch to lookup the pull request" do
462
+ expect(GitReflow.git_server).to receive(:find_open_pull_request).with({from: feature_branch, to: 'racecar'}).and_return(existing_gh_pull_request)
368
463
  subject
369
464
  end
370
465
  end
@@ -374,7 +469,7 @@ describe GitReflow::Workflows::Core do
374
469
  describe ".deploy" do
375
470
  let(:deploy_command) { "bundle exec cap #{destination} deploy" }
376
471
  let(:destination) { nil }
377
- subject { GitReflow::Workflows::Core.deploy(destination_server: destination) }
472
+ subject { workflow.deploy(destination_server: destination) }
378
473
 
379
474
  before do
380
475
  stub_command_line_inputs({
@@ -409,16 +504,16 @@ describe GitReflow::Workflows::Core do
409
504
  describe ".stage" do
410
505
  let(:feature_branch) { 'new-feature' }
411
506
 
412
- subject { GitReflow::Workflows::Core.stage }
507
+ subject { workflow.stage }
413
508
 
414
509
  before do
415
- allow(GitReflow).to receive(:current_branch).and_return(feature_branch)
416
- allow(GitReflow::Config).to receive(:get).and_call_original
510
+ allow(workflow).to receive(:current_branch).and_return(feature_branch)
511
+ allow(workflow.git_config).to receive(:get).and_call_original
417
512
  allow(GitReflow::Workflows::Core).to receive(:deploy)
418
513
  end
419
514
 
420
515
  it "checks out and updates the staging branch" do
421
- expect(GitReflow::Config).to receive(:get).with('reflow.staging-branch', local: true).and_return('staging')
516
+ expect(workflow.git_config).to receive(:get).with('reflow.staging-branch', local: true).and_return('staging')
422
517
  expect { subject }.to have_run_commands_in_order([
423
518
  "git checkout staging",
424
519
  "git pull origin staging",
@@ -429,9 +524,9 @@ describe GitReflow::Workflows::Core do
429
524
 
430
525
  context "merge is not successful" do
431
526
  before do
432
- allow(GitReflow::Config).to receive(:get).with('reflow.staging-branch', local: true).and_return('staging')
433
- allow(GitReflow).to receive(:run_command_with_label).and_call_original
434
- expect(GitReflow).to receive(:run_command_with_label).with("git merge #{feature_branch}", with_system: true).and_return(false)
527
+ allow(workflow.git_config).to receive(:get).with('reflow.staging-branch', local: true).and_return('staging')
528
+ allow(workflow).to receive(:run_command_with_label).and_call_original
529
+ expect(workflow).to receive(:run_command_with_label).with("git merge #{feature_branch}", with_system: true).and_return(false)
435
530
  end
436
531
 
437
532
  it "notifies the user of unsuccessful merge" do
@@ -450,9 +545,9 @@ describe GitReflow::Workflows::Core do
450
545
 
451
546
  context "merge is successful" do
452
547
  before do
453
- allow(GitReflow::Config).to receive(:get).with('reflow.staging-branch', local: true).and_return('staging')
454
- allow(GitReflow).to receive(:run_command_with_label).and_call_original
455
- expect(GitReflow).to receive(:run_command_with_label).with("git merge #{feature_branch}", with_system: true).and_return(true).and_call_original
548
+ allow(workflow.git_config).to receive(:get).with('reflow.staging-branch', local: true).and_return('staging')
549
+ allow(workflow).to receive(:run_command_with_label).and_call_original
550
+ expect(workflow).to receive(:run_command_with_label).with("git merge #{feature_branch}", with_system: true).and_return(true).and_call_original
456
551
  end
457
552
 
458
553
  specify { expect{ subject }.to have_run_command "git push origin staging" }
@@ -470,19 +565,19 @@ describe GitReflow::Workflows::Core do
470
565
 
471
566
  context "no staging branch has been setup" do
472
567
  before do
473
- allow(GitReflow::Config).to receive(:get).with('reflow.staging-branch', local: true).and_return('')
568
+ allow(workflow.git_config).to receive(:get).with('reflow.staging-branch', local: true).and_return('')
474
569
  stub_command_line_inputs({
475
570
  "What's the name of your staging branch? (default: 'staging') " => "bobby"
476
571
  })
477
572
  end
478
573
 
479
574
  it "sets the reflow.staging-branch git config to 'staging'" do
480
- expect(GitReflow::Config).to receive(:set).with("reflow.staging-branch", "bobby", local: true)
575
+ expect(workflow.git_config).to receive(:set).with("reflow.staging-branch", "bobby", local: true)
481
576
  subject
482
577
  end
483
578
 
484
579
  it "checks out and updates the staging branch" do
485
- allow(GitReflow::Config).to receive(:set).with("reflow.staging-branch", "bobby", local: true)
580
+ allow(workflow.git_config).to receive(:set).with("reflow.staging-branch", "bobby", local: true)
486
581
  expect { subject }.to have_run_commands_in_order([
487
582
  "git checkout bobby",
488
583
  "git pull origin bobby",
@@ -519,23 +614,25 @@ describe GitReflow::Workflows::Core do
519
614
  let(:user) { 'reenhanced' }
520
615
  let(:repo) { 'repo' }
521
616
 
522
- subject { GitReflow::Workflows::Core.deliver }
617
+ subject { workflow.deliver }
523
618
 
524
619
  before do
525
620
  allow(GitReflow).to receive(:git_server).and_return(GitReflow::GitServer)
526
621
  allow(GitReflow).to receive(:remote_user).and_return(user)
622
+ allow(workflow).to receive(:remote_user).and_return(user)
527
623
  allow(GitReflow).to receive(:current_branch).and_return(feature_branch)
528
- allow(GitReflow.git_server).to receive(:get_build_status).and_return(Struct.new(:state, :description, :url, :target_url).new)
624
+ allow(workflow).to receive(:current_branch).and_return(feature_branch)
625
+ allow(workflow.git_server).to receive(:get_build_status).and_return(Struct.new(:state, :description, :url, :target_url).new)
529
626
  end
530
627
 
531
628
  context "pull request does not exist" do
532
- before { allow(GitReflow.git_server).to receive(:find_open_pull_request).with( from: feature_branch, to: 'master').and_return(nil) }
629
+ before { allow(workflow.git_server).to receive(:find_open_pull_request).with( from: feature_branch, to: 'master').and_return(nil) }
533
630
  specify { expect{ subject }.to have_said "No pull request exists for #{user}:#{feature_branch}\nPlease submit your branch for review first with \`git reflow review\`", :deliver_halted }
534
631
  end
535
632
 
536
633
  context "pull request exists" do
537
634
  before do
538
- allow(GitReflow.git_server).to receive(:find_open_pull_request).with( from: feature_branch, to: 'master').and_return(existing_gh_pull_request)
635
+ allow(workflow.git_server).to receive(:find_open_pull_request).with( from: feature_branch, to: 'master').and_return(existing_gh_pull_request)
539
636
  allow(GitReflow::Workflows::Core).to receive(:status)
540
637
  end
541
638
 
@@ -586,11 +683,16 @@ describe GitReflow::Workflows::Core do
586
683
  end
587
684
 
588
685
  context "but forcing the deliver" do
589
- subject { GitReflow::Workflows::Core.deliver force: true }
686
+ subject { workflow.deliver force: true }
590
687
 
591
688
  before do
592
689
  allow(existing_gh_pull_request).to receive(:good_to_merge?).with(force: true).and_return(true)
593
- allow(existing_gh_pull_request).to receive(:merge!).with(force: true, base: 'master', skip_lgtm: true)
690
+ allow(existing_gh_pull_request).to receive(:merge!).with(
691
+ force: true,
692
+ merge_method: "squash",
693
+ base: 'master',
694
+ skip_lgtm: false
695
+ )
594
696
  end
595
697
 
596
698
  it "displays the status of the PR" do
@@ -599,28 +701,74 @@ describe GitReflow::Workflows::Core do
599
701
  end
600
702
 
601
703
  it "merges the feature branch anyway" do
602
- expect(existing_gh_pull_request).to receive(:merge!).with(force: true, base: 'master', skip_lgtm: true)
704
+ expect(existing_gh_pull_request).to receive(:merge!).with(
705
+ force: true,
706
+ merge_method: "squash",
707
+ base: 'master',
708
+ skip_lgtm: false
709
+ )
603
710
  subject
604
711
  end
605
712
  end
606
713
  end
607
714
 
608
715
  context "and using a custom base branch" do
609
- subject { GitReflow::Workflows::Core.deliver base: 'development' }
716
+ subject { workflow.deliver base: 'development' }
610
717
  before do
611
- expect(GitReflow.git_server).to receive(:find_open_pull_request).with( from: feature_branch, to: 'development').and_return(existing_gh_pull_request)
718
+ expect(workflow.git_server).to receive(:find_open_pull_request).with( from: feature_branch, to: 'development').and_return(existing_gh_pull_request)
612
719
  allow(existing_gh_pull_request).to receive(:good_to_merge?).and_return(true)
613
720
  end
614
721
 
615
722
 
616
723
  it "displays the status of the PR" do
617
- allow(existing_gh_pull_request).to receive(:merge!).with(base: 'development')
724
+ allow(existing_gh_pull_request).to receive(:merge!).with(
725
+ base: 'development',
726
+ merge_method: "squash",
727
+ force: false,
728
+ skip_lgtm: false
729
+ )
618
730
  expect(GitReflow::Workflows::Core).to receive(:status).with(destination_branch: 'development')
619
731
  subject
620
732
  end
621
733
 
622
734
  it "merges the feature branch" do
623
- expect(existing_gh_pull_request).to receive(:merge!).with(base: 'development')
735
+ expect(existing_gh_pull_request).to receive(:merge!).with(
736
+ base: "development",
737
+ merge_method: "squash",
738
+ force: false,
739
+ skip_lgtm: false
740
+ )
741
+ subject
742
+ end
743
+ end
744
+
745
+ context "when a custom base-branch is configured" do
746
+ subject { workflow.deliver }
747
+ before do
748
+ expect(GitReflow.git_server).to receive(:find_open_pull_request).with( from: feature_branch, to: 'racecar').and_return(existing_gh_pull_request)
749
+ allow(existing_gh_pull_request).to receive(:good_to_merge?).and_return(true)
750
+ allow(GitReflow::Config).to receive(:get).with('reflow.base-branch').and_return('racecar')
751
+ end
752
+
753
+
754
+ it "displays the status of the PR" do
755
+ allow(existing_gh_pull_request).to receive(:merge!).with(
756
+ base: 'racecar',
757
+ merge_method: "squash",
758
+ force: false,
759
+ skip_lgtm: false
760
+ )
761
+ expect(GitReflow::Workflows::Core).to receive(:status).with(destination_branch: 'racecar')
762
+ subject
763
+ end
764
+
765
+ it "merges the feature branch" do
766
+ expect(existing_gh_pull_request).to receive(:merge!).with(
767
+ base: "racecar",
768
+ merge_method: "squash",
769
+ force: false,
770
+ skip_lgtm: false
771
+ )
624
772
  subject
625
773
  end
626
774
  end
@@ -628,36 +776,46 @@ describe GitReflow::Workflows::Core do
628
776
  end
629
777
 
630
778
  describe ".refresh" do
631
- subject { GitReflow::Workflows::Core.refresh }
779
+ subject { workflow.refresh }
632
780
 
633
781
  it "updates the feature branch with default remote repo and base branch" do
634
- expect(GitReflow).to receive(:update_feature_branch).with(remote: 'origin', base: 'master')
782
+ expect(workflow).to receive(:update_feature_branch).with(remote: 'origin', base: 'master')
635
783
  subject
636
784
  end
637
785
 
638
786
  context "providing a custom base branch" do
639
- subject { GitReflow::Workflows::Core.refresh base: 'development' }
787
+ subject { workflow.refresh base: 'development' }
640
788
 
641
789
  it "updates the feature branch with default remote repo and base branch" do
642
- expect(GitReflow).to receive(:update_feature_branch).with(remote: 'origin', base: 'development')
790
+ expect(workflow).to receive(:update_feature_branch).with(remote: 'origin', base: 'development')
791
+ subject
792
+ end
793
+ end
794
+
795
+ context "when a custom base branch is configured" do
796
+ before { allow(workflow.git_config).to receive(:get).with('reflow.base-branch').and_return('racecar') }
797
+ subject { workflow.refresh }
798
+
799
+ it "updates the feature branch with custom base branch" do
800
+ expect(workflow).to receive(:update_feature_branch).with(remote: 'origin', base: 'racecar')
643
801
  subject
644
802
  end
645
803
  end
646
804
 
647
805
  context "provding a custom remote repo" do
648
- subject { GitReflow::Workflows::Core.refresh remote: 'upstream' }
806
+ subject { workflow.refresh remote: 'upstream' }
649
807
 
650
808
  it "updates the feature branch with default remote repo and base branch" do
651
- expect(GitReflow).to receive(:update_feature_branch).with(remote: 'upstream', base: 'master')
809
+ expect(workflow).to receive(:update_feature_branch).with(remote: 'upstream', base: 'master')
652
810
  subject
653
811
  end
654
812
  end
655
813
 
656
814
  context "providing a custom base branch and remote repo" do
657
- subject { GitReflow::Workflows::Core.refresh remote: 'upstream', base: 'development' }
815
+ subject { workflow.refresh remote: 'upstream', base: 'development' }
658
816
 
659
817
  it "updates the feature branch with default remote repo and base branch" do
660
- expect(GitReflow).to receive(:update_feature_branch).with(remote: 'upstream', base: 'development')
818
+ expect(workflow).to receive(:update_feature_branch).with(remote: 'upstream', base: 'development')
661
819
  subject
662
820
  end
663
821
  end