git_helper 1.3.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +17 -13
  3. data/README.md +37 -44
  4. data/Rakefile +1 -37
  5. data/bin/git-helper +10 -28
  6. data/lib/git_helper.rb +3 -5
  7. data/lib/git_helper/change_remote.rb +53 -40
  8. data/lib/git_helper/checkout_default.rb +1 -1
  9. data/lib/git_helper/clean_branches.rb +1 -4
  10. data/lib/git_helper/code_request.rb +95 -0
  11. data/lib/git_helper/empty_commit.rb +1 -1
  12. data/lib/git_helper/forget_local_commits.rb +7 -0
  13. data/lib/git_helper/git_config_reader.rb +1 -1
  14. data/lib/git_helper/gitlab_client.rb +0 -1
  15. data/lib/git_helper/highline_cli.rb +21 -17
  16. data/lib/git_helper/local_code.rb +67 -19
  17. data/lib/git_helper/merge_request.rb +55 -73
  18. data/lib/git_helper/new_branch.rb +2 -13
  19. data/lib/git_helper/octokit_client.rb +0 -1
  20. data/lib/git_helper/pull_request.rb +44 -67
  21. data/lib/git_helper/version.rb +1 -1
  22. data/plugins.zip +0 -0
  23. data/spec/git_helper/change_remote_spec.rb +173 -0
  24. data/spec/git_helper/checkout_default_spec.rb +19 -0
  25. data/spec/git_helper/clean_branches_spec.rb +19 -0
  26. data/spec/git_helper/code_request_spec.rb +259 -0
  27. data/spec/git_helper/empty_commit_spec.rb +19 -0
  28. data/spec/git_helper/forget_local_commits_spec.rb +19 -0
  29. data/spec/git_helper/git_config_reader_spec.rb +60 -0
  30. data/spec/git_helper/gitlab_client_spec.rb +26 -0
  31. data/spec/git_helper/highline_cli_spec.rb +215 -0
  32. data/spec/git_helper/local_code_spec.rb +231 -0
  33. data/spec/git_helper/merge_request_spec.rb +234 -0
  34. data/spec/git_helper/new_branch_spec.rb +44 -0
  35. data/spec/git_helper/octokit_client_spec.rb +26 -0
  36. data/spec/git_helper/pull_request_spec.rb +246 -0
  37. data/spec/spec_helper.rb +0 -7
  38. metadata +41 -24
@@ -0,0 +1,234 @@
1
+ require 'spec_helper'
2
+ require 'git_helper'
3
+
4
+ describe GitHelper::GitLabMergeRequest do
5
+ let(:local_code) { double(:local_code, read_template: 'template') }
6
+ let(:highline_cli) { double(:highline_cli) }
7
+ let(:gitlab_client_client) { double(:gitlab_client_client, project: :project, merge_request: :merge_request, create_merge_request: :created) }
8
+ let(:gitlab_client) { double(:gitlab_client, client: gitlab_client_client) }
9
+ let(:options) do
10
+ {
11
+ local_project: 'emmasax4/git_helper',
12
+ local_branch: 'main',
13
+ local_code: local_code,
14
+ cli: highline_cli
15
+ }
16
+ end
17
+
18
+ subject { GitHelper::GitLabMergeRequest.new(options) }
19
+
20
+ before do
21
+ allow(GitHelper::GitLabClient).to receive(:new).and_return(gitlab_client)
22
+ end
23
+
24
+ describe '#create' do
25
+ it 'should call the gitlab client to create' do
26
+ allow(subject).to receive(:squash_merge_request).and_return(true)
27
+ allow(subject).to receive(:remove_source_branch).and_return(false)
28
+ allow(subject).to receive(:new_mr_body).and_return('')
29
+ expect(gitlab_client_client).to receive(:create_merge_request)
30
+ subject.create({base_branch: 'base', new_title: 'title'})
31
+ end
32
+
33
+ it 'should call various other methods' do
34
+ expect(subject).to receive(:squash_merge_request).and_return(true)
35
+ expect(subject).to receive(:remove_source_branch).and_return(false)
36
+ expect(subject).to receive(:new_mr_body).and_return('')
37
+ allow(gitlab_client_client).to receive(:create_merge_request)
38
+ subject.create({base_branch: 'base', new_title: 'title'})
39
+ end
40
+
41
+ it 'should catch the raised error if the creation does not work' do
42
+ allow(subject).to receive(:squash_merge_request).and_return(true)
43
+ allow(subject).to receive(:remove_source_branch).and_return(false)
44
+ allow(subject).to receive(:new_mr_body).and_return('')
45
+ allow(gitlab_client_client).to receive(:create_merge_request).and_raise(StandardError)
46
+ expect(subject.create({base_branch: 'base', new_title: 'title'})).to eq(nil)
47
+ end
48
+ end
49
+
50
+ describe '#merge' do
51
+ it 'should call the gitlab client to merge' do
52
+ allow(subject).to receive(:existing_mr).and_return(double(should_remove_source_branch: true, squash: false, title: 'title'))
53
+ allow(subject).to receive(:mr_id).and_return(123)
54
+ expect(gitlab_client_client).to receive(:accept_merge_request)
55
+ subject.merge
56
+ end
57
+
58
+ it 'should call various other methods' do
59
+ expect(subject).to receive(:existing_mr).and_return(double(should_remove_source_branch: true, squash: false, title: 'title')).at_least(:once)
60
+ expect(subject).to receive(:mr_id).and_return(123).at_least(:once)
61
+ allow(gitlab_client_client).to receive(:accept_merge_request)
62
+ subject.merge
63
+ end
64
+
65
+ it 'should catch the raised error if the merge does not work' do
66
+ allow(subject).to receive(:existing_mr).and_return(double(should_remove_source_branch: true, squash: false, title: 'title'))
67
+ allow(subject).to receive(:mr_id).and_return(123)
68
+ allow(gitlab_client_client).to receive(:accept_merge_request).and_raise(StandardError)
69
+ expect(subject.merge).to eq(nil)
70
+ end
71
+
72
+ it 'should try to merge multiple times if the first merge errors' do
73
+ allow(subject).to receive(:existing_mr).and_return(double(should_remove_source_branch: true, squash: false, title: 'title'))
74
+ allow(subject).to receive(:mr_id).and_return(123)
75
+ expect(gitlab_client_client).to receive(:accept_merge_request).and_return(double(merge_commit_sha: nil)).exactly(2).times
76
+ expect(subject.merge).to eq(nil)
77
+ end
78
+ end
79
+
80
+ describe '#new_mr_body' do
81
+ it 'should call the local code if the template to apply exists' do
82
+ allow(subject).to receive(:template_name_to_apply).and_return('')
83
+ expect(local_code).to receive(:read_template)
84
+ subject.send(:new_mr_body)
85
+ end
86
+
87
+ it 'should not call the local code if the template is nil' do
88
+ allow(subject).to receive(:template_name_to_apply).and_return(nil)
89
+ expect(local_code).not_to receive(:read_template)
90
+ subject.send(:new_mr_body)
91
+ end
92
+
93
+ it 'should return an empty string if the template is nil' do
94
+ allow(subject).to receive(:template_name_to_apply).and_return(nil)
95
+ expect(subject.send(:new_mr_body)).to eq('')
96
+ end
97
+ end
98
+
99
+ describe '#template_name_to_apply' do
100
+ context 'if MR template options are empty' do
101
+ it 'should return nil' do
102
+ allow(subject).to receive(:mr_template_options).and_return([])
103
+ expect(subject.send(:template_name_to_apply)).to eq(nil)
104
+ end
105
+ end
106
+
107
+ context 'if there is one template option' do
108
+ it 'should call the CLI to ask about a single template' do
109
+ allow(subject).to receive(:mr_template_options).and_return(['template1'])
110
+ expect(highline_cli).to receive(:apply_template?).and_return(true)
111
+ subject.send(:template_name_to_apply)
112
+ end
113
+
114
+ it 'should return the single template if the user says yes' do
115
+ allow(subject).to receive(:mr_template_options).and_return(['template1'])
116
+ allow(highline_cli).to receive(:apply_template?).and_return(true)
117
+ expect(subject.send(:template_name_to_apply)).to eq('template1')
118
+ end
119
+
120
+ it 'should return nil if the user says no' do
121
+ allow(subject).to receive(:mr_template_options).and_return(['template1'])
122
+ allow(highline_cli).to receive(:apply_template?).and_return(false)
123
+ expect(subject.send(:template_name_to_apply)).to eq(nil)
124
+ end
125
+ end
126
+
127
+ context 'if there are multiple template options' do
128
+ it 'should call the CLI to ask which of multiple templates to apply' do
129
+ allow(subject).to receive(:mr_template_options).and_return(['template1', 'template2'])
130
+ expect(highline_cli).to receive(:template_to_apply).and_return('template1')
131
+ subject.send(:template_name_to_apply)
132
+ end
133
+
134
+ it 'should return the answer template if the user says yes' do
135
+ allow(subject).to receive(:mr_template_options).and_return(['template1', 'template2'])
136
+ allow(highline_cli).to receive(:template_to_apply).and_return('template1')
137
+ expect(subject.send(:template_name_to_apply)).to eq('template1')
138
+ end
139
+
140
+ it 'should return nil if the user says no' do
141
+ allow(subject).to receive(:mr_template_options).and_return(['template1', 'template2'])
142
+ allow(highline_cli).to receive(:template_to_apply).and_return('None')
143
+ expect(subject.send(:template_name_to_apply)).to eq(nil)
144
+ end
145
+ end
146
+ end
147
+
148
+ describe '#mr_template_options' do
149
+ it 'should call the local code' do
150
+ expect(local_code).to receive(:template_options)
151
+ subject.send(:mr_template_options)
152
+ end
153
+ end
154
+
155
+ describe '#mr_id' do
156
+ it 'should ask the CLI for the code request ID' do
157
+ expect(highline_cli).to receive(:code_request_id).and_return(123)
158
+ subject.send(:mr_id)
159
+ end
160
+
161
+ it 'should equal an integer' do
162
+ expect(highline_cli).to receive(:code_request_id).and_return(123)
163
+ expect(subject.send(:mr_id)).to eq(123)
164
+ end
165
+ end
166
+
167
+ describe '#squash_merge_request' do
168
+ it 'should ask the CLI for the code request ID' do
169
+ expect(highline_cli).to receive(:squash_merge_request?).and_return(true)
170
+ subject.send(:squash_merge_request)
171
+ end
172
+
173
+ it 'should be a boolean' do
174
+ expect(highline_cli).to receive(:squash_merge_request?).and_return(false)
175
+ expect([true, false]).to include(subject.send(:squash_merge_request))
176
+ end
177
+ end
178
+
179
+ describe '#remove_source_branch' do
180
+ before do
181
+ allow(subject).to receive(:existing_project).and_return(double(remove_source_branch_after_merge: nil))
182
+ end
183
+
184
+ context 'when the existing project has no setting' do
185
+ it 'should ask the CLI for the code request ID' do
186
+ expect(highline_cli).to receive(:remove_source_branch?).and_return(true)
187
+ subject.send(:remove_source_branch)
188
+ end
189
+
190
+ it 'should be a boolean' do
191
+ allow(highline_cli).to receive(:remove_source_branch?).and_return(false)
192
+ expect([true, false]).to include(subject.send(:remove_source_branch))
193
+ end
194
+ end
195
+
196
+ it 'should ask the existing project' do
197
+ expect(subject).to receive(:existing_project).and_return(double(remove_source_branch_after_merge: true))
198
+ subject.send(:remove_source_branch)
199
+ end
200
+
201
+ it "should return the existing project's setting if it exists" do
202
+ allow(subject).to receive(:existing_project).and_return(double(remove_source_branch_after_merge: true))
203
+ expect(subject.send(:remove_source_branch)).to eq(true)
204
+ end
205
+
206
+ it "should return the existing project's setting if it exists" do
207
+ allow(subject).to receive(:existing_project).and_return(double(remove_source_branch_after_merge: false))
208
+ allow(highline_cli).to receive(:remove_source_branch?).and_return(true)
209
+ expect(subject.send(:remove_source_branch)).to eq(true)
210
+ end
211
+ end
212
+
213
+ describe '#existing_project' do
214
+ it 'should call the gitlab client' do
215
+ expect(gitlab_client_client).to receive(:project).and_return(:project)
216
+ subject.send(:existing_project)
217
+ end
218
+ end
219
+
220
+ describe '#existing_mr' do
221
+ it 'should call the gitlab client' do
222
+ allow(highline_cli).to receive(:code_request_id).and_return(123)
223
+ expect(gitlab_client_client).to receive(:merge_request).and_return(:merge_request)
224
+ subject.send(:existing_mr)
225
+ end
226
+ end
227
+
228
+ describe '#gitlab_client' do
229
+ it 'should call the gitlab client' do
230
+ expect(GitHelper::GitLabClient).to receive(:new).and_return(gitlab_client)
231
+ subject.send(:gitlab_client)
232
+ end
233
+ end
234
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+ require 'git_helper'
3
+
4
+ describe GitHelper::NewBranch do
5
+ let(:new_branch_name) { 'new-branch-name' }
6
+ let(:local_code) { double(:local_code, new_branch: :commit) }
7
+ let(:cli) { double(:highline_cli, new_branch_name: new_branch_name) }
8
+
9
+ subject { GitHelper::NewBranch.new }
10
+
11
+ before do
12
+ allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
13
+ allow(GitHelper::HighlineCli).to receive(:new).and_return(cli)
14
+ end
15
+
16
+ it 'should call GitHelper::LocalCode' do
17
+ expect(GitHelper::LocalCode).to receive(:new).and_return(local_code)
18
+ subject.execute
19
+ end
20
+
21
+ it 'should call the new_branch method from the local code class' do
22
+ expect(local_code).to receive(:new_branch)
23
+ subject.execute
24
+ end
25
+
26
+ context 'when no branch name is passed in' do
27
+ it 'should call the highline cli' do
28
+ expect(GitHelper::HighlineCli).to receive(:new).and_return(cli)
29
+ subject.execute
30
+ end
31
+
32
+ it 'should ask the highline cli what the new branch name should be' do
33
+ expect(cli).to receive(:new_branch_name)
34
+ subject.execute
35
+ end
36
+ end
37
+
38
+ context 'when there is a branch name passed in' do
39
+ it 'should not create a highline cli' do
40
+ expect(GitHelper::HighlineCli).not_to receive(:new)
41
+ subject.execute(new_branch_name)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ require 'git_helper'
3
+
4
+ describe GitHelper::OctokitClient do
5
+ let(:git_config_reader) { double(:git_config_reader, github_token: :token) }
6
+
7
+ subject { GitHelper::OctokitClient.new }
8
+
9
+ before do
10
+ allow(GitHelper::GitConfigReader).to receive(:new).and_return(git_config_reader)
11
+ end
12
+
13
+ describe '#client' do
14
+ it 'should call the GitLab client to make a new client' do
15
+ expect(Octokit::Client).to receive(:new)
16
+ subject.client
17
+ end
18
+ end
19
+
20
+ describe '#git_config_reader' do
21
+ it 'should make a new git config reader' do
22
+ expect(GitHelper::GitConfigReader).to receive(:new)
23
+ subject.send(:git_config_reader)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,246 @@
1
+ require 'spec_helper'
2
+ require 'git_helper'
3
+
4
+ describe GitHelper::GitHubPullRequest do
5
+ let(:local_code) { double(:local_code, read_template: 'template') }
6
+ let(:highline_cli) { double(:highline_cli) }
7
+ let(:octokit_client_client) { double(:octokit_client_client, project: :project, merge_request: :merge_request, create_merge_request: :created) }
8
+ let(:octokit_client) { double(:octokit_client, client: octokit_client_client) }
9
+ let(:options) do
10
+ {
11
+ local_project: 'emmasax4/git_helper',
12
+ local_branch: 'main',
13
+ local_code: local_code,
14
+ cli: highline_cli
15
+ }
16
+ end
17
+
18
+ subject { GitHelper::GitHubPullRequest.new(options) }
19
+
20
+ before do
21
+ allow(GitHelper::OctokitClient).to receive(:new).and_return(octokit_client)
22
+ end
23
+
24
+ describe '#create' do
25
+ it 'should call the octokit client to create' do
26
+ allow(subject).to receive(:new_pr_body).and_return('')
27
+ expect(octokit_client_client).to receive(:create_pull_request)
28
+ subject.create({base_branch: 'base', new_title: 'title'})
29
+ end
30
+
31
+ it 'should call various other methods' do
32
+ expect(subject).to receive(:new_pr_body).and_return('').at_least(:once)
33
+ allow(octokit_client_client).to receive(:create_pull_request)
34
+ subject.create({base_branch: 'base', new_title: 'title'})
35
+ end
36
+
37
+ it 'should catch the raised error if the creation does not work' do
38
+ allow(subject).to receive(:new_pr_body).and_return('')
39
+ allow(octokit_client_client).to receive(:create_pull_request).and_raise(StandardError)
40
+ expect(subject.create({base_branch: 'base', new_title: 'title'})).to eq(nil)
41
+ end
42
+ end
43
+
44
+ describe '#merge' do
45
+ it 'should call the octokit client to merge' do
46
+ allow(subject).to receive(:existing_pr).and_return(double(title: 'title'))
47
+ allow(subject).to receive(:merge_method).and_return('rebase')
48
+ allow(subject).to receive(:pr_id).and_return(123)
49
+ expect(octokit_client_client).to receive(:merge_pull_request)
50
+ subject.merge
51
+ end
52
+
53
+ it 'should call various other methods' do
54
+ expect(subject).to receive(:existing_pr).and_return(double(title: 'title')).at_least(:once)
55
+ expect(subject).to receive(:merge_method).and_return('rebase').at_least(:once)
56
+ expect(subject).to receive(:pr_id).and_return(123).at_least(:once)
57
+ allow(octokit_client_client).to receive(:merge_pull_request)
58
+ subject.merge
59
+ end
60
+
61
+ it 'should catch the raised error if the merge does not work' do
62
+ allow(subject).to receive(:existing_pr).and_return(double(title: 'title'))
63
+ allow(subject).to receive(:merge_method).and_return('rebase')
64
+ allow(subject).to receive(:pr_id).and_return(123)
65
+ allow(octokit_client_client).to receive(:merge_pull_request).and_raise(StandardError)
66
+ expect(subject.merge).to eq(nil)
67
+ end
68
+ end
69
+
70
+ describe '#new_pr_body' do
71
+ it 'should call the local code if the template to apply exists' do
72
+ allow(subject).to receive(:template_name_to_apply).and_return('')
73
+ expect(local_code).to receive(:read_template)
74
+ subject.send(:new_pr_body)
75
+ end
76
+
77
+ it 'should not call the local code if the template is nil' do
78
+ allow(subject).to receive(:template_name_to_apply).and_return(nil)
79
+ expect(local_code).not_to receive(:read_template)
80
+ subject.send(:new_pr_body)
81
+ end
82
+
83
+ it 'should return an empty string if the template is nil' do
84
+ allow(subject).to receive(:template_name_to_apply).and_return(nil)
85
+ expect(subject.send(:new_pr_body)).to eq('')
86
+ end
87
+ end
88
+
89
+ describe '#template_name_to_apply' do
90
+ context 'if PR template options are empty' do
91
+ it 'should return nil' do
92
+ allow(subject).to receive(:pr_template_options).and_return([])
93
+ expect(subject.send(:template_name_to_apply)).to eq(nil)
94
+ end
95
+ end
96
+
97
+ context 'if there is one template option' do
98
+ it 'should call the CLI to ask about a single template' do
99
+ allow(subject).to receive(:pr_template_options).and_return(['template1'])
100
+ expect(highline_cli).to receive(:apply_template?).and_return(true)
101
+ subject.send(:template_name_to_apply)
102
+ end
103
+
104
+ it 'should return the single template if the user says yes' do
105
+ allow(subject).to receive(:pr_template_options).and_return(['template1'])
106
+ allow(highline_cli).to receive(:apply_template?).and_return(true)
107
+ expect(subject.send(:template_name_to_apply)).to eq('template1')
108
+ end
109
+
110
+ it 'should return nil if the user says no' do
111
+ allow(subject).to receive(:pr_template_options).and_return(['template1'])
112
+ allow(highline_cli).to receive(:apply_template?).and_return(false)
113
+ expect(subject.send(:template_name_to_apply)).to eq(nil)
114
+ end
115
+ end
116
+
117
+ context 'if there are multiple template options' do
118
+ it 'should call the CLI to ask which of multiple templates to apply' do
119
+ allow(subject).to receive(:pr_template_options).and_return(['template1', 'template2'])
120
+ expect(highline_cli).to receive(:template_to_apply).and_return('template1')
121
+ subject.send(:template_name_to_apply)
122
+ end
123
+
124
+ it 'should return the answer template if the user says yes' do
125
+ allow(subject).to receive(:pr_template_options).and_return(['template1', 'template2'])
126
+ allow(highline_cli).to receive(:template_to_apply).and_return('template1')
127
+ expect(subject.send(:template_name_to_apply)).to eq('template1')
128
+ end
129
+
130
+ it 'should return nil if the user says no' do
131
+ allow(subject).to receive(:pr_template_options).and_return(['template1', 'template2'])
132
+ allow(highline_cli).to receive(:template_to_apply).and_return('None')
133
+ expect(subject.send(:template_name_to_apply)).to eq(nil)
134
+ end
135
+ end
136
+ end
137
+
138
+ describe '#pr_template_options' do
139
+ it 'should call the local code' do
140
+ expect(local_code).to receive(:template_options)
141
+ subject.send(:pr_template_options)
142
+ end
143
+ end
144
+
145
+ describe '#pr_id' do
146
+ it 'should ask the CLI for the code request ID' do
147
+ expect(highline_cli).to receive(:code_request_id).and_return(123)
148
+ subject.send(:pr_id)
149
+ end
150
+
151
+ it 'should equal an integer' do
152
+ expect(highline_cli).to receive(:code_request_id).and_return(123)
153
+ expect(subject.send(:pr_id)).to eq(123)
154
+ end
155
+ end
156
+
157
+ describe '#merge_method' do
158
+ let(:project) { double(:project, allow_merge_commit: true, allow_squash_merge: true, allow_rebase_merge: true) }
159
+
160
+ before do
161
+ allow(subject).to receive(:existing_project).and_return(project)
162
+ allow(highline_cli).to receive(:merge_method)
163
+ end
164
+
165
+ it 'should ask the CLI for the merge_method' do
166
+ expect(highline_cli).to receive(:merge_method).and_return('merge')
167
+ subject.send(:merge_method)
168
+ end
169
+
170
+ it 'should be a string' do
171
+ allow(highline_cli).to receive(:merge_method).and_return('merge')
172
+ expect(subject.send(:merge_method)).to be_a(String)
173
+ end
174
+
175
+ context "if there's only one item" do
176
+ let(:project) { double(:project, allow_merge_commit: true, allow_squash_merge: false, allow_rebase_merge: false) }
177
+
178
+ it 'should not ask the CLI anything' do
179
+ expect(highline_cli).not_to receive(:merge_method)
180
+ subject.send(:merge_method)
181
+ end
182
+ end
183
+ end
184
+
185
+ describe '#merge_options' do
186
+ let(:project) { double(:project, allow_merge_commit: true, allow_squash_merge: true, allow_rebase_merge: true) }
187
+
188
+ before do
189
+ allow(subject).to receive(:existing_project).and_return(project)
190
+ end
191
+
192
+ it 'should return an array' do
193
+ expect(subject.send(:merge_options)).to be_a(Array)
194
+ end
195
+
196
+ it 'should have three items' do
197
+ expect(subject.send(:merge_options).length).to eq(3)
198
+ end
199
+
200
+ context 'when two options are present' do
201
+ let(:project) { double(:project, allow_merge_commit: false, allow_squash_merge: true, allow_rebase_merge: true) }
202
+
203
+ it 'should have two items' do
204
+ expect(subject.send(:merge_options).length).to eq(2)
205
+ end
206
+ end
207
+
208
+ context 'when one option is present' do
209
+ let(:project) { double(:project, allow_merge_commit: false, allow_squash_merge: false, allow_rebase_merge: true) }
210
+
211
+ it 'should have one item' do
212
+ expect(subject.send(:merge_options).length).to eq(1)
213
+ end
214
+ end
215
+
216
+ context 'when no options are present' do
217
+ let(:project) { double(:project, allow_merge_commit: false, allow_squash_merge: false, allow_rebase_merge: false) }
218
+
219
+ it 'should have no items' do
220
+ expect(subject.send(:merge_options).length).to eq(0)
221
+ end
222
+ end
223
+ end
224
+
225
+ describe '#existing_project' do
226
+ it 'should call the octokit client' do
227
+ expect(octokit_client_client).to receive(:repository).and_return(:repository)
228
+ subject.send(:existing_project)
229
+ end
230
+ end
231
+
232
+ describe '#existing_pr' do
233
+ it 'should call the octokit client' do
234
+ allow(highline_cli).to receive(:code_request_id).and_return(123)
235
+ expect(octokit_client_client).to receive(:pull_request).and_return(:pull_request)
236
+ subject.send(:existing_pr)
237
+ end
238
+ end
239
+
240
+ describe '#octokit_client' do
241
+ it 'should call the octokit client' do
242
+ expect(GitHelper::OctokitClient).to receive(:new).and_return(octokit_client)
243
+ subject.send(:octokit_client)
244
+ end
245
+ end
246
+ end