git_helper 1.2.0 → 2.0.2
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +17 -13
- data/README.md +27 -33
- data/Rakefile +1 -37
- data/bin/git-helper +10 -28
- data/lib/git_helper.rb +3 -5
- data/lib/git_helper/change_remote.rb +53 -40
- data/lib/git_helper/checkout_default.rb +1 -1
- data/lib/git_helper/clean_branches.rb +1 -4
- data/lib/git_helper/code_request.rb +95 -0
- data/lib/git_helper/empty_commit.rb +1 -1
- data/lib/git_helper/forget_local_commits.rb +7 -0
- data/lib/git_helper/gitlab_client.rb +0 -1
- data/lib/git_helper/highline_cli.rb +72 -6
- data/lib/git_helper/local_code.rb +124 -0
- data/lib/git_helper/merge_request.rb +57 -126
- data/lib/git_helper/new_branch.rb +2 -11
- data/lib/git_helper/octokit_client.rb +0 -1
- data/lib/git_helper/pull_request.rb +45 -110
- data/lib/git_helper/version.rb +1 -1
- data/spec/git_helper/change_remote_spec.rb +173 -0
- data/spec/git_helper/checkout_default_spec.rb +19 -0
- data/spec/git_helper/clean_branches_spec.rb +19 -0
- data/spec/git_helper/code_request_spec.rb +259 -0
- data/spec/git_helper/empty_commit_spec.rb +19 -0
- data/spec/git_helper/forget_local_commits_spec.rb +19 -0
- data/spec/git_helper/git_config_reader_spec.rb +60 -0
- data/spec/git_helper/gitlab_client_spec.rb +26 -0
- data/spec/git_helper/highline_cli_spec.rb +215 -0
- data/spec/git_helper/local_code_spec.rb +231 -0
- data/spec/git_helper/merge_request_spec.rb +234 -0
- data/spec/git_helper/new_branch_spec.rb +44 -0
- data/spec/git_helper/octokit_client_spec.rb +26 -0
- data/spec/git_helper/pull_request_spec.rb +246 -0
- data/spec/spec_helper.rb +0 -7
- metadata +41 -24
@@ -0,0 +1,259 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'git_helper'
|
3
|
+
|
4
|
+
describe GitHelper::CodeRequest do
|
5
|
+
let(:highline_cli) { double(:highline_cli) }
|
6
|
+
let(:local_code) { double(:local_code, project_name: 'name', branch: 'branch') }
|
7
|
+
let(:process_project) { double(:process_project, create: :created, merge: :merged) }
|
8
|
+
|
9
|
+
subject { GitHelper::CodeRequest.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(highline_cli)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#create' do
|
17
|
+
before do
|
18
|
+
allow(subject).to receive(:base_branch).and_return('base')
|
19
|
+
allow(subject).to receive(:new_code_request_title).and_return('Title')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should call to process the project' do
|
23
|
+
expect(subject).to receive(:process_project).and_return(process_project)
|
24
|
+
subject.create
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should call create' do
|
28
|
+
allow(subject).to receive(:process_project).and_return(process_project)
|
29
|
+
expect(process_project).to receive(:create)
|
30
|
+
subject.create
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should call base_branch and new_code_request_title' do
|
34
|
+
expect(subject).to receive(:base_branch).and_return('base')
|
35
|
+
expect(subject).to receive(:new_code_request_title).and_return('Title')
|
36
|
+
allow(subject).to receive(:process_project).and_return(process_project)
|
37
|
+
allow(process_project).to receive(:create)
|
38
|
+
subject.create
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#merge' do
|
43
|
+
it 'should call to process the project' do
|
44
|
+
expect(subject).to receive(:process_project).and_return(process_project)
|
45
|
+
subject.merge
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should call merge' do
|
49
|
+
allow(subject).to receive(:process_project).and_return(process_project)
|
50
|
+
expect(process_project).to receive(:merge)
|
51
|
+
subject.merge
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#process_project' do
|
56
|
+
it 'should call the local code to see if it is a github or gitlab project' do
|
57
|
+
expect(local_code).to receive(:gitlab_project?).and_return(false)
|
58
|
+
expect(local_code).to receive(:github_repo?).and_return(true)
|
59
|
+
subject.send(:process_project)
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when github and gitlab remotes are found' do
|
63
|
+
it 'should ask for clarification' do
|
64
|
+
allow(local_code).to receive(:gitlab_project?).and_return(true)
|
65
|
+
allow(local_code).to receive(:github_repo?).and_return(true)
|
66
|
+
expect(subject).to receive(:ask_for_clarification)
|
67
|
+
subject.send(:process_project)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'when github' do
|
72
|
+
it 'should call the github_pull_request' do
|
73
|
+
allow(local_code).to receive(:gitlab_project?).and_return(false)
|
74
|
+
allow(local_code).to receive(:github_repo?).and_return(true)
|
75
|
+
expect(subject).to receive(:github_pull_request)
|
76
|
+
subject.send(:process_project)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when gitlab' do
|
81
|
+
it 'should call the gitlab_merge_request' do
|
82
|
+
allow(local_code).to receive(:gitlab_project?).and_return(true)
|
83
|
+
allow(local_code).to receive(:github_repo?).and_return(false)
|
84
|
+
expect(subject).to receive(:gitlab_merge_request)
|
85
|
+
subject.send(:process_project)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'when no github or gitlab remotes are found' do
|
90
|
+
it 'should raise error' do
|
91
|
+
allow(local_code).to receive(:gitlab_project?).and_return(false)
|
92
|
+
allow(local_code).to receive(:github_repo?).and_return(false)
|
93
|
+
expect(subject).to receive(:exit)
|
94
|
+
subject.send(:process_project)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#ask_for_clarification' do
|
100
|
+
it 'should ask the CLI' do
|
101
|
+
expect(highline_cli).to receive(:conflicting_remote_clarification).and_return('github')
|
102
|
+
subject.send(:ask_for_clarification)
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'when response is github' do
|
106
|
+
it 'should return github_pull_request' do
|
107
|
+
allow(highline_cli).to receive(:conflicting_remote_clarification).and_return('github')
|
108
|
+
expect(subject).to receive(:github_pull_request)
|
109
|
+
subject.send(:ask_for_clarification)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should return github_pull_request' do
|
113
|
+
allow(highline_cli).to receive(:conflicting_remote_clarification).and_return('Github')
|
114
|
+
expect(subject).to receive(:github_pull_request)
|
115
|
+
subject.send(:ask_for_clarification)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'when response is gitlab' do
|
120
|
+
it 'should return gitlab_merge_request' do
|
121
|
+
allow(highline_cli).to receive(:conflicting_remote_clarification).and_return('gitlab')
|
122
|
+
expect(subject).to receive(:gitlab_merge_request)
|
123
|
+
subject.send(:ask_for_clarification)
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should return gitlab_merge_request' do
|
127
|
+
allow(highline_cli).to receive(:conflicting_remote_clarification).and_return('Gitlab')
|
128
|
+
expect(subject).to receive(:gitlab_merge_request)
|
129
|
+
subject.send(:ask_for_clarification)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'when response is neither' do
|
134
|
+
it 'should raise an error' do
|
135
|
+
allow(highline_cli).to receive(:conflicting_remote_clarification).and_return('huh?')
|
136
|
+
expect(subject).to receive(:exit)
|
137
|
+
subject.send(:ask_for_clarification)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe '#github_pull_request' do
|
143
|
+
it 'should call the GitHelper::GitHubPullRequest' do
|
144
|
+
expect(GitHelper::GitHubPullRequest).to receive(:new)
|
145
|
+
subject.send(:github_pull_request)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe '#gitlab_merge_request' do
|
150
|
+
it 'should call the GitHelper::GitLabMergeRequest' do
|
151
|
+
expect(GitHelper::GitLabMergeRequest).to receive(:new)
|
152
|
+
subject.send(:gitlab_merge_request)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe '#local_project' do
|
157
|
+
it 'should call the name of the local_code' do
|
158
|
+
expect(local_code).to receive(:project_name)
|
159
|
+
subject.send(:local_project)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#default_branch' do
|
164
|
+
it 'should call the name of the local_code' do
|
165
|
+
expect(local_code).to receive(:default_branch)
|
166
|
+
subject.send(:default_branch)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe '#base_branch' do
|
171
|
+
it 'should call the default branch' do
|
172
|
+
expect(subject).to receive(:default_branch)
|
173
|
+
allow(highline_cli).to receive(:base_branch_default?).at_least(:once)
|
174
|
+
allow(highline_cli).to receive(:base_branch).at_least(:once).and_return('base')
|
175
|
+
subject.send(:base_branch)
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should ask the CLI to ask the user' do
|
179
|
+
allow(subject).to receive(:default_branch)
|
180
|
+
expect(highline_cli).to receive(:base_branch_default?).at_least(:once)
|
181
|
+
allow(highline_cli).to receive(:base_branch).at_least(:once).and_return('base')
|
182
|
+
subject.send(:base_branch)
|
183
|
+
end
|
184
|
+
|
185
|
+
context 'if the user says no' do
|
186
|
+
it "definitely asks for the user's base branch" do
|
187
|
+
allow(subject).to receive(:default_branch)
|
188
|
+
expect(highline_cli).to receive(:base_branch_default?).at_least(:once).and_return(false)
|
189
|
+
expect(highline_cli).to receive(:base_branch).at_least(:once).and_return('base')
|
190
|
+
subject.send(:base_branch)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'if the user says yes' do
|
195
|
+
it "does not ask for the user's base branch" do
|
196
|
+
allow(subject).to receive(:default_branch)
|
197
|
+
expect(highline_cli).to receive(:base_branch_default?).at_least(:once).and_return(true)
|
198
|
+
expect(highline_cli).not_to receive(:base_branch)
|
199
|
+
subject.send(:base_branch)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe '#autogenerated_title' do
|
205
|
+
it 'should generate a title based on the branch' do
|
206
|
+
expect(subject).to receive(:local_branch).and_return('branch')
|
207
|
+
expect(local_code).to receive(:generate_title)
|
208
|
+
subject.send(:autogenerated_title)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe '#new_code_request_title' do
|
213
|
+
it 'should call autogenerated title method' do
|
214
|
+
expect(subject).to receive(:autogenerated_title)
|
215
|
+
allow(highline_cli).to receive(:accept_autogenerated_title?).at_least(:once)
|
216
|
+
allow(highline_cli).to receive(:title).at_least(:once).and_return('Title')
|
217
|
+
subject.send(:new_code_request_title)
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'should ask the CLI to ask the user' do
|
221
|
+
allow(subject).to receive(:autogenerated_title)
|
222
|
+
expect(highline_cli).to receive(:accept_autogenerated_title?).at_least(:once)
|
223
|
+
allow(highline_cli).to receive(:title).at_least(:once).and_return('Title')
|
224
|
+
subject.send(:new_code_request_title)
|
225
|
+
end
|
226
|
+
|
227
|
+
context 'if the user says no' do
|
228
|
+
it "definitely asks for the user's title" do
|
229
|
+
allow(subject).to receive(:autogenerated_title)
|
230
|
+
expect(highline_cli).to receive(:accept_autogenerated_title?).at_least(:once).and_return(false)
|
231
|
+
expect(highline_cli).to receive(:title).at_least(:once).and_return('Title')
|
232
|
+
subject.send(:new_code_request_title)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
context 'if the user says yes to original title' do
|
237
|
+
it "does not ask for the user's chosen title" do
|
238
|
+
allow(subject).to receive(:autogenerated_title)
|
239
|
+
expect(highline_cli).to receive(:accept_autogenerated_title?).at_least(:once).and_return(true)
|
240
|
+
expect(highline_cli).not_to receive(:title)
|
241
|
+
subject.send(:new_code_request_title)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
describe '#local_code' do
|
247
|
+
it 'should call the octokit client' do
|
248
|
+
expect(GitHelper::LocalCode).to receive(:new).and_return(local_code)
|
249
|
+
subject.send(:local_code)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
describe '#cli' do
|
254
|
+
it 'should call the octokit client' do
|
255
|
+
expect(GitHelper::HighlineCli).to receive(:new).and_return(highline_cli)
|
256
|
+
subject.send(:cli)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'git_helper'
|
3
|
+
|
4
|
+
describe GitHelper::EmptyCommit do
|
5
|
+
let(:local_code) { double(:local_code, empty_commit: :commit) }
|
6
|
+
|
7
|
+
subject { GitHelper::EmptyCommit.new }
|
8
|
+
|
9
|
+
it 'should call GitHelper::LocalCode' do
|
10
|
+
expect(GitHelper::LocalCode).to receive(:new).and_return(local_code)
|
11
|
+
subject.execute
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should call the empty_commit method from the local code class' do
|
15
|
+
allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
|
16
|
+
expect(local_code).to receive(:empty_commit)
|
17
|
+
subject.execute
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'git_helper'
|
3
|
+
|
4
|
+
describe GitHelper::ForgetLocalCommits do
|
5
|
+
let(:local_code) { double(:local_code, forget_local_commits: :commit) }
|
6
|
+
|
7
|
+
subject { GitHelper::ForgetLocalCommits.new }
|
8
|
+
|
9
|
+
it 'should call GitHelper::LocalCode' do
|
10
|
+
expect(GitHelper::LocalCode).to receive(:new).and_return(local_code)
|
11
|
+
subject.execute
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should call the forget_local_commits method from the local code class' do
|
15
|
+
allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
|
16
|
+
expect(local_code).to receive(:forget_local_commits)
|
17
|
+
subject.execute
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'git_helper'
|
3
|
+
|
4
|
+
describe GitHelper::GitConfigReader do
|
5
|
+
let(:github_token) { '1234ASDF1234ASDF' }
|
6
|
+
let(:gitlab_token) { 'ASDF123ASDF1234' }
|
7
|
+
let(:config_file) {
|
8
|
+
{
|
9
|
+
github_user: 'github-user-name',
|
10
|
+
github_token: github_token,
|
11
|
+
gitlab_user: 'gitlab-user-name',
|
12
|
+
gitlab_token: gitlab_token
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
subject { GitHelper::GitConfigReader.new }
|
17
|
+
|
18
|
+
describe '#gitlab_token' do
|
19
|
+
it 'should locate the gitlab_token' do
|
20
|
+
expect(subject).to receive(:config_file).and_return(config_file)
|
21
|
+
expect(subject.gitlab_token).to eq(gitlab_token)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should call the config file' do
|
25
|
+
expect(subject).to receive(:config_file).and_return(config_file)
|
26
|
+
subject.gitlab_token
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#github_token' do
|
31
|
+
it 'should locate the github_token' do
|
32
|
+
expect(subject).to receive(:config_file).and_return(config_file)
|
33
|
+
expect(subject.github_token).to eq(github_token)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should call the config file' do
|
37
|
+
expect(subject).to receive(:config_file).and_return(config_file)
|
38
|
+
subject.github_token
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#config_file' do
|
43
|
+
it 'should yaml load the file path' do
|
44
|
+
expect(YAML).to receive(:load_file)
|
45
|
+
subject.send(:config_file)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#git_config_file_path' do
|
50
|
+
it 'should look in the current directory' do
|
51
|
+
expect(Dir).to receive(:pwd).and_return('/Users/firstnamelastname/path/to/git_helper')
|
52
|
+
subject.send(:git_config_file_path)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should return the base path with the git config file at the end' do
|
56
|
+
allow(Dir).to receive(:pwd).and_return('/Users/firstnamelastname/path/to/git_helper')
|
57
|
+
expect(subject.send(:git_config_file_path)).to eq('/Users/firstnamelastname/.git_config.yml')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'git_helper'
|
3
|
+
|
4
|
+
describe GitHelper::GitLabClient do
|
5
|
+
let(:git_config_reader) { double(:git_config_reader, gitlab_token: :token) }
|
6
|
+
|
7
|
+
subject { GitHelper::GitLabClient.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(Gitlab).to receive(:client)
|
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,215 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'git_helper'
|
3
|
+
|
4
|
+
describe GitHelper::HighlineCli do
|
5
|
+
let(:response) { double(:response, readline: true, to_i: 5) }
|
6
|
+
let(:highline_client) { double(:highline_cli, ask: response) }
|
7
|
+
|
8
|
+
subject { GitHelper::HighlineCli.new }
|
9
|
+
|
10
|
+
before do
|
11
|
+
allow(HighLine).to receive(:new).and_return(highline_client)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#new_branch_name' do
|
15
|
+
it "should ask the subject's 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 subject's ask method" do
|
27
|
+
expect(subject).to receive(:ask).and_return('y')
|
28
|
+
subject.process_directory_remotes?('directory')
|
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?('directory'))
|
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?('directory')).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?('directory')).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?('directory')).to eq(true)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#conflicting_remote_clarification' do
|
53
|
+
it "should ask the subject's 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 subject's 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 subject's 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
|
+
it "should ask the subject's ask method" do
|
87
|
+
expect(subject).to receive(:ask).with('Example Request ID?')
|
88
|
+
subject.code_request_id('Example')
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should come out a string' do
|
92
|
+
expect(subject.code_request_id('Example')).to be_a(String)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#accept_autogenerated_title' do
|
97
|
+
it "should ask the subject's ask method" do
|
98
|
+
expect(subject).to receive(:ask).and_return('y')
|
99
|
+
subject.accept_autogenerated_title?('Title Example')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should be a boolean at the end' do
|
103
|
+
allow(subject).to receive(:ask).and_return('y')
|
104
|
+
expect([true, false]).to include(subject.accept_autogenerated_title?('Title Example'))
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should come out as a true boolean if somebody responds y' do
|
108
|
+
allow(subject).to receive(:ask).and_return('y')
|
109
|
+
expect(subject.accept_autogenerated_title?('Title Example')).to eq(true)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should come out as a true boolean if somebody responds n' do
|
113
|
+
allow(subject).to receive(:ask).and_return('n')
|
114
|
+
expect(subject.accept_autogenerated_title?('Title Example')).to eq(false)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should come out as a true boolean if somebody responds yes' do
|
118
|
+
allow(subject).to receive(:ask).and_return('yes')
|
119
|
+
expect(subject.accept_autogenerated_title?('Title Example')).to eq(true)
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should come out as a false boolean if somebody responds no' do
|
123
|
+
allow(subject).to receive(:ask).and_return('no')
|
124
|
+
expect(subject.accept_autogenerated_title?('Title Example')).to eq(false)
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should come out as true if somebody presses enter' do
|
128
|
+
allow(subject).to receive(:ask).and_return('')
|
129
|
+
expect(subject.accept_autogenerated_title?('Title Example')).to eq(true)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '#base_branch_default' do
|
134
|
+
it "should ask the subject's ask method" do
|
135
|
+
expect(subject).to receive(:ask).and_return('y')
|
136
|
+
subject.base_branch_default?('default_branch')
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should be a boolean at the end' do
|
140
|
+
allow(subject).to receive(:ask).and_return('y')
|
141
|
+
expect([true, false]).to include(subject.base_branch_default?('default_branch'))
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'should come out as a true boolean if somebody responds y' do
|
145
|
+
allow(subject).to receive(:ask).and_return('y')
|
146
|
+
expect(subject.base_branch_default?('default_branch')).to eq(true)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should come out as a true boolean if somebody responds n' do
|
150
|
+
allow(subject).to receive(:ask).and_return('n')
|
151
|
+
expect(subject.base_branch_default?('default_branch')).to eq(false)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should come out as a true boolean if somebody responds yes' do
|
155
|
+
allow(subject).to receive(:ask).and_return('yes')
|
156
|
+
expect(subject.base_branch_default?('default_branch')).to eq(true)
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'should come out as a false boolean if somebody responds no' do
|
160
|
+
allow(subject).to receive(:ask).and_return('no')
|
161
|
+
expect(subject.base_branch_default?('default_branch')).to eq(false)
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should come out as true if somebody presses enter' do
|
165
|
+
allow(subject).to receive(:ask).and_return('')
|
166
|
+
expect(subject.base_branch_default?('default_branch')).to eq(true)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe '#merge_method' do
|
171
|
+
it "should ask the subject's ask_options method" do
|
172
|
+
expect(subject).to receive(:ask_options).and_return(3)
|
173
|
+
subject.merge_method(['1', '2', '3'])
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'should return a string' do
|
177
|
+
allow(subject).to receive(:ask_options).and_return(2)
|
178
|
+
expect(subject.merge_method(['1', '2', '3'])).to be_a(String)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe '#template_to_apply' do
|
183
|
+
it "should ask the subject's ask_options method" do
|
184
|
+
expect(subject).to receive(:ask_options).and_return(3)
|
185
|
+
subject.template_to_apply(['option1', 'option2', 'option3'], 'example type')
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should return a string' do
|
189
|
+
allow(subject).to receive(:ask_options).and_return(3)
|
190
|
+
expect(subject.template_to_apply(['option1', 'option2', 'option3'], 'example type')).to eq('None')
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
describe '#ask' do
|
195
|
+
it 'should ask the highline client ask'do
|
196
|
+
expect(highline_client).to receive(:ask)
|
197
|
+
subject.send(:ask, 'prompt goes here')
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'should return a string' do
|
201
|
+
expect(subject.send(:ask, 'prompt goes here')).to be_a(String)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe '#ask_options' do
|
206
|
+
it 'should ask the highline client ask'do
|
207
|
+
expect(highline_client).to receive(:ask)
|
208
|
+
subject.send(:ask_options, 'prompt goes here', ['1', '2', '3'])
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'should return an integer' do
|
212
|
+
expect(subject.send(:ask_options, 'prompt goes here', ['1', '2', '3'])).to be_a(Integer)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|