git_helper 3.1.3 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +19 -18
- data/README.md +11 -6
- data/bin/git-helper +8 -1
- data/lib/git_helper/change_remote.rb +1 -1
- data/lib/git_helper/code_request.rb +6 -5
- data/lib/git_helper/git_config_reader.rb +11 -3
- data/lib/git_helper/highline_cli.rb +12 -68
- data/lib/git_helper/merge_request.rb +5 -5
- data/lib/git_helper/new_branch.rb +1 -1
- data/lib/git_helper/pull_request.rb +4 -4
- data/lib/git_helper/setup.rb +96 -0
- data/lib/git_helper/version.rb +1 -1
- data/spec/git_helper/change_remote_spec.rb +2 -2
- data/spec/git_helper/code_request_spec.rb +25 -24
- data/spec/git_helper/git_config_reader_spec.rb +28 -2
- data/spec/git_helper/highline_cli_spec.rb +18 -184
- data/spec/git_helper/merge_request_spec.rb +14 -14
- data/spec/git_helper/new_branch_spec.rb +2 -2
- data/spec/git_helper/pull_request_spec.rb +12 -12
- data/spec/git_helper/setup_spec.rb +175 -0
- metadata +19 -17
data/lib/git_helper/version.rb
CHANGED
@@ -4,7 +4,7 @@ require 'git_helper'
|
|
4
4
|
describe GitHelper::ChangeRemote do
|
5
5
|
let(:remote1) { "git@github.com:#{old_owner}/#{project}.git" }
|
6
6
|
let(:project) { Faker::Lorem.word }
|
7
|
-
let(:cli) { double(:highline_cli,
|
7
|
+
let(:cli) { double(:highline_cli, ask_yes_no: true) }
|
8
8
|
let(:old_owner) { Faker::Internet.username }
|
9
9
|
let(:new_owner) { Faker::Internet.username }
|
10
10
|
let(:directory_entries) { [ '.', '..', project, Faker::Lorem.word, Faker::Lorem.word ] }
|
@@ -73,7 +73,7 @@ describe GitHelper::ChangeRemote do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
context 'when the user says not to process the directory' do
|
76
|
-
let(:cli) { double(:highline_cli,
|
76
|
+
let(:cli) { double(:highline_cli, ask_yes_no: false) }
|
77
77
|
|
78
78
|
it 'should not call to process the directory' do
|
79
79
|
expect(subject).not_to receive(:process_git_repository)
|
@@ -101,19 +101,19 @@ describe GitHelper::CodeRequest do
|
|
101
101
|
|
102
102
|
describe '#ask_for_clarification' do
|
103
103
|
it 'should ask the CLI' do
|
104
|
-
expect(highline_cli).to receive(:
|
104
|
+
expect(highline_cli).to receive(:ask).and_return('github')
|
105
105
|
subject.send(:ask_for_clarification)
|
106
106
|
end
|
107
107
|
|
108
108
|
context 'when response is github' do
|
109
109
|
it 'should return github_pull_request' do
|
110
|
-
allow(highline_cli).to receive(:
|
110
|
+
allow(highline_cli).to receive(:ask).and_return('github')
|
111
111
|
expect(subject).to receive(:github_pull_request)
|
112
112
|
subject.send(:ask_for_clarification)
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'should return github_pull_request' do
|
116
|
-
allow(highline_cli).to receive(:
|
116
|
+
allow(highline_cli).to receive(:ask).and_return('Github')
|
117
117
|
expect(subject).to receive(:github_pull_request)
|
118
118
|
subject.send(:ask_for_clarification)
|
119
119
|
end
|
@@ -121,21 +121,22 @@ describe GitHelper::CodeRequest do
|
|
121
121
|
|
122
122
|
context 'when response is gitlab' do
|
123
123
|
it 'should return gitlab_merge_request' do
|
124
|
-
allow(highline_cli).to receive(:
|
124
|
+
allow(highline_cli).to receive(:ask).and_return('gitlab')
|
125
125
|
expect(subject).to receive(:gitlab_merge_request)
|
126
126
|
subject.send(:ask_for_clarification)
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'should return gitlab_merge_request' do
|
130
|
-
allow(highline_cli).to receive(:
|
130
|
+
allow(highline_cli).to receive(:ask).and_return('Gitlab')
|
131
131
|
expect(subject).to receive(:gitlab_merge_request)
|
132
132
|
subject.send(:ask_for_clarification)
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
+
# Unfortunately this test sometimes fails... just rerun the tests if it does
|
136
137
|
context 'when response is neither' do
|
137
138
|
it 'should raise an error' do
|
138
|
-
allow(highline_cli).to receive(:
|
139
|
+
allow(highline_cli).to receive(:ask).and_return(Faker::Lorem.word)
|
139
140
|
expect(subject).to receive(:exit)
|
140
141
|
subject.send(:ask_for_clarification)
|
141
142
|
end
|
@@ -173,23 +174,23 @@ describe GitHelper::CodeRequest do
|
|
173
174
|
describe '#base_branch' do
|
174
175
|
it 'should call the default branch' do
|
175
176
|
expect(subject).to receive(:default_branch)
|
176
|
-
allow(highline_cli).to receive(:
|
177
|
-
allow(highline_cli).to receive(:
|
177
|
+
allow(highline_cli).to receive(:ask_yes_no).at_least(:once)
|
178
|
+
allow(highline_cli).to receive(:ask).at_least(:once).and_return(base_branch)
|
178
179
|
subject.send(:base_branch)
|
179
180
|
end
|
180
181
|
|
181
182
|
it 'should ask the CLI to ask the user' do
|
182
183
|
allow(subject).to receive(:default_branch)
|
183
|
-
expect(highline_cli).to receive(:
|
184
|
-
allow(highline_cli).to receive(:
|
184
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once)
|
185
|
+
allow(highline_cli).to receive(:ask).at_least(:once).and_return(base_branch)
|
185
186
|
subject.send(:base_branch)
|
186
187
|
end
|
187
188
|
|
188
189
|
context 'if the user says no' do
|
189
190
|
it 'definitely asks for the users base branch' do
|
190
191
|
allow(subject).to receive(:default_branch)
|
191
|
-
expect(highline_cli).to receive(:
|
192
|
-
expect(highline_cli).to receive(:
|
192
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(false)
|
193
|
+
expect(highline_cli).to receive(:ask).at_least(:once).and_return(base_branch)
|
193
194
|
subject.send(:base_branch)
|
194
195
|
end
|
195
196
|
end
|
@@ -197,7 +198,7 @@ describe GitHelper::CodeRequest do
|
|
197
198
|
context 'if the user says yes' do
|
198
199
|
it 'does not ask for the users base branch' do
|
199
200
|
allow(subject).to receive(:default_branch)
|
200
|
-
expect(highline_cli).to receive(:
|
201
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(true)
|
201
202
|
expect(highline_cli).not_to receive(:base_branch)
|
202
203
|
subject.send(:base_branch)
|
203
204
|
end
|
@@ -215,32 +216,32 @@ describe GitHelper::CodeRequest do
|
|
215
216
|
describe '#new_code_request_title' do
|
216
217
|
it 'should call autogenerated title method' do
|
217
218
|
expect(subject).to receive(:autogenerated_title)
|
218
|
-
allow(highline_cli).to receive(:
|
219
|
-
allow(highline_cli).to receive(:
|
219
|
+
allow(highline_cli).to receive(:ask_yes_no).at_least(:once)
|
220
|
+
allow(highline_cli).to receive(:ask).at_least(:once).and_return(title)
|
220
221
|
subject.send(:new_code_request_title)
|
221
222
|
end
|
222
223
|
|
223
224
|
it 'should ask the CLI to ask the user' do
|
224
|
-
allow(subject).to receive(:autogenerated_title)
|
225
|
-
expect(highline_cli).to receive(:
|
226
|
-
allow(highline_cli).to receive(:
|
225
|
+
allow(subject).to receive(:autogenerated_title).and_return(Faker::Lorem.sentence)
|
226
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once)
|
227
|
+
allow(highline_cli).to receive(:ask).at_least(:once).and_return(title)
|
227
228
|
subject.send(:new_code_request_title)
|
228
229
|
end
|
229
230
|
|
230
231
|
context 'if the user says no' do
|
231
232
|
it 'definitely asks for the users title' do
|
232
|
-
allow(subject).to receive(:autogenerated_title)
|
233
|
-
expect(highline_cli).to receive(:
|
234
|
-
expect(highline_cli).to receive(:
|
233
|
+
allow(subject).to receive(:autogenerated_title).and_return(Faker::Lorem.sentence)
|
234
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(false)
|
235
|
+
expect(highline_cli).to receive(:ask).at_least(:once).and_return(title)
|
235
236
|
subject.send(:new_code_request_title)
|
236
237
|
end
|
237
238
|
end
|
238
239
|
|
239
240
|
context 'if the user says yes to original title' do
|
240
241
|
it 'does not ask for the users chosen title' do
|
241
|
-
allow(subject).to receive(:autogenerated_title)
|
242
|
-
expect(highline_cli).to receive(:
|
243
|
-
expect(highline_cli).not_to receive(:
|
242
|
+
allow(subject).to receive(:autogenerated_title).and_return(Faker::Lorem.sentence)
|
243
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(true)
|
244
|
+
expect(highline_cli).not_to receive(:ask)
|
244
245
|
subject.send(:new_code_request_title)
|
245
246
|
end
|
246
247
|
end
|
@@ -2,14 +2,16 @@ require 'spec_helper'
|
|
2
2
|
require 'git_helper'
|
3
3
|
|
4
4
|
describe GitHelper::GitConfigReader do
|
5
|
+
let(:github_user) { Faker::Internet.username }
|
5
6
|
let(:github_token) { Faker::Internet.password(max_length: 10) }
|
7
|
+
let(:gitlab_user) { Faker::Internet.username }
|
6
8
|
let(:gitlab_token) { Faker::Internet.password(max_length: 10) }
|
7
9
|
|
8
10
|
let(:config_file) {
|
9
11
|
{
|
10
|
-
github_user:
|
12
|
+
github_user: github_user,
|
11
13
|
github_token: github_token,
|
12
|
-
gitlab_user:
|
14
|
+
gitlab_user: gitlab_user,
|
13
15
|
gitlab_token: gitlab_token
|
14
16
|
}
|
15
17
|
}
|
@@ -40,6 +42,30 @@ describe GitHelper::GitConfigReader do
|
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
45
|
+
describe '#github_user' do
|
46
|
+
it 'should locate the github_user' do
|
47
|
+
expect(subject).to receive(:config_file).and_return(config_file)
|
48
|
+
expect(subject.github_user).to eq(github_user)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should call the config file' do
|
52
|
+
expect(subject).to receive(:config_file).and_return(config_file)
|
53
|
+
subject.github_user
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#gitlab_user' do
|
58
|
+
it 'should locate the gitlab_user' do
|
59
|
+
expect(subject).to receive(:config_file).and_return(config_file)
|
60
|
+
expect(subject.gitlab_user).to eq(gitlab_user)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should call the config file' do
|
64
|
+
expect(subject).to receive(:config_file).and_return(config_file)
|
65
|
+
subject.gitlab_user
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
43
69
|
describe '#config_file' do
|
44
70
|
it 'should yaml load the file path' do
|
45
71
|
expect(YAML).to receive(:load_file)
|
@@ -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
|
+
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 '#
|
15
|
-
it 'should ask the
|
16
|
-
expect(
|
17
|
-
subject.
|
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
|
-
|
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 '#
|
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.
|
28
|
+
subject.ask_yes_no(Faker::Lorem.sentence)
|
200
29
|
end
|
201
30
|
|
202
|
-
it 'should return a
|
203
|
-
expect(subject.
|
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.
|
44
|
+
subject.ask_options(Faker::Lorem.sentence, ['one', 'two', 'three'])
|
211
45
|
end
|
212
46
|
|
213
|
-
it 'should return
|
214
|
-
expect(subject.
|
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
|
@@ -120,19 +120,19 @@ describe GitHelper::GitLabMergeRequest do
|
|
120
120
|
|
121
121
|
it 'should call the CLI to ask about a single template' do
|
122
122
|
allow(subject).to receive(:mr_template_options).and_return([template])
|
123
|
-
expect(highline_cli).to receive(:
|
123
|
+
expect(highline_cli).to receive(:ask_yes_no).and_return(true)
|
124
124
|
subject.send(:template_name_to_apply)
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'should return the single template if the user says yes' do
|
128
128
|
allow(subject).to receive(:mr_template_options).and_return([template])
|
129
|
-
allow(highline_cli).to receive(:
|
129
|
+
allow(highline_cli).to receive(:ask_yes_no).and_return(true)
|
130
130
|
expect(subject.send(:template_name_to_apply)).to eq(template)
|
131
131
|
end
|
132
132
|
|
133
133
|
it 'should return nil if the user says no' do
|
134
134
|
allow(subject).to receive(:mr_template_options).and_return([template])
|
135
|
-
allow(highline_cli).to receive(:
|
135
|
+
allow(highline_cli).to receive(:ask_yes_no).and_return(false)
|
136
136
|
expect(subject.send(:template_name_to_apply)).to eq(nil)
|
137
137
|
end
|
138
138
|
end
|
@@ -143,19 +143,19 @@ describe GitHelper::GitLabMergeRequest do
|
|
143
143
|
|
144
144
|
it 'should call the CLI to ask which of multiple templates to apply' do
|
145
145
|
allow(subject).to receive(:mr_template_options).and_return([template1, template2])
|
146
|
-
expect(highline_cli).to receive(:
|
146
|
+
expect(highline_cli).to receive(:ask_options).and_return(template1)
|
147
147
|
subject.send(:template_name_to_apply)
|
148
148
|
end
|
149
149
|
|
150
150
|
it 'should return the answer template if the user says yes' do
|
151
151
|
allow(subject).to receive(:mr_template_options).and_return([template1, template2])
|
152
|
-
allow(highline_cli).to receive(:
|
152
|
+
allow(highline_cli).to receive(:ask_options).and_return(template1)
|
153
153
|
expect(subject.send(:template_name_to_apply)).to eq(template1)
|
154
154
|
end
|
155
155
|
|
156
156
|
it 'should return nil if the user says no' do
|
157
157
|
allow(subject).to receive(:mr_template_options).and_return([template1, template2])
|
158
|
-
allow(highline_cli).to receive(:
|
158
|
+
allow(highline_cli).to receive(:ask_options).and_return('None')
|
159
159
|
expect(subject.send(:template_name_to_apply)).to eq(nil)
|
160
160
|
end
|
161
161
|
end
|
@@ -170,25 +170,25 @@ describe GitHelper::GitLabMergeRequest do
|
|
170
170
|
|
171
171
|
describe '#mr_id' do
|
172
172
|
it 'should ask the CLI for the code request ID' do
|
173
|
-
expect(highline_cli).to receive(:
|
173
|
+
expect(highline_cli).to receive(:ask).and_return(Faker::Number.number)
|
174
174
|
subject.send(:mr_id)
|
175
175
|
end
|
176
176
|
|
177
177
|
it 'should equal an integer' do
|
178
178
|
pr_id = Faker::Number.number
|
179
|
-
expect(highline_cli).to receive(:
|
179
|
+
expect(highline_cli).to receive(:ask).and_return(pr_id)
|
180
180
|
expect(subject.send(:mr_id)).to eq(pr_id)
|
181
181
|
end
|
182
182
|
end
|
183
183
|
|
184
184
|
describe '#squash_merge_request' do
|
185
185
|
it 'should ask the CLI for the code request ID' do
|
186
|
-
expect(highline_cli).to receive(:
|
186
|
+
expect(highline_cli).to receive(:ask_yes_no).and_return(true)
|
187
187
|
subject.send(:squash_merge_request)
|
188
188
|
end
|
189
189
|
|
190
190
|
it 'should be a boolean' do
|
191
|
-
expect(highline_cli).to receive(:
|
191
|
+
expect(highline_cli).to receive(:ask_yes_no).and_return(false)
|
192
192
|
expect([true, false]).to include(subject.send(:squash_merge_request))
|
193
193
|
end
|
194
194
|
end
|
@@ -200,12 +200,12 @@ describe GitHelper::GitLabMergeRequest do
|
|
200
200
|
|
201
201
|
context 'when the existing project has no setting' do
|
202
202
|
it 'should ask the CLI for the code request ID' do
|
203
|
-
expect(highline_cli).to receive(:
|
203
|
+
expect(highline_cli).to receive(:ask_yes_no).and_return(true)
|
204
204
|
subject.send(:remove_source_branch)
|
205
205
|
end
|
206
206
|
|
207
207
|
it 'should be a boolean' do
|
208
|
-
allow(highline_cli).to receive(:
|
208
|
+
allow(highline_cli).to receive(:ask_yes_no).and_return(false)
|
209
209
|
expect([true, false]).to include(subject.send(:remove_source_branch))
|
210
210
|
end
|
211
211
|
end
|
@@ -222,7 +222,7 @@ describe GitHelper::GitLabMergeRequest do
|
|
222
222
|
|
223
223
|
it 'should return the existing projects setting if it exists' do
|
224
224
|
allow(subject).to receive(:existing_project).and_return(double(remove_source_branch_after_merge: false))
|
225
|
-
allow(highline_cli).to receive(:
|
225
|
+
allow(highline_cli).to receive(:ask_yes_no).and_return(true)
|
226
226
|
expect(subject.send(:remove_source_branch)).to eq(true)
|
227
227
|
end
|
228
228
|
end
|
@@ -236,7 +236,7 @@ describe GitHelper::GitLabMergeRequest do
|
|
236
236
|
|
237
237
|
describe '#existing_mr' do
|
238
238
|
it 'should call the gitlab client' do
|
239
|
-
allow(highline_cli).to receive(:
|
239
|
+
allow(highline_cli).to receive(:ask).and_return(Faker::Number.number)
|
240
240
|
expect(gitlab_client_client).to receive(:merge_request).and_return(:merge_request)
|
241
241
|
subject.send(:existing_mr)
|
242
242
|
end
|