git_helper 3.0.1 → 3.2.1
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 +33 -23
- data/Guardfile +2 -2
- data/README.md +26 -13
- data/Rakefile +1 -1
- data/bin/git-helper +12 -16
- data/lib/git_helper.rb +6 -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 +0 -2
- data/lib/git_helper/gitlab_client.rb +0 -2
- data/lib/git_helper/highline_cli.rb +12 -70
- data/lib/git_helper/local_code.rb +9 -9
- data/lib/git_helper/merge_request.rb +5 -5
- data/lib/git_helper/new_branch.rb +1 -1
- data/lib/git_helper/octokit_client.rb +0 -2
- data/lib/git_helper/pull_request.rb +4 -4
- data/lib/git_helper/version.rb +1 -1
- data/plugins.zip +0 -0
- data/spec/git_helper/change_remote_spec.rb +19 -16
- data/spec/git_helper/code_request_spec.rb +37 -34
- data/spec/git_helper/git_config_reader_spec.rb +9 -7
- data/spec/git_helper/highline_cli_spec.rb +18 -182
- data/spec/git_helper/local_code_spec.rb +62 -26
- data/spec/git_helper/merge_request_spec.rb +58 -41
- data/spec/git_helper/new_branch_spec.rb +3 -2
- data/spec/git_helper/pull_request_spec.rb +46 -38
- data/spec/spec_helper.rb +2 -0
- metadata +27 -14
@@ -84,10 +84,10 @@ module GitHelper
|
|
84
84
|
|
85
85
|
unless mr_template_options.empty?
|
86
86
|
if mr_template_options.count == 1
|
87
|
-
apply_single_template = cli.
|
87
|
+
apply_single_template = cli.ask_yes_no("Apply the merge request template from #{mr_template_options.first}? (y/n)")
|
88
88
|
@template_name_to_apply = mr_template_options.first if apply_single_template
|
89
89
|
else
|
90
|
-
response = cli.
|
90
|
+
response = cli.ask_options("Which merge request template should be applied?", mr_template_options << 'None')
|
91
91
|
@template_name_to_apply = response unless response == 'None'
|
92
92
|
end
|
93
93
|
end
|
@@ -104,15 +104,15 @@ module GitHelper
|
|
104
104
|
end
|
105
105
|
|
106
106
|
private def mr_id
|
107
|
-
@mr_id ||= cli.
|
107
|
+
@mr_id ||= cli.ask('Merge Request ID?')
|
108
108
|
end
|
109
109
|
|
110
110
|
private def squash_merge_request
|
111
|
-
@squash_merge_request ||= cli.
|
111
|
+
@squash_merge_request ||= cli.ask_yes_no('Squash merge request? (y/n)')
|
112
112
|
end
|
113
113
|
|
114
114
|
private def remove_source_branch
|
115
|
-
@remove_source_branch ||= existing_project.remove_source_branch_after_merge || cli.
|
115
|
+
@remove_source_branch ||= existing_project.remove_source_branch_after_merge || cli.ask_yes_no('Remove source branch after merging? (y/n)')
|
116
116
|
end
|
117
117
|
|
118
118
|
private def existing_project
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module GitHelper
|
2
2
|
class NewBranch
|
3
3
|
def execute(new_branch_name = nil)
|
4
|
-
branch_name = new_branch_name || GitHelper::HighlineCli.new.
|
4
|
+
branch_name = new_branch_name || GitHelper::HighlineCli.new.ask('New branch name?')
|
5
5
|
puts "Attempting to create a new branch: #{branch_name}"
|
6
6
|
GitHelper::LocalCode.new.new_branch(branch_name)
|
7
7
|
end
|
@@ -81,10 +81,10 @@ module GitHelper
|
|
81
81
|
|
82
82
|
unless pr_template_options.empty?
|
83
83
|
if pr_template_options.count == 1
|
84
|
-
apply_single_template = cli.
|
84
|
+
apply_single_template = cli.ask_yes_no("Apply the pull request template from #{pr_template_options.first}? (y/n)")
|
85
85
|
@template_name_to_apply = pr_template_options.first if apply_single_template
|
86
86
|
else
|
87
|
-
response = cli.
|
87
|
+
response = cli.ask_options("Which pull request template should be applied?", pr_template_options << 'None')
|
88
88
|
@template_name_to_apply = response unless response == 'None'
|
89
89
|
end
|
90
90
|
end
|
@@ -101,11 +101,11 @@ module GitHelper
|
|
101
101
|
end
|
102
102
|
|
103
103
|
private def pr_id
|
104
|
-
@pr_id ||= cli.
|
104
|
+
@pr_id ||= cli.ask('Pull Request ID?')
|
105
105
|
end
|
106
106
|
|
107
107
|
private def merge_method
|
108
|
-
@merge_method ||= merge_options.length == 1 ? merge_options.first : cli.
|
108
|
+
@merge_method ||= merge_options.length == 1 ? merge_options.first : cli.ask_options('Merge method?', merge_options)
|
109
109
|
end
|
110
110
|
|
111
111
|
private def merge_options
|
data/lib/git_helper/version.rb
CHANGED
data/plugins.zip
CHANGED
Binary file
|
@@ -2,35 +2,38 @@ require 'spec_helper'
|
|
2
2
|
require 'git_helper'
|
3
3
|
|
4
4
|
describe GitHelper::ChangeRemote do
|
5
|
-
let(:remote1) {
|
5
|
+
let(:remote1) { "git@github.com:#{old_owner}/#{project}.git" }
|
6
|
+
let(:project) { Faker::Lorem.word }
|
7
|
+
let(:cli) { double(:highline_cli, ask_yes_no: true) }
|
8
|
+
let(:old_owner) { Faker::Internet.username }
|
9
|
+
let(:new_owner) { Faker::Internet.username }
|
10
|
+
let(:directory_entries) { [ '.', '..', project, Faker::Lorem.word, Faker::Lorem.word ] }
|
11
|
+
|
6
12
|
let(:local_code) do
|
7
13
|
double(:local_code,
|
8
14
|
remotes: [remote1],
|
9
|
-
remote_name:
|
15
|
+
remote_name: Faker::Lorem.word,
|
10
16
|
ssh_remote?: true,
|
11
17
|
https_remote?: false,
|
12
|
-
remote_project:
|
18
|
+
remote_project: project,
|
13
19
|
remote_source: 'github.com',
|
14
20
|
change_remote: true
|
15
21
|
)
|
16
22
|
end
|
17
|
-
let(:cli) { double(:highline_cli, process_directory_remotes?: true) }
|
18
|
-
let(:old_owner) { 'github-username-old' }
|
19
|
-
let(:new_owner) { 'github-username-new' }
|
20
|
-
let(:directory_entries) { [ '.', '..', 'project-1', 'project-2', 'project-3' ] }
|
21
23
|
|
22
24
|
subject { GitHelper::ChangeRemote.new(old_owner, new_owner) }
|
23
25
|
|
24
26
|
before do
|
25
27
|
allow(GitHelper::HighlineCli).to receive(:new).and_return(cli)
|
26
28
|
allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
|
29
|
+
allow(subject).to receive(:puts)
|
27
30
|
end
|
28
31
|
|
29
32
|
describe '#execute' do
|
30
33
|
before do
|
31
|
-
allow(Dir).to receive(:pwd).and_return(
|
34
|
+
allow(Dir).to receive(:pwd).and_return("/Users/#{Faker::Name.first_name}/#{project}")
|
32
35
|
allow(Dir).to receive(:entries).and_return(directory_entries)
|
33
|
-
allow(File).to receive(:join).and_return(
|
36
|
+
allow(File).to receive(:join).and_return("/Users/#{Faker::Name.first_name}/#{project}/#{Faker::Lorem.word}")
|
34
37
|
allow(File).to receive(:directory?).and_return(true)
|
35
38
|
allow(subject).to receive(:process_dir)
|
36
39
|
end
|
@@ -59,22 +62,22 @@ describe GitHelper::ChangeRemote do
|
|
59
62
|
it 'should definitely look in the file structure' do
|
60
63
|
expect(Dir).to receive(:chdir)
|
61
64
|
expect(File).to receive(:exist?)
|
62
|
-
subject.send(:process_dir,
|
65
|
+
subject.send(:process_dir, "/Users/#{Faker::Name.first_name}/#{project}", "/Users/#{Faker::Name.first_name}/#{project}/#{Faker::Lorem.word}")
|
63
66
|
end
|
64
67
|
|
65
68
|
context 'when the user says to process the directory' do
|
66
69
|
it 'should call to process the git repository at least once' do
|
67
70
|
expect(subject).to receive(:process_git_repository).at_least(:once)
|
68
|
-
subject.send(:process_dir,
|
71
|
+
subject.send(:process_dir, "/Users/#{Faker::Name.first_name}/#{project}", "/Users/#{Faker::Name.first_name}/#{project}/#{Faker::Lorem.word}")
|
69
72
|
end
|
70
73
|
end
|
71
74
|
|
72
75
|
context 'when the user says not to process the directory' do
|
73
|
-
let(:cli) { double(:highline_cli,
|
76
|
+
let(:cli) { double(:highline_cli, ask_yes_no: false) }
|
74
77
|
|
75
78
|
it 'should not call to process the directory' do
|
76
79
|
expect(subject).not_to receive(:process_git_repository)
|
77
|
-
subject.send(:process_dir,
|
80
|
+
subject.send(:process_dir, "/Users/#{Faker::Name.first_name}/#{project}", "/Users/#{Faker::Name.first_name}/#{project}/#{Faker::Lorem.word}")
|
78
81
|
end
|
79
82
|
end
|
80
83
|
end
|
@@ -97,7 +100,7 @@ describe GitHelper::ChangeRemote do
|
|
97
100
|
end
|
98
101
|
|
99
102
|
context 'when the remote does not include the old owner' do
|
100
|
-
let(:remote1) {
|
103
|
+
let(:remote1) { "git@github.com:#{new_owner}/#{project}.git" }
|
101
104
|
|
102
105
|
it 'should not call to process the remote' do
|
103
106
|
expect(subject).not_to receive(:process_remote)
|
@@ -136,10 +139,10 @@ describe GitHelper::ChangeRemote do
|
|
136
139
|
let(:local_code) do
|
137
140
|
double(:local_code,
|
138
141
|
remotes: [remote1],
|
139
|
-
remote_name:
|
142
|
+
remote_name: Faker::Lorem.word,
|
140
143
|
ssh_remote?: false,
|
141
144
|
https_remote?: false,
|
142
|
-
remote_project:
|
145
|
+
remote_project: project,
|
143
146
|
remote_source: 'github.com',
|
144
147
|
change_remote: true
|
145
148
|
)
|
@@ -3,20 +3,23 @@ require 'git_helper'
|
|
3
3
|
|
4
4
|
describe GitHelper::CodeRequest do
|
5
5
|
let(:highline_cli) { double(:highline_cli) }
|
6
|
-
let(:local_code) { double(:local_code, project_name:
|
6
|
+
let(:local_code) { double(:local_code, project_name: Faker::Lorem.word, branch: Faker::Lorem.word) }
|
7
7
|
let(:process_project) { double(:process_project, create: :created, merge: :merged) }
|
8
|
+
let(:base_branch) { Faker::Lorem.word }
|
9
|
+
let(:title) { Faker::Lorem.sentence }
|
8
10
|
|
9
11
|
subject { GitHelper::CodeRequest.new }
|
10
12
|
|
11
13
|
before do
|
12
14
|
allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
|
13
15
|
allow(GitHelper::HighlineCli).to receive(:new).and_return(highline_cli)
|
16
|
+
allow(subject).to receive(:puts)
|
14
17
|
end
|
15
18
|
|
16
19
|
describe '#create' do
|
17
20
|
before do
|
18
|
-
allow(subject).to receive(:base_branch).and_return(
|
19
|
-
allow(subject).to receive(:new_code_request_title).and_return(
|
21
|
+
allow(subject).to receive(:base_branch).and_return(base_branch)
|
22
|
+
allow(subject).to receive(:new_code_request_title).and_return(title)
|
20
23
|
end
|
21
24
|
|
22
25
|
it 'should call to process the project' do
|
@@ -31,8 +34,8 @@ describe GitHelper::CodeRequest do
|
|
31
34
|
end
|
32
35
|
|
33
36
|
it 'should call base_branch and new_code_request_title' do
|
34
|
-
expect(subject).to receive(:base_branch).and_return(
|
35
|
-
expect(subject).to receive(:new_code_request_title).and_return(
|
37
|
+
expect(subject).to receive(:base_branch).and_return(base_branch)
|
38
|
+
expect(subject).to receive(:new_code_request_title).and_return(title)
|
36
39
|
allow(subject).to receive(:process_project).and_return(process_project)
|
37
40
|
allow(process_project).to receive(:create)
|
38
41
|
subject.create
|
@@ -98,19 +101,19 @@ describe GitHelper::CodeRequest do
|
|
98
101
|
|
99
102
|
describe '#ask_for_clarification' do
|
100
103
|
it 'should ask the CLI' do
|
101
|
-
expect(highline_cli).to receive(:
|
104
|
+
expect(highline_cli).to receive(:ask).and_return('github')
|
102
105
|
subject.send(:ask_for_clarification)
|
103
106
|
end
|
104
107
|
|
105
108
|
context 'when response is github' do
|
106
109
|
it 'should return github_pull_request' do
|
107
|
-
allow(highline_cli).to receive(:
|
110
|
+
allow(highline_cli).to receive(:ask).and_return('github')
|
108
111
|
expect(subject).to receive(:github_pull_request)
|
109
112
|
subject.send(:ask_for_clarification)
|
110
113
|
end
|
111
114
|
|
112
115
|
it 'should return github_pull_request' do
|
113
|
-
allow(highline_cli).to receive(:
|
116
|
+
allow(highline_cli).to receive(:ask).and_return('Github')
|
114
117
|
expect(subject).to receive(:github_pull_request)
|
115
118
|
subject.send(:ask_for_clarification)
|
116
119
|
end
|
@@ -118,13 +121,13 @@ describe GitHelper::CodeRequest do
|
|
118
121
|
|
119
122
|
context 'when response is gitlab' do
|
120
123
|
it 'should return gitlab_merge_request' do
|
121
|
-
allow(highline_cli).to receive(:
|
124
|
+
allow(highline_cli).to receive(:ask).and_return('gitlab')
|
122
125
|
expect(subject).to receive(:gitlab_merge_request)
|
123
126
|
subject.send(:ask_for_clarification)
|
124
127
|
end
|
125
128
|
|
126
129
|
it 'should return gitlab_merge_request' do
|
127
|
-
allow(highline_cli).to receive(:
|
130
|
+
allow(highline_cli).to receive(:ask).and_return('Gitlab')
|
128
131
|
expect(subject).to receive(:gitlab_merge_request)
|
129
132
|
subject.send(:ask_for_clarification)
|
130
133
|
end
|
@@ -132,7 +135,7 @@ describe GitHelper::CodeRequest do
|
|
132
135
|
|
133
136
|
context 'when response is neither' do
|
134
137
|
it 'should raise an error' do
|
135
|
-
allow(highline_cli).to receive(:
|
138
|
+
allow(highline_cli).to receive(:ask).and_return(Faker::Lorem.word)
|
136
139
|
expect(subject).to receive(:exit)
|
137
140
|
subject.send(:ask_for_clarification)
|
138
141
|
end
|
@@ -170,31 +173,31 @@ describe GitHelper::CodeRequest do
|
|
170
173
|
describe '#base_branch' do
|
171
174
|
it 'should call the default branch' do
|
172
175
|
expect(subject).to receive(:default_branch)
|
173
|
-
allow(highline_cli).to receive(:
|
174
|
-
allow(highline_cli).to receive(:
|
176
|
+
allow(highline_cli).to receive(:ask_yes_no).at_least(:once)
|
177
|
+
allow(highline_cli).to receive(:ask).at_least(:once).and_return(base_branch)
|
175
178
|
subject.send(:base_branch)
|
176
179
|
end
|
177
180
|
|
178
181
|
it 'should ask the CLI to ask the user' do
|
179
182
|
allow(subject).to receive(:default_branch)
|
180
|
-
expect(highline_cli).to receive(:
|
181
|
-
allow(highline_cli).to receive(:
|
183
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once)
|
184
|
+
allow(highline_cli).to receive(:ask).at_least(:once).and_return(base_branch)
|
182
185
|
subject.send(:base_branch)
|
183
186
|
end
|
184
187
|
|
185
188
|
context 'if the user says no' do
|
186
|
-
it
|
189
|
+
it 'definitely asks for the users base branch' do
|
187
190
|
allow(subject).to receive(:default_branch)
|
188
|
-
expect(highline_cli).to receive(:
|
189
|
-
expect(highline_cli).to receive(:
|
191
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(false)
|
192
|
+
expect(highline_cli).to receive(:ask).at_least(:once).and_return(base_branch)
|
190
193
|
subject.send(:base_branch)
|
191
194
|
end
|
192
195
|
end
|
193
196
|
|
194
197
|
context 'if the user says yes' do
|
195
|
-
it
|
198
|
+
it 'does not ask for the users base branch' do
|
196
199
|
allow(subject).to receive(:default_branch)
|
197
|
-
expect(highline_cli).to receive(:
|
200
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(true)
|
198
201
|
expect(highline_cli).not_to receive(:base_branch)
|
199
202
|
subject.send(:base_branch)
|
200
203
|
end
|
@@ -203,7 +206,7 @@ describe GitHelper::CodeRequest do
|
|
203
206
|
|
204
207
|
describe '#autogenerated_title' do
|
205
208
|
it 'should generate a title based on the branch' do
|
206
|
-
expect(subject).to receive(:local_branch).and_return(
|
209
|
+
expect(subject).to receive(:local_branch).and_return(Faker::Lorem.word)
|
207
210
|
expect(local_code).to receive(:generate_title)
|
208
211
|
subject.send(:autogenerated_title)
|
209
212
|
end
|
@@ -212,32 +215,32 @@ describe GitHelper::CodeRequest do
|
|
212
215
|
describe '#new_code_request_title' do
|
213
216
|
it 'should call autogenerated title method' do
|
214
217
|
expect(subject).to receive(:autogenerated_title)
|
215
|
-
allow(highline_cli).to receive(:
|
216
|
-
allow(highline_cli).to receive(:
|
218
|
+
allow(highline_cli).to receive(:ask_yes_no).at_least(:once)
|
219
|
+
allow(highline_cli).to receive(:ask).at_least(:once).and_return(title)
|
217
220
|
subject.send(:new_code_request_title)
|
218
221
|
end
|
219
222
|
|
220
223
|
it 'should ask the CLI to ask the user' do
|
221
|
-
allow(subject).to receive(:autogenerated_title)
|
222
|
-
expect(highline_cli).to receive(:
|
223
|
-
allow(highline_cli).to receive(:
|
224
|
+
allow(subject).to receive(:autogenerated_title).and_return(Faker::Lorem.sentence)
|
225
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once)
|
226
|
+
allow(highline_cli).to receive(:ask).at_least(:once).and_return(title)
|
224
227
|
subject.send(:new_code_request_title)
|
225
228
|
end
|
226
229
|
|
227
230
|
context 'if the user says no' do
|
228
|
-
it
|
229
|
-
allow(subject).to receive(:autogenerated_title)
|
230
|
-
expect(highline_cli).to receive(:
|
231
|
-
expect(highline_cli).to receive(:
|
231
|
+
it 'definitely asks for the users title' do
|
232
|
+
allow(subject).to receive(:autogenerated_title).and_return(Faker::Lorem.sentence)
|
233
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(false)
|
234
|
+
expect(highline_cli).to receive(:ask).at_least(:once).and_return(title)
|
232
235
|
subject.send(:new_code_request_title)
|
233
236
|
end
|
234
237
|
end
|
235
238
|
|
236
239
|
context 'if the user says yes to original title' do
|
237
|
-
it
|
238
|
-
allow(subject).to receive(:autogenerated_title)
|
239
|
-
expect(highline_cli).to receive(:
|
240
|
-
expect(highline_cli).not_to receive(:
|
240
|
+
it 'does not ask for the users chosen title' do
|
241
|
+
allow(subject).to receive(:autogenerated_title).and_return(Faker::Lorem.sentence)
|
242
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(true)
|
243
|
+
expect(highline_cli).not_to receive(:ask)
|
241
244
|
subject.send(:new_code_request_title)
|
242
245
|
end
|
243
246
|
end
|
@@ -2,13 +2,14 @@ require 'spec_helper'
|
|
2
2
|
require 'git_helper'
|
3
3
|
|
4
4
|
describe GitHelper::GitConfigReader do
|
5
|
-
let(:github_token) {
|
6
|
-
let(:gitlab_token) {
|
5
|
+
let(:github_token) { Faker::Internet.password(max_length: 10) }
|
6
|
+
let(:gitlab_token) { Faker::Internet.password(max_length: 10) }
|
7
|
+
|
7
8
|
let(:config_file) {
|
8
9
|
{
|
9
|
-
github_user:
|
10
|
+
github_user: Faker::Internet.username,
|
10
11
|
github_token: github_token,
|
11
|
-
gitlab_user:
|
12
|
+
gitlab_user: Faker::Internet.username,
|
12
13
|
gitlab_token: gitlab_token
|
13
14
|
}
|
14
15
|
}
|
@@ -48,13 +49,14 @@ describe GitHelper::GitConfigReader do
|
|
48
49
|
|
49
50
|
describe '#git_config_file_path' do
|
50
51
|
it 'should look in the current directory' do
|
51
|
-
expect(Dir).to receive(:pwd).and_return(
|
52
|
+
expect(Dir).to receive(:pwd).and_return("/Users/#{Faker::Name.first_name}/#{Faker::Lorem.word}")
|
52
53
|
subject.send(:git_config_file_path)
|
53
54
|
end
|
54
55
|
|
55
56
|
it 'should return the base path with the git config file at the end' do
|
56
|
-
|
57
|
-
|
57
|
+
user = Faker::Name.first_name
|
58
|
+
allow(Dir).to receive(:pwd).and_return("/Users/#{user}/#{Faker::Lorem.word}")
|
59
|
+
expect(subject.send(:git_config_file_path)).to eq("/Users/#{user}/.git_helper/config.yml")
|
58
60
|
end
|
59
61
|
end
|
60
62
|
end
|
@@ -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,205 +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
|
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 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')
|
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)
|
186
18
|
end
|
187
19
|
|
188
20
|
it 'should return a string' do
|
189
|
-
|
190
|
-
expect(subject.template_to_apply(['option1', 'option2', 'option3'], 'example type')).to eq('None')
|
21
|
+
expect(subject.ask(Faker::Lorem.sentence)).to be_a(String)
|
191
22
|
end
|
192
23
|
end
|
193
24
|
|
194
|
-
describe '#
|
25
|
+
describe '#ask_yes_no' do
|
195
26
|
it 'should ask the highline client ask'do
|
196
27
|
expect(highline_client).to receive(:ask)
|
197
|
-
subject.
|
28
|
+
subject.ask_yes_no(Faker::Lorem.sentence)
|
198
29
|
end
|
199
30
|
|
200
|
-
it 'should return a
|
201
|
-
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
|
202
38
|
end
|
203
39
|
end
|
204
40
|
|
205
41
|
describe '#ask_options' do
|
206
42
|
it 'should ask the highline client ask'do
|
207
43
|
expect(highline_client).to receive(:ask)
|
208
|
-
subject.
|
44
|
+
subject.ask_options(Faker::Lorem.sentence, ['one', 'two', 'three'])
|
209
45
|
end
|
210
46
|
|
211
|
-
it 'should return
|
212
|
-
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)
|
213
49
|
end
|
214
50
|
end
|
215
51
|
end
|