git_helper 3.2.0 → 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 +111 -0
- data/lib/git_helper/change_remote.rb +1 -1
- data/lib/git_helper/code_request.rb +6 -5
- 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/version.rb +1 -1
- data/spec/git_helper/change_remote_spec.rb +2 -2
- data/spec/git_helper/code_request_spec.rb +24 -24
- 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
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b3f63c9e4283a7e005a3f6ca7f29e7721e474ec06ebebecd1dcda8f63f841450
|
|
4
|
+
data.tar.gz: 2ec89ecd8513c12f9434aa9c03f7568522b84d3c282e62e09670aa15a63fef95
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bce1b9c25dc1ad30c8434a0e252bdc95f8864fcd29e2c02e712dffb4fe63aaa063fa6a72d9cc27a91c06784758fd6499f9aaa21f62ea57d7b7b81522558112a4
|
|
7
|
+
data.tar.gz: 572c484112dbdcfbb2da9ad8c25add8fd56baa3c652931715a46d9355780e3535e226afc3a83d2f57a6815f78df6fba7c8f47e97990801608bb9653ef3c961c2
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
git_helper (3.2.0)
|
|
5
|
+
gitlab (~> 4.16)
|
|
6
|
+
gli (~> 2.13)
|
|
7
|
+
highline (~> 2.0)
|
|
8
|
+
octokit (~> 4.18)
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
addressable (2.7.0)
|
|
14
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
15
|
+
coderay (1.1.3)
|
|
16
|
+
concurrent-ruby (1.1.7)
|
|
17
|
+
diff-lcs (1.4.4)
|
|
18
|
+
faker (2.15.1)
|
|
19
|
+
i18n (>= 1.6, < 2)
|
|
20
|
+
faraday (1.3.0)
|
|
21
|
+
faraday-net_http (~> 1.0)
|
|
22
|
+
multipart-post (>= 1.2, < 3)
|
|
23
|
+
ruby2_keywords
|
|
24
|
+
faraday-net_http (1.0.0)
|
|
25
|
+
ffi (1.14.2)
|
|
26
|
+
formatador (0.2.5)
|
|
27
|
+
gitlab (4.17.0)
|
|
28
|
+
httparty (~> 0.18)
|
|
29
|
+
terminal-table (~> 1.5, >= 1.5.1)
|
|
30
|
+
gli (2.19.2)
|
|
31
|
+
guard (2.16.2)
|
|
32
|
+
formatador (>= 0.2.4)
|
|
33
|
+
listen (>= 2.7, < 4.0)
|
|
34
|
+
lumberjack (>= 1.0.12, < 2.0)
|
|
35
|
+
nenv (~> 0.1)
|
|
36
|
+
notiffany (~> 0.0)
|
|
37
|
+
pry (>= 0.9.12)
|
|
38
|
+
shellany (~> 0.0)
|
|
39
|
+
thor (>= 0.18.1)
|
|
40
|
+
guard-compat (1.2.1)
|
|
41
|
+
guard-rspec (4.7.3)
|
|
42
|
+
guard (~> 2.1)
|
|
43
|
+
guard-compat (~> 1.1)
|
|
44
|
+
rspec (>= 2.99.0, < 4.0)
|
|
45
|
+
highline (2.0.3)
|
|
46
|
+
httparty (0.18.1)
|
|
47
|
+
mime-types (~> 3.0)
|
|
48
|
+
multi_xml (>= 0.5.2)
|
|
49
|
+
i18n (1.8.7)
|
|
50
|
+
concurrent-ruby (~> 1.0)
|
|
51
|
+
listen (3.4.1)
|
|
52
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
53
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
54
|
+
lumberjack (1.2.8)
|
|
55
|
+
method_source (1.0.0)
|
|
56
|
+
mime-types (3.3.1)
|
|
57
|
+
mime-types-data (~> 3.2015)
|
|
58
|
+
mime-types-data (3.2020.1104)
|
|
59
|
+
multi_xml (0.6.0)
|
|
60
|
+
multipart-post (2.1.1)
|
|
61
|
+
nenv (0.3.0)
|
|
62
|
+
notiffany (0.1.3)
|
|
63
|
+
nenv (~> 0.1)
|
|
64
|
+
shellany (~> 0.0)
|
|
65
|
+
octokit (4.20.0)
|
|
66
|
+
faraday (>= 0.9)
|
|
67
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
|
68
|
+
pry (0.13.1)
|
|
69
|
+
coderay (~> 1.1)
|
|
70
|
+
method_source (~> 1.0)
|
|
71
|
+
public_suffix (4.0.6)
|
|
72
|
+
rake (13.0.3)
|
|
73
|
+
rb-fsevent (0.10.4)
|
|
74
|
+
rb-inotify (0.10.1)
|
|
75
|
+
ffi (~> 1.0)
|
|
76
|
+
rspec (3.10.0)
|
|
77
|
+
rspec-core (~> 3.10.0)
|
|
78
|
+
rspec-expectations (~> 3.10.0)
|
|
79
|
+
rspec-mocks (~> 3.10.0)
|
|
80
|
+
rspec-core (3.10.1)
|
|
81
|
+
rspec-support (~> 3.10.0)
|
|
82
|
+
rspec-expectations (3.10.1)
|
|
83
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
84
|
+
rspec-support (~> 3.10.0)
|
|
85
|
+
rspec-mocks (3.10.1)
|
|
86
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
87
|
+
rspec-support (~> 3.10.0)
|
|
88
|
+
rspec-support (3.10.1)
|
|
89
|
+
ruby2_keywords (0.0.2)
|
|
90
|
+
sawyer (0.8.2)
|
|
91
|
+
addressable (>= 2.3.5)
|
|
92
|
+
faraday (> 0.8, < 2.0)
|
|
93
|
+
shellany (0.0.1)
|
|
94
|
+
terminal-table (1.8.0)
|
|
95
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
|
96
|
+
thor (1.0.1)
|
|
97
|
+
unicode-display_width (1.7.0)
|
|
98
|
+
|
|
99
|
+
PLATFORMS
|
|
100
|
+
x86_64-darwin-19
|
|
101
|
+
|
|
102
|
+
DEPENDENCIES
|
|
103
|
+
bundler (~> 2.2)
|
|
104
|
+
faker (~> 2.15)
|
|
105
|
+
git_helper!
|
|
106
|
+
guard-rspec (~> 4.3)
|
|
107
|
+
rake (~> 13.0)
|
|
108
|
+
rspec (~> 3.9)
|
|
109
|
+
|
|
110
|
+
BUNDLED WITH
|
|
111
|
+
2.2.4
|
|
@@ -23,7 +23,7 @@ module GitHelper
|
|
|
23
23
|
Dir.chdir(current_dir)
|
|
24
24
|
|
|
25
25
|
if File.exist?('.git')
|
|
26
|
-
process_git_repository if cli.
|
|
26
|
+
process_git_repository if cli.ask_yes_no("Found git directory: #{current_dir}. Do you wish to proceed in updating #{current_dir}'s remote URLs? (y/n)")
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
Dir.chdir(original_dir)
|
|
@@ -24,7 +24,7 @@ module GitHelper
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
private def ask_for_clarification
|
|
27
|
-
resp = cli.
|
|
27
|
+
resp = cli.ask('Found git remotes for both GitHub and GitLab. Would you like to proceed with GitLab or GitHub? (github/gitlab)').downcase
|
|
28
28
|
if resp.include?('hub')
|
|
29
29
|
github_pull_request
|
|
30
30
|
elsif resp.include?('lab')
|
|
@@ -61,10 +61,10 @@ module GitHelper
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
private def base_branch
|
|
64
|
-
@base_branch ||= if cli.
|
|
64
|
+
@base_branch ||= if cli.ask_yes_no("Is '#{default_branch}' the correct base branch for your new code request? (y/n)")
|
|
65
65
|
default_branch
|
|
66
66
|
else
|
|
67
|
-
cli.
|
|
67
|
+
cli.ask('Base branch?')
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -77,10 +77,11 @@ module GitHelper
|
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
private def new_code_request_title
|
|
80
|
-
@new_code_request_title ||= if
|
|
80
|
+
@new_code_request_title ||= if autogenerated_title &&
|
|
81
|
+
cli.ask_yes_no("Accept the autogenerated code request title '#{autogenerated_title}'? (y/n)")
|
|
81
82
|
autogenerated_title
|
|
82
83
|
else
|
|
83
|
-
cli.
|
|
84
|
+
cli.ask('Title?')
|
|
84
85
|
end
|
|
85
86
|
end
|
|
86
87
|
|
|
@@ -1,85 +1,29 @@
|
|
|
1
1
|
module GitHelper
|
|
2
2
|
class HighlineCli
|
|
3
|
-
def
|
|
4
|
-
ask(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def process_directory_remotes?(directory)
|
|
8
|
-
answer = ask("Found git directory: #{directory}. Do you wish to proceed in updating #{directory}'s remote URLs? (y/n)")
|
|
9
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def conflicting_remote_clarification
|
|
13
|
-
ask('Found git remotes for both GitHub and GitLab. Would you like to proceed with GitLab or GitHub? (github/gitlab)').downcase
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def title
|
|
17
|
-
ask('Title?')
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def base_branch
|
|
21
|
-
ask('Base branch?')
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def code_request_id(request_type)
|
|
25
|
-
ask("#{request_type} Request ID?")
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def accept_autogenerated_title?(autogenerated_title)
|
|
29
|
-
return false unless autogenerated_title
|
|
30
|
-
answer = ask("Accept the autogenerated code request title '#{autogenerated_title}'? (y/n)")
|
|
31
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def base_branch_default?(default_branch)
|
|
35
|
-
answer = ask("Is '#{default_branch}' the correct base branch for your new code request? (y/n)")
|
|
36
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def squash_merge_request?
|
|
40
|
-
answer = ask('Squash merge request? (y/n)')
|
|
41
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def remove_source_branch?
|
|
45
|
-
answer = ask('Remove source branch after merging? (y/n)')
|
|
46
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def merge_method(merge_options)
|
|
50
|
-
index = ask_options("Merge method?", merge_options)
|
|
51
|
-
merge_options[index]
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def apply_template?(template_file_name, request_type)
|
|
55
|
-
answer = ask("Apply the #{request_type} request template from #{template_file_name}? (y/n)")
|
|
56
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def template_to_apply(template_options, request_type)
|
|
60
|
-
complete_options = template_options << 'None'
|
|
61
|
-
index = ask_options("Which #{request_type} request template should be applied?", complete_options)
|
|
62
|
-
complete_options[index]
|
|
3
|
+
def ask(prompt)
|
|
4
|
+
highline_client.ask(prompt) do |conf|
|
|
5
|
+
conf.readline = true
|
|
6
|
+
end.to_s
|
|
63
7
|
end
|
|
64
8
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
#######################
|
|
68
|
-
|
|
69
|
-
private def ask(prompt)
|
|
70
|
-
highline_client.ask(prompt) do |conf|
|
|
9
|
+
def ask_yes_no(prompt)
|
|
10
|
+
answer = highline_client.ask(prompt) do |conf|
|
|
71
11
|
conf.readline = true
|
|
72
12
|
end.to_s
|
|
13
|
+
|
|
14
|
+
answer.empty? ? true : !!(answer =~ /^y/i)
|
|
73
15
|
end
|
|
74
16
|
|
|
75
|
-
|
|
17
|
+
def ask_options(prompt, choices)
|
|
76
18
|
choices_as_string_options = ''
|
|
77
19
|
choices.each { |choice| choices_as_string_options << "#{choices.index(choice) + 1}. #{choice}\n" }
|
|
78
20
|
compiled_prompt = "#{prompt}\n#{choices_as_string_options.strip}"
|
|
79
21
|
|
|
80
|
-
highline_client.ask(compiled_prompt) do |conf|
|
|
22
|
+
index = highline_client.ask(compiled_prompt) do |conf|
|
|
81
23
|
conf.readline = true
|
|
82
24
|
end.to_i - 1
|
|
25
|
+
|
|
26
|
+
choices[index]
|
|
83
27
|
end
|
|
84
28
|
|
|
85
29
|
private def highline_client
|
|
@@ -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
|
@@ -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,13 +121,13 @@ 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
|
|
@@ -135,7 +135,7 @@ describe GitHelper::CodeRequest do
|
|
|
135
135
|
|
|
136
136
|
context 'when response is neither' do
|
|
137
137
|
it 'should raise an error' do
|
|
138
|
-
allow(highline_cli).to receive(:
|
|
138
|
+
allow(highline_cli).to receive(:ask).and_return(Faker::Lorem.word)
|
|
139
139
|
expect(subject).to receive(:exit)
|
|
140
140
|
subject.send(:ask_for_clarification)
|
|
141
141
|
end
|
|
@@ -173,23 +173,23 @@ describe GitHelper::CodeRequest do
|
|
|
173
173
|
describe '#base_branch' do
|
|
174
174
|
it 'should call the default branch' do
|
|
175
175
|
expect(subject).to receive(:default_branch)
|
|
176
|
-
allow(highline_cli).to receive(:
|
|
177
|
-
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)
|
|
178
178
|
subject.send(:base_branch)
|
|
179
179
|
end
|
|
180
180
|
|
|
181
181
|
it 'should ask the CLI to ask the user' do
|
|
182
182
|
allow(subject).to receive(:default_branch)
|
|
183
|
-
expect(highline_cli).to receive(:
|
|
184
|
-
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)
|
|
185
185
|
subject.send(:base_branch)
|
|
186
186
|
end
|
|
187
187
|
|
|
188
188
|
context 'if the user says no' do
|
|
189
189
|
it 'definitely asks for the users base branch' do
|
|
190
190
|
allow(subject).to receive(:default_branch)
|
|
191
|
-
expect(highline_cli).to receive(:
|
|
192
|
-
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)
|
|
193
193
|
subject.send(:base_branch)
|
|
194
194
|
end
|
|
195
195
|
end
|
|
@@ -197,7 +197,7 @@ describe GitHelper::CodeRequest do
|
|
|
197
197
|
context 'if the user says yes' do
|
|
198
198
|
it 'does not ask for the users base branch' do
|
|
199
199
|
allow(subject).to receive(:default_branch)
|
|
200
|
-
expect(highline_cli).to receive(:
|
|
200
|
+
expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(true)
|
|
201
201
|
expect(highline_cli).not_to receive(:base_branch)
|
|
202
202
|
subject.send(:base_branch)
|
|
203
203
|
end
|
|
@@ -215,32 +215,32 @@ describe GitHelper::CodeRequest do
|
|
|
215
215
|
describe '#new_code_request_title' do
|
|
216
216
|
it 'should call autogenerated title method' do
|
|
217
217
|
expect(subject).to receive(:autogenerated_title)
|
|
218
|
-
allow(highline_cli).to receive(:
|
|
219
|
-
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)
|
|
220
220
|
subject.send(:new_code_request_title)
|
|
221
221
|
end
|
|
222
222
|
|
|
223
223
|
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(:
|
|
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)
|
|
227
227
|
subject.send(:new_code_request_title)
|
|
228
228
|
end
|
|
229
229
|
|
|
230
230
|
context 'if the user says no' do
|
|
231
231
|
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(:
|
|
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)
|
|
235
235
|
subject.send(:new_code_request_title)
|
|
236
236
|
end
|
|
237
237
|
end
|
|
238
238
|
|
|
239
239
|
context 'if the user says yes to original title' do
|
|
240
240
|
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(:
|
|
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)
|
|
244
244
|
subject.send(:new_code_request_title)
|
|
245
245
|
end
|
|
246
246
|
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,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
|
|
@@ -4,7 +4,7 @@ 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,
|
|
7
|
+
let(:cli) { double(:highline_cli, ask: new_branch_name) }
|
|
8
8
|
|
|
9
9
|
subject { GitHelper::NewBranch.new }
|
|
10
10
|
|
|
@@ -31,7 +31,7 @@ describe GitHelper::NewBranch do
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it 'should ask the highline cli what the new branch name should be' do
|
|
34
|
-
expect(cli).to receive(:
|
|
34
|
+
expect(cli).to receive(:ask)
|
|
35
35
|
subject.execute
|
|
36
36
|
end
|
|
37
37
|
end
|
|
@@ -101,19 +101,19 @@ describe GitHelper::GitHubPullRequest do
|
|
|
101
101
|
|
|
102
102
|
it 'should call the CLI to ask about a single template' do
|
|
103
103
|
allow(subject).to receive(:pr_template_options).and_return([template])
|
|
104
|
-
expect(highline_cli).to receive(:
|
|
104
|
+
expect(highline_cli).to receive(:ask_yes_no).and_return(true)
|
|
105
105
|
subject.send(:template_name_to_apply)
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
it 'should return the single template if the user says yes' do
|
|
109
109
|
allow(subject).to receive(:pr_template_options).and_return([template])
|
|
110
|
-
allow(highline_cli).to receive(:
|
|
110
|
+
allow(highline_cli).to receive(:ask_yes_no).and_return(true)
|
|
111
111
|
expect(subject.send(:template_name_to_apply)).to eq(template)
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
it 'should return nil if the user says no' do
|
|
115
115
|
allow(subject).to receive(:pr_template_options).and_return([template])
|
|
116
|
-
allow(highline_cli).to receive(:
|
|
116
|
+
allow(highline_cli).to receive(:ask_yes_no).and_return(false)
|
|
117
117
|
expect(subject.send(:template_name_to_apply)).to eq(nil)
|
|
118
118
|
end
|
|
119
119
|
end
|
|
@@ -124,19 +124,19 @@ describe GitHelper::GitHubPullRequest do
|
|
|
124
124
|
|
|
125
125
|
it 'should call the CLI to ask which of multiple templates to apply' do
|
|
126
126
|
allow(subject).to receive(:pr_template_options).and_return([template1, template2])
|
|
127
|
-
expect(highline_cli).to receive(:
|
|
127
|
+
expect(highline_cli).to receive(:ask_options).and_return(template1)
|
|
128
128
|
subject.send(:template_name_to_apply)
|
|
129
129
|
end
|
|
130
130
|
|
|
131
131
|
it 'should return the answer template if the user says yes' do
|
|
132
132
|
allow(subject).to receive(:pr_template_options).and_return([template1, template2])
|
|
133
|
-
allow(highline_cli).to receive(:
|
|
133
|
+
allow(highline_cli).to receive(:ask_options).and_return(template1)
|
|
134
134
|
expect(subject.send(:template_name_to_apply)).to eq(template1)
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
it 'should return nil if the user says no' do
|
|
138
138
|
allow(subject).to receive(:pr_template_options).and_return([template1, template2])
|
|
139
|
-
allow(highline_cli).to receive(:
|
|
139
|
+
allow(highline_cli).to receive(:ask_options).and_return('None')
|
|
140
140
|
expect(subject.send(:template_name_to_apply)).to eq(nil)
|
|
141
141
|
end
|
|
142
142
|
end
|
|
@@ -151,13 +151,13 @@ describe GitHelper::GitHubPullRequest do
|
|
|
151
151
|
|
|
152
152
|
describe '#pr_id' do
|
|
153
153
|
it 'should ask the CLI for the code request ID' do
|
|
154
|
-
expect(highline_cli).to receive(:
|
|
154
|
+
expect(highline_cli).to receive(:ask).and_return(Faker::Number.number)
|
|
155
155
|
subject.send(:pr_id)
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
it 'should equal an integer' do
|
|
159
159
|
pr_id = Faker::Number.number
|
|
160
|
-
expect(highline_cli).to receive(:
|
|
160
|
+
expect(highline_cli).to receive(:ask).and_return(pr_id)
|
|
161
161
|
expect(subject.send(:pr_id)).to eq(pr_id)
|
|
162
162
|
end
|
|
163
163
|
end
|
|
@@ -167,16 +167,16 @@ describe GitHelper::GitHubPullRequest do
|
|
|
167
167
|
|
|
168
168
|
before do
|
|
169
169
|
allow(subject).to receive(:existing_project).and_return(project)
|
|
170
|
-
allow(highline_cli).to receive(:
|
|
170
|
+
allow(highline_cli).to receive(:ask_options)
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
it 'should ask the CLI for the merge_method' do
|
|
174
|
-
expect(highline_cli).to receive(:
|
|
174
|
+
expect(highline_cli).to receive(:ask_options).and_return('merge')
|
|
175
175
|
subject.send(:merge_method)
|
|
176
176
|
end
|
|
177
177
|
|
|
178
178
|
it 'should be a string' do
|
|
179
|
-
allow(highline_cli).to receive(:
|
|
179
|
+
allow(highline_cli).to receive(:ask_options).and_return('merge')
|
|
180
180
|
expect(subject.send(:merge_method)).to be_a(String)
|
|
181
181
|
end
|
|
182
182
|
|
|
@@ -239,7 +239,7 @@ describe GitHelper::GitHubPullRequest do
|
|
|
239
239
|
|
|
240
240
|
describe '#existing_pr' do
|
|
241
241
|
it 'should call the octokit client' do
|
|
242
|
-
allow(highline_cli).to receive(:
|
|
242
|
+
allow(highline_cli).to receive(:ask).and_return(Faker::Number.number)
|
|
243
243
|
expect(octokit_client_client).to receive(:pull_request).and_return(:pull_request)
|
|
244
244
|
subject.send(:existing_pr)
|
|
245
245
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: git_helper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.2.
|
|
4
|
+
version: 3.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Emma Sax
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-01-
|
|
11
|
+
date: 2021-01-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gitlab
|
|
@@ -139,13 +139,13 @@ dependencies:
|
|
|
139
139
|
description: A set of GitHub and GitLab workflow scripts to provide a smoother development
|
|
140
140
|
process for your git projects.
|
|
141
141
|
email:
|
|
142
|
-
- emma.sax4@gmail.com
|
|
143
142
|
executables:
|
|
144
143
|
- git-helper
|
|
145
144
|
extensions: []
|
|
146
145
|
extra_rdoc_files: []
|
|
147
146
|
files:
|
|
148
147
|
- Gemfile
|
|
148
|
+
- Gemfile.lock
|
|
149
149
|
- Guardfile
|
|
150
150
|
- LICENSE
|
|
151
151
|
- README.md
|