git_helper 3.1.0 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'git_helper'
3
3
 
4
4
  describe GitHelper::HighlineCli do
5
- let(:response) { double(:response, readline: true, to_i: 5) }
5
+ let(:response) { double(:response, readline: true, to_i: 3) }
6
6
  let(:highline_client) { double(:highline_cli, ask: response) }
7
7
 
8
8
  subject { GitHelper::HighlineCli.new }
@@ -11,207 +11,41 @@ describe GitHelper::HighlineCli do
11
11
  allow(HighLine).to receive(:new).and_return(highline_client)
12
12
  end
13
13
 
14
- describe '#new_branch_name' do
15
- it 'should ask the subjects ask method' do
16
- expect(subject).to receive(:ask).with('New branch name?')
17
- subject.new_branch_name
18
- end
19
-
20
- it 'should come out a string' do
21
- expect(subject.new_branch_name).to be_a(String)
22
- end
23
- end
24
-
25
- describe '#process_directory_remotes' do
26
- it 'should ask the subjects ask method' do
27
- expect(subject).to receive(:ask).and_return('y')
28
- subject.process_directory_remotes?(Faker::Lorem.word)
29
- end
30
-
31
- it 'should be a boolean at the end' do
32
- allow(subject).to receive(:ask).and_return('y')
33
- expect([true, false]).to include(subject.process_directory_remotes?(Faker::Lorem.word))
34
- end
35
-
36
- it 'should come out as a true boolean if somebody responds y' do
37
- allow(subject).to receive(:ask).and_return('y')
38
- expect(subject.process_directory_remotes?(Faker::Lorem.word)).to eq(true)
39
- end
40
-
41
- it 'should come out as a false boolean if somebody responds n' do
42
- allow(subject).to receive(:ask).and_return('n')
43
- expect(subject.process_directory_remotes?(Faker::Lorem.word)).to eq(false)
44
- end
45
-
46
- it 'should come out as true if somebody presses enter' do
47
- allow(subject).to receive(:ask).and_return('')
48
- expect(subject.accept_autogenerated_title?(Faker::Lorem.word)).to eq(true)
49
- end
50
- end
51
-
52
- describe '#conflicting_remote_clarification' do
53
- it 'should ask the subjects ask method' do
54
- expect(subject).to receive(:ask).with('Found git remotes for both GitHub and GitLab. Would you like to proceed with GitLab or GitHub? (github/gitlab)').and_return('gitlab')
55
- subject.conflicting_remote_clarification
56
- end
57
-
58
- it 'should come out a string' do
59
- expect(subject.conflicting_remote_clarification).to be_a(String)
60
- end
61
- end
62
-
63
- describe '#title' do
64
- it 'should ask the subjects ask method' do
65
- expect(subject).to receive(:ask).with('Title?')
66
- subject.title
67
- end
68
-
69
- it 'should come out a string' do
70
- expect(subject.title).to be_a(String)
71
- end
72
- end
73
-
74
- describe '#base_branch' do
75
- it 'should ask the subjects ask method' do
76
- expect(subject).to receive(:ask).with('Base branch?')
77
- subject.base_branch
78
- end
79
-
80
- it 'should come out a string' do
81
- expect(subject.base_branch).to be_a(String)
82
- end
83
- end
84
-
85
- describe '#code_request_id' do
86
- let(:phrase) { Faker::Lorem.sentence }
87
-
88
- it 'should ask the subjects ask method' do
89
- expect(subject).to receive(:ask).with("#{phrase} Request ID?")
90
- subject.code_request_id(phrase)
91
- end
92
-
93
- it 'should come out a string' do
94
- expect(subject.code_request_id(phrase)).to be_a(String)
95
- end
96
- end
97
-
98
- describe '#accept_autogenerated_title' do
99
- it 'should ask the subjects ask method' do
100
- expect(subject).to receive(:ask).and_return('y')
101
- subject.accept_autogenerated_title?(Faker::Lorem.sentence)
102
- end
103
-
104
- it 'should be a boolean at the end' do
105
- allow(subject).to receive(:ask).and_return('y')
106
- expect([true, false]).to include(subject.accept_autogenerated_title?(Faker::Lorem.sentence))
107
- end
108
-
109
- it 'should come out as a true boolean if somebody responds y' do
110
- allow(subject).to receive(:ask).and_return('y')
111
- expect(subject.accept_autogenerated_title?(Faker::Lorem.sentence)).to eq(true)
112
- end
113
-
114
- it 'should come out as a true boolean if somebody responds n' do
115
- allow(subject).to receive(:ask).and_return('n')
116
- expect(subject.accept_autogenerated_title?(Faker::Lorem.sentence)).to eq(false)
117
- end
118
-
119
- it 'should come out as a true boolean if somebody responds yes' do
120
- allow(subject).to receive(:ask).and_return('yes')
121
- expect(subject.accept_autogenerated_title?(Faker::Lorem.sentence)).to eq(true)
122
- end
123
-
124
- it 'should come out as a false boolean if somebody responds no' do
125
- allow(subject).to receive(:ask).and_return('no')
126
- expect(subject.accept_autogenerated_title?(Faker::Lorem.sentence)).to eq(false)
127
- end
128
-
129
- it 'should come out as true if somebody presses enter' do
130
- allow(subject).to receive(:ask).and_return('')
131
- expect(subject.accept_autogenerated_title?(Faker::Lorem.sentence)).to eq(true)
132
- end
133
- end
134
-
135
- describe '#base_branch_default' do
136
- it 'should ask the subjects ask method' do
137
- expect(subject).to receive(:ask).and_return('y')
138
- subject.base_branch_default?(Faker::Lorem.word)
139
- end
140
-
141
- it 'should be a boolean at the end' do
142
- allow(subject).to receive(:ask).and_return('y')
143
- expect([true, false]).to include(subject.base_branch_default?(Faker::Lorem.word))
144
- end
145
-
146
- it 'should come out as a true boolean if somebody responds y' do
147
- allow(subject).to receive(:ask).and_return('y')
148
- expect(subject.base_branch_default?(Faker::Lorem.word)).to eq(true)
149
- end
150
-
151
- it 'should come out as a true boolean if somebody responds n' do
152
- allow(subject).to receive(:ask).and_return('n')
153
- expect(subject.base_branch_default?(Faker::Lorem.word)).to eq(false)
154
- end
155
-
156
- it 'should come out as a true boolean if somebody responds yes' do
157
- allow(subject).to receive(:ask).and_return('yes')
158
- expect(subject.base_branch_default?(Faker::Lorem.word)).to eq(true)
159
- end
160
-
161
- it 'should come out as a false boolean if somebody responds no' do
162
- allow(subject).to receive(:ask).and_return('no')
163
- expect(subject.base_branch_default?(Faker::Lorem.word)).to eq(false)
164
- end
165
-
166
- it 'should come out as true if somebody presses enter' do
167
- allow(subject).to receive(:ask).and_return('')
168
- expect(subject.base_branch_default?(Faker::Lorem.word)).to eq(true)
169
- end
170
- end
171
-
172
- describe '#merge_method' do
173
- it 'should ask the subjects ask_options method' do
174
- expect(subject).to receive(:ask_options).and_return(3)
175
- subject.merge_method(['1', '2', '3'])
176
- end
177
-
178
- it 'should return a string' do
179
- allow(subject).to receive(:ask_options).and_return(2)
180
- expect(subject.merge_method(['1', '2', '3'])).to be_a(String)
181
- end
182
- end
183
-
184
- describe '#template_to_apply' do
185
- it 'should ask the subjects ask_options method' do
186
- expect(subject).to receive(:ask_options).and_return(3)
187
- subject.template_to_apply(['option1', 'option2', 'option3'], 'example type')
14
+ describe '#ask' do
15
+ it 'should ask the highline client ask'do
16
+ expect(highline_client).to receive(:ask)
17
+ subject.ask(Faker::Lorem.sentence)
188
18
  end
189
19
 
190
20
  it 'should return a string' do
191
- allow(subject).to receive(:ask_options).and_return(3)
192
- expect(subject.template_to_apply(['option1', 'option2', 'option3'], 'example type')).to eq('None')
21
+ expect(subject.ask(Faker::Lorem.sentence)).to be_a(String)
193
22
  end
194
23
  end
195
24
 
196
- describe '#ask' do
25
+ describe '#ask_yes_no' do
197
26
  it 'should ask the highline client ask'do
198
27
  expect(highline_client).to receive(:ask)
199
- subject.send(:ask, Faker::Lorem.sentence)
28
+ subject.ask_yes_no(Faker::Lorem.sentence)
200
29
  end
201
30
 
202
- it 'should return a string' do
203
- expect(subject.send(:ask, Faker::Lorem.sentence)).to be_a(String)
31
+ it 'should return a boolean' do
32
+ expect(subject.ask_yes_no(Faker::Lorem.sentence)).to be_falsey
33
+ end
34
+
35
+ it 'should return true if we say yes' do
36
+ allow(response).to receive(:to_s).and_return('y')
37
+ expect(subject.ask_yes_no(Faker::Lorem.sentence)).to be_truthy
204
38
  end
205
39
  end
206
40
 
207
41
  describe '#ask_options' do
208
42
  it 'should ask the highline client ask'do
209
43
  expect(highline_client).to receive(:ask)
210
- subject.send(:ask_options, Faker::Lorem.sentence, ['1', '2', '3'])
44
+ subject.ask_options(Faker::Lorem.sentence, ['one', 'two', 'three'])
211
45
  end
212
46
 
213
- it 'should return an integer' do
214
- expect(subject.send(:ask_options, Faker::Lorem.sentence, ['1', '2', '3'])).to be_a(Integer)
47
+ it 'should return a string from the options' do
48
+ expect(subject.ask_options(Faker::Lorem.sentence, ['one', 'two', 'three'])).to be_a(String)
215
49
  end
216
50
  end
217
51
  end
@@ -70,6 +70,7 @@ describe GitHelper::LocalCode do
70
70
 
71
71
  describe '#change_remote' do
72
72
  it 'should return a string' do
73
+ allow(subject).to receive(:`).and_return(Faker::Lorem.word)
73
74
  expect(subject.change_remote(Faker::Lorem.word, Faker::Internet.url)).to be_a(String)
74
75
  end
75
76
  end
@@ -6,6 +6,15 @@ describe GitHelper::GitLabMergeRequest do
6
6
  let(:highline_cli) { double(:highline_cli) }
7
7
  let(:gitlab_client_client) { double(:gitlab_client_client, project: :project, merge_request: :merge_request, create_merge_request: :created) }
8
8
  let(:gitlab_client) { double(:gitlab_client, client: gitlab_client_client) }
9
+ let(:diff_refs) { double(:diff_refs, base_sha: :base, head_sha: :head) }
10
+
11
+ let(:merge_request) do
12
+ double(:merge_request,
13
+ diff_refs: diff_refs,
14
+ web_url: Faker::Internet.url,
15
+ merge_commit_sha: Faker::Internet.password
16
+ )
17
+ end
9
18
 
10
19
  let(:options) do
11
20
  {
@@ -20,6 +29,7 @@ describe GitHelper::GitLabMergeRequest do
20
29
 
21
30
  before do
22
31
  allow(GitHelper::GitLabClient).to receive(:new).and_return(gitlab_client)
32
+ allow(subject).to receive(:puts)
23
33
  end
24
34
 
25
35
  describe '#create' do
@@ -27,7 +37,7 @@ describe GitHelper::GitLabMergeRequest do
27
37
  allow(subject).to receive(:squash_merge_request).and_return(true)
28
38
  allow(subject).to receive(:remove_source_branch).and_return(false)
29
39
  allow(subject).to receive(:new_mr_body).and_return('')
30
- expect(gitlab_client_client).to receive(:create_merge_request)
40
+ expect(gitlab_client_client).to receive(:create_merge_request).and_return(merge_request)
31
41
  subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})
32
42
  end
33
43
 
@@ -35,7 +45,7 @@ describe GitHelper::GitLabMergeRequest do
35
45
  expect(subject).to receive(:squash_merge_request).and_return(true)
36
46
  expect(subject).to receive(:remove_source_branch).and_return(false)
37
47
  expect(subject).to receive(:new_mr_body).and_return('')
38
- allow(gitlab_client_client).to receive(:create_merge_request)
48
+ allow(gitlab_client_client).to receive(:create_merge_request).and_return(merge_request)
39
49
  subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})
40
50
  end
41
51
 
@@ -52,14 +62,14 @@ describe GitHelper::GitLabMergeRequest do
52
62
  it 'should call the gitlab client to merge' do
53
63
  allow(subject).to receive(:existing_mr).and_return(double(should_remove_source_branch: true, squash: false, title: 'title'))
54
64
  allow(subject).to receive(:mr_id).and_return(Faker::Number.number)
55
- expect(gitlab_client_client).to receive(:accept_merge_request)
65
+ expect(gitlab_client_client).to receive(:accept_merge_request).and_return(merge_request)
56
66
  subject.merge
57
67
  end
58
68
 
59
69
  it 'should call various other methods' do
60
70
  expect(subject).to receive(:existing_mr).and_return(double(should_remove_source_branch: true, squash: false, title: 'title')).at_least(:once)
61
71
  expect(subject).to receive(:mr_id).and_return(Faker::Number.number).at_least(:once)
62
- allow(gitlab_client_client).to receive(:accept_merge_request)
72
+ allow(gitlab_client_client).to receive(:accept_merge_request).and_return(merge_request)
63
73
  subject.merge
64
74
  end
65
75
 
@@ -73,7 +83,7 @@ describe GitHelper::GitLabMergeRequest do
73
83
  it 'should try to merge multiple times if the first merge errors' do
74
84
  allow(subject).to receive(:existing_mr).and_return(double(should_remove_source_branch: true, squash: false, title: 'title'))
75
85
  allow(subject).to receive(:mr_id).and_return(Faker::Number.number)
76
- expect(gitlab_client_client).to receive(:accept_merge_request).and_return(double(merge_commit_sha: nil)).exactly(2).times
86
+ expect(gitlab_client_client).to receive(:accept_merge_request).and_return(double(merge_commit_sha: nil, merge_error: Faker::Lorem.word)).exactly(2).times
77
87
  expect(subject.merge).to eq(nil)
78
88
  end
79
89
  end
@@ -110,19 +120,19 @@ describe GitHelper::GitLabMergeRequest do
110
120
 
111
121
  it 'should call the CLI to ask about a single template' do
112
122
  allow(subject).to receive(:mr_template_options).and_return([template])
113
- expect(highline_cli).to receive(:apply_template?).and_return(true)
123
+ expect(highline_cli).to receive(:ask_yes_no).and_return(true)
114
124
  subject.send(:template_name_to_apply)
115
125
  end
116
126
 
117
127
  it 'should return the single template if the user says yes' do
118
128
  allow(subject).to receive(:mr_template_options).and_return([template])
119
- allow(highline_cli).to receive(:apply_template?).and_return(true)
129
+ allow(highline_cli).to receive(:ask_yes_no).and_return(true)
120
130
  expect(subject.send(:template_name_to_apply)).to eq(template)
121
131
  end
122
132
 
123
133
  it 'should return nil if the user says no' do
124
134
  allow(subject).to receive(:mr_template_options).and_return([template])
125
- allow(highline_cli).to receive(:apply_template?).and_return(false)
135
+ allow(highline_cli).to receive(:ask_yes_no).and_return(false)
126
136
  expect(subject.send(:template_name_to_apply)).to eq(nil)
127
137
  end
128
138
  end
@@ -133,19 +143,19 @@ describe GitHelper::GitLabMergeRequest do
133
143
 
134
144
  it 'should call the CLI to ask which of multiple templates to apply' do
135
145
  allow(subject).to receive(:mr_template_options).and_return([template1, template2])
136
- expect(highline_cli).to receive(:template_to_apply).and_return(template1)
146
+ expect(highline_cli).to receive(:ask_options).and_return(template1)
137
147
  subject.send(:template_name_to_apply)
138
148
  end
139
149
 
140
150
  it 'should return the answer template if the user says yes' do
141
151
  allow(subject).to receive(:mr_template_options).and_return([template1, template2])
142
- allow(highline_cli).to receive(:template_to_apply).and_return(template1)
152
+ allow(highline_cli).to receive(:ask_options).and_return(template1)
143
153
  expect(subject.send(:template_name_to_apply)).to eq(template1)
144
154
  end
145
155
 
146
156
  it 'should return nil if the user says no' do
147
157
  allow(subject).to receive(:mr_template_options).and_return([template1, template2])
148
- allow(highline_cli).to receive(:template_to_apply).and_return('None')
158
+ allow(highline_cli).to receive(:ask_options).and_return('None')
149
159
  expect(subject.send(:template_name_to_apply)).to eq(nil)
150
160
  end
151
161
  end
@@ -160,25 +170,25 @@ describe GitHelper::GitLabMergeRequest do
160
170
 
161
171
  describe '#mr_id' do
162
172
  it 'should ask the CLI for the code request ID' do
163
- expect(highline_cli).to receive(:code_request_id).and_return(Faker::Number.number)
173
+ expect(highline_cli).to receive(:ask).and_return(Faker::Number.number)
164
174
  subject.send(:mr_id)
165
175
  end
166
176
 
167
177
  it 'should equal an integer' do
168
178
  pr_id = Faker::Number.number
169
- expect(highline_cli).to receive(:code_request_id).and_return(pr_id)
179
+ expect(highline_cli).to receive(:ask).and_return(pr_id)
170
180
  expect(subject.send(:mr_id)).to eq(pr_id)
171
181
  end
172
182
  end
173
183
 
174
184
  describe '#squash_merge_request' do
175
185
  it 'should ask the CLI for the code request ID' do
176
- expect(highline_cli).to receive(:squash_merge_request?).and_return(true)
186
+ expect(highline_cli).to receive(:ask_yes_no).and_return(true)
177
187
  subject.send(:squash_merge_request)
178
188
  end
179
189
 
180
190
  it 'should be a boolean' do
181
- expect(highline_cli).to receive(:squash_merge_request?).and_return(false)
191
+ expect(highline_cli).to receive(:ask_yes_no).and_return(false)
182
192
  expect([true, false]).to include(subject.send(:squash_merge_request))
183
193
  end
184
194
  end
@@ -190,12 +200,12 @@ describe GitHelper::GitLabMergeRequest do
190
200
 
191
201
  context 'when the existing project has no setting' do
192
202
  it 'should ask the CLI for the code request ID' do
193
- expect(highline_cli).to receive(:remove_source_branch?).and_return(true)
203
+ expect(highline_cli).to receive(:ask_yes_no).and_return(true)
194
204
  subject.send(:remove_source_branch)
195
205
  end
196
206
 
197
207
  it 'should be a boolean' do
198
- allow(highline_cli).to receive(:remove_source_branch?).and_return(false)
208
+ allow(highline_cli).to receive(:ask_yes_no).and_return(false)
199
209
  expect([true, false]).to include(subject.send(:remove_source_branch))
200
210
  end
201
211
  end
@@ -212,7 +222,7 @@ describe GitHelper::GitLabMergeRequest do
212
222
 
213
223
  it 'should return the existing projects setting if it exists' do
214
224
  allow(subject).to receive(:existing_project).and_return(double(remove_source_branch_after_merge: false))
215
- allow(highline_cli).to receive(:remove_source_branch?).and_return(true)
225
+ allow(highline_cli).to receive(:ask_yes_no).and_return(true)
216
226
  expect(subject.send(:remove_source_branch)).to eq(true)
217
227
  end
218
228
  end
@@ -226,7 +236,7 @@ describe GitHelper::GitLabMergeRequest do
226
236
 
227
237
  describe '#existing_mr' do
228
238
  it 'should call the gitlab client' do
229
- allow(highline_cli).to receive(:code_request_id).and_return(Faker::Number.number)
239
+ allow(highline_cli).to receive(:ask).and_return(Faker::Number.number)
230
240
  expect(gitlab_client_client).to receive(:merge_request).and_return(:merge_request)
231
241
  subject.send(:existing_mr)
232
242
  end
@@ -4,13 +4,14 @@ require 'git_helper'
4
4
  describe GitHelper::NewBranch do
5
5
  let(:new_branch_name) { 'new-branch-name' }
6
6
  let(:local_code) { double(:local_code, new_branch: :commit) }
7
- let(:cli) { double(:highline_cli, new_branch_name: new_branch_name) }
7
+ let(:cli) { double(:highline_cli, ask: new_branch_name) }
8
8
 
9
9
  subject { GitHelper::NewBranch.new }
10
10
 
11
11
  before do
12
12
  allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
13
13
  allow(GitHelper::HighlineCli).to receive(:new).and_return(cli)
14
+ allow(subject).to receive(:puts)
14
15
  end
15
16
 
16
17
  it 'should call GitHelper::LocalCode' do
@@ -30,7 +31,7 @@ describe GitHelper::NewBranch do
30
31
  end
31
32
 
32
33
  it 'should ask the highline cli what the new branch name should be' do
33
- expect(cli).to receive(:new_branch_name)
34
+ expect(cli).to receive(:ask)
34
35
  subject.execute
35
36
  end
36
37
  end
@@ -20,18 +20,19 @@ describe GitHelper::GitHubPullRequest do
20
20
 
21
21
  before do
22
22
  allow(GitHelper::OctokitClient).to receive(:new).and_return(octokit_client)
23
+ allow(subject).to receive(:puts)
23
24
  end
24
25
 
25
26
  describe '#create' do
26
27
  it 'should call the octokit client to create' do
27
28
  allow(subject).to receive(:new_pr_body).and_return('')
28
- expect(octokit_client_client).to receive(:create_pull_request)
29
+ expect(octokit_client_client).to receive(:create_pull_request).and_return(double(html_url: Faker::Internet.url))
29
30
  subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})
30
31
  end
31
32
 
32
33
  it 'should call various other methods' do
33
34
  expect(subject).to receive(:new_pr_body).and_return('').at_least(:once)
34
- allow(octokit_client_client).to receive(:create_pull_request)
35
+ allow(octokit_client_client).to receive(:create_pull_request).and_return(double(html_url: Faker::Internet.url))
35
36
  subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})
36
37
  end
37
38
 
@@ -47,7 +48,7 @@ describe GitHelper::GitHubPullRequest do
47
48
  allow(subject).to receive(:existing_pr).and_return(double(title: Faker::Lorem.word))
48
49
  allow(subject).to receive(:merge_method).and_return('rebase')
49
50
  allow(subject).to receive(:pr_id).and_return(Faker::Number.number)
50
- expect(octokit_client_client).to receive(:merge_pull_request)
51
+ expect(octokit_client_client).to receive(:merge_pull_request).and_return(double(sha: Faker::Internet.password))
51
52
  subject.merge
52
53
  end
53
54
 
@@ -55,7 +56,7 @@ describe GitHelper::GitHubPullRequest do
55
56
  expect(subject).to receive(:existing_pr).and_return(double(title: Faker::Lorem.word)).at_least(:once)
56
57
  expect(subject).to receive(:merge_method).and_return('rebase').at_least(:once)
57
58
  expect(subject).to receive(:pr_id).and_return(Faker::Number.number).at_least(:once)
58
- allow(octokit_client_client).to receive(:merge_pull_request)
59
+ allow(octokit_client_client).to receive(:merge_pull_request).and_return(double(sha: Faker::Internet.password))
59
60
  subject.merge
60
61
  end
61
62
 
@@ -100,19 +101,19 @@ describe GitHelper::GitHubPullRequest do
100
101
 
101
102
  it 'should call the CLI to ask about a single template' do
102
103
  allow(subject).to receive(:pr_template_options).and_return([template])
103
- expect(highline_cli).to receive(:apply_template?).and_return(true)
104
+ expect(highline_cli).to receive(:ask_yes_no).and_return(true)
104
105
  subject.send(:template_name_to_apply)
105
106
  end
106
107
 
107
108
  it 'should return the single template if the user says yes' do
108
109
  allow(subject).to receive(:pr_template_options).and_return([template])
109
- allow(highline_cli).to receive(:apply_template?).and_return(true)
110
+ allow(highline_cli).to receive(:ask_yes_no).and_return(true)
110
111
  expect(subject.send(:template_name_to_apply)).to eq(template)
111
112
  end
112
113
 
113
114
  it 'should return nil if the user says no' do
114
115
  allow(subject).to receive(:pr_template_options).and_return([template])
115
- allow(highline_cli).to receive(:apply_template?).and_return(false)
116
+ allow(highline_cli).to receive(:ask_yes_no).and_return(false)
116
117
  expect(subject.send(:template_name_to_apply)).to eq(nil)
117
118
  end
118
119
  end
@@ -123,19 +124,19 @@ describe GitHelper::GitHubPullRequest do
123
124
 
124
125
  it 'should call the CLI to ask which of multiple templates to apply' do
125
126
  allow(subject).to receive(:pr_template_options).and_return([template1, template2])
126
- expect(highline_cli).to receive(:template_to_apply).and_return(template1)
127
+ expect(highline_cli).to receive(:ask_options).and_return(template1)
127
128
  subject.send(:template_name_to_apply)
128
129
  end
129
130
 
130
131
  it 'should return the answer template if the user says yes' do
131
132
  allow(subject).to receive(:pr_template_options).and_return([template1, template2])
132
- allow(highline_cli).to receive(:template_to_apply).and_return(template1)
133
+ allow(highline_cli).to receive(:ask_options).and_return(template1)
133
134
  expect(subject.send(:template_name_to_apply)).to eq(template1)
134
135
  end
135
136
 
136
137
  it 'should return nil if the user says no' do
137
138
  allow(subject).to receive(:pr_template_options).and_return([template1, template2])
138
- allow(highline_cli).to receive(:template_to_apply).and_return('None')
139
+ allow(highline_cli).to receive(:ask_options).and_return('None')
139
140
  expect(subject.send(:template_name_to_apply)).to eq(nil)
140
141
  end
141
142
  end
@@ -150,13 +151,13 @@ describe GitHelper::GitHubPullRequest do
150
151
 
151
152
  describe '#pr_id' do
152
153
  it 'should ask the CLI for the code request ID' do
153
- expect(highline_cli).to receive(:code_request_id).and_return(Faker::Number.number)
154
+ expect(highline_cli).to receive(:ask).and_return(Faker::Number.number)
154
155
  subject.send(:pr_id)
155
156
  end
156
157
 
157
158
  it 'should equal an integer' do
158
159
  pr_id = Faker::Number.number
159
- expect(highline_cli).to receive(:code_request_id).and_return(pr_id)
160
+ expect(highline_cli).to receive(:ask).and_return(pr_id)
160
161
  expect(subject.send(:pr_id)).to eq(pr_id)
161
162
  end
162
163
  end
@@ -166,16 +167,16 @@ describe GitHelper::GitHubPullRequest do
166
167
 
167
168
  before do
168
169
  allow(subject).to receive(:existing_project).and_return(project)
169
- allow(highline_cli).to receive(:merge_method)
170
+ allow(highline_cli).to receive(:ask_options)
170
171
  end
171
172
 
172
173
  it 'should ask the CLI for the merge_method' do
173
- expect(highline_cli).to receive(:merge_method).and_return('merge')
174
+ expect(highline_cli).to receive(:ask_options).and_return('merge')
174
175
  subject.send(:merge_method)
175
176
  end
176
177
 
177
178
  it 'should be a string' do
178
- allow(highline_cli).to receive(:merge_method).and_return('merge')
179
+ allow(highline_cli).to receive(:ask_options).and_return('merge')
179
180
  expect(subject.send(:merge_method)).to be_a(String)
180
181
  end
181
182
 
@@ -238,7 +239,7 @@ describe GitHelper::GitHubPullRequest do
238
239
 
239
240
  describe '#existing_pr' do
240
241
  it 'should call the octokit client' do
241
- allow(highline_cli).to receive(:code_request_id).and_return(Faker::Number.number)
242
+ allow(highline_cli).to receive(:ask).and_return(Faker::Number.number)
242
243
  expect(octokit_client_client).to receive(:pull_request).and_return(:pull_request)
243
244
  subject.send(:existing_pr)
244
245
  end