git_helper 3.3.0 → 3.6.6

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +58 -64
  4. data/Guardfile +5 -3
  5. data/LICENSE.md +29 -0
  6. data/README.md +42 -34
  7. data/Rakefile +2 -0
  8. data/bin/git-helper +18 -13
  9. data/lib/git_helper/change_remote.rb +15 -6
  10. data/lib/git_helper/checkout_default.rb +2 -0
  11. data/lib/git_helper/clean_branches.rb +2 -0
  12. data/lib/git_helper/code_request.rb +33 -19
  13. data/lib/git_helper/empty_commit.rb +2 -0
  14. data/lib/git_helper/forget_local_commits.rb +2 -0
  15. data/lib/git_helper/git_config_reader.rb +11 -5
  16. data/lib/git_helper/github_client.rb +70 -0
  17. data/lib/git_helper/gitlab_client.rb +48 -2
  18. data/lib/git_helper/local_code.rb +24 -14
  19. data/lib/git_helper/merge_request.rb +98 -70
  20. data/lib/git_helper/new_branch.rb +3 -1
  21. data/lib/git_helper/pull_request.rb +91 -73
  22. data/lib/git_helper/setup.rb +62 -39
  23. data/lib/git_helper/version.rb +3 -1
  24. data/lib/git_helper.rb +7 -4
  25. data/renovate.json +6 -0
  26. metadata +34 -80
  27. data/LICENSE +0 -22
  28. data/lib/git_helper/highline_cli.rb +0 -33
  29. data/lib/git_helper/octokit_client.rb +0 -11
  30. data/plugins.zip +0 -0
  31. data/spec/git_helper/change_remote_spec.rb +0 -176
  32. data/spec/git_helper/checkout_default_spec.rb +0 -19
  33. data/spec/git_helper/clean_branches_spec.rb +0 -19
  34. data/spec/git_helper/code_request_spec.rb +0 -263
  35. data/spec/git_helper/empty_commit_spec.rb +0 -19
  36. data/spec/git_helper/forget_local_commits_spec.rb +0 -19
  37. data/spec/git_helper/git_config_reader_spec.rb +0 -62
  38. data/spec/git_helper/gitlab_client_spec.rb +0 -26
  39. data/spec/git_helper/highline_cli_spec.rb +0 -51
  40. data/spec/git_helper/local_code_spec.rb +0 -268
  41. data/spec/git_helper/merge_request_spec.rb +0 -251
  42. data/spec/git_helper/new_branch_spec.rb +0 -45
  43. data/spec/git_helper/octokit_client_spec.rb +0 -26
  44. data/spec/git_helper/pull_request_spec.rb +0 -254
  45. data/spec/git_helper/setup_spec.rb +0 -170
  46. data/spec/spec_helper.rb +0 -47
@@ -1,11 +0,0 @@
1
- module GitHelper
2
- class OctokitClient
3
- def client
4
- Octokit::Client.new(access_token: git_config_reader.github_token)
5
- end
6
-
7
- private def git_config_reader
8
- @git_config_reader ||= GitHelper::GitConfigReader.new
9
- end
10
- end
11
- end
data/plugins.zip DELETED
Binary file
@@ -1,176 +0,0 @@
1
- require 'spec_helper'
2
- require 'git_helper'
3
-
4
- describe GitHelper::ChangeRemote do
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
-
12
- let(:local_code) do
13
- double(:local_code,
14
- remotes: [remote1],
15
- remote_name: Faker::Lorem.word,
16
- ssh_remote?: true,
17
- https_remote?: false,
18
- remote_project: project,
19
- remote_source: 'github.com',
20
- change_remote: true
21
- )
22
- end
23
-
24
- subject { GitHelper::ChangeRemote.new(old_owner, new_owner) }
25
-
26
- before do
27
- allow(GitHelper::HighlineCli).to receive(:new).and_return(cli)
28
- allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
29
- allow(subject).to receive(:puts)
30
- end
31
-
32
- describe '#execute' do
33
- before do
34
- allow(Dir).to receive(:pwd).and_return("/Users/#{Faker::Name.first_name}/#{project}")
35
- allow(Dir).to receive(:entries).and_return(directory_entries)
36
- allow(File).to receive(:join).and_return("/Users/#{Faker::Name.first_name}/#{project}/#{Faker::Lorem.word}")
37
- allow(File).to receive(:directory?).and_return(true)
38
- allow(subject).to receive(:process_dir)
39
- end
40
-
41
- it 'should call to process at least one directory' do
42
- expect(subject).to receive(:process_dir).at_least(:once)
43
- subject.execute
44
- end
45
-
46
- it 'should definitely look in the file structure' do
47
- expect(Dir).to receive(:pwd)
48
- expect(Dir).to receive(:entries)
49
- expect(File).to receive(:join)
50
- expect(File).to receive(:directory?)
51
- subject.execute
52
- end
53
- end
54
-
55
- describe '#process_dir' do
56
- before do
57
- allow(Dir).to receive(:chdir).and_return(nil)
58
- allow(File).to receive(:exist?).and_return(true)
59
- allow(subject).to receive(:process_git_repository)
60
- end
61
-
62
- it 'should definitely look in the file structure' do
63
- expect(Dir).to receive(:chdir)
64
- expect(File).to receive(:exist?)
65
- subject.send(:process_dir, "/Users/#{Faker::Name.first_name}/#{project}", "/Users/#{Faker::Name.first_name}/#{project}/#{Faker::Lorem.word}")
66
- end
67
-
68
- context 'when the user says to process the directory' do
69
- it 'should call to process the git repository at least once' do
70
- expect(subject).to receive(:process_git_repository).at_least(:once)
71
- subject.send(:process_dir, "/Users/#{Faker::Name.first_name}/#{project}", "/Users/#{Faker::Name.first_name}/#{project}/#{Faker::Lorem.word}")
72
- end
73
- end
74
-
75
- context 'when the user says not to process the directory' do
76
- let(:cli) { double(:highline_cli, ask_yes_no: false) }
77
-
78
- it 'should not call to process the directory' do
79
- expect(subject).not_to receive(:process_git_repository)
80
- subject.send(:process_dir, "/Users/#{Faker::Name.first_name}/#{project}", "/Users/#{Faker::Name.first_name}/#{project}/#{Faker::Lorem.word}")
81
- end
82
- end
83
- end
84
-
85
- describe '#process_git_repository' do
86
- before do
87
- allow(subject).to receive(:process_remote).and_return(nil)
88
- end
89
-
90
- it 'should call local_code' do
91
- expect(GitHelper::LocalCode).to receive(:new)
92
- subject.send(:process_git_repository)
93
- end
94
-
95
- context 'when the remote includes the old owner' do
96
- it 'should call to process the remote' do
97
- expect(subject).to receive(:process_remote)
98
- subject.send(:process_git_repository)
99
- end
100
- end
101
-
102
- context 'when the remote does not include the old owner' do
103
- let(:remote1) { "git@github.com:#{new_owner}/#{project}.git" }
104
-
105
- it 'should not call to process the remote' do
106
- expect(subject).not_to receive(:process_remote)
107
- subject.send(:process_git_repository)
108
- end
109
- end
110
- end
111
-
112
- describe '#process_remote' do
113
- it 'should always get the remote name' do
114
- expect(local_code).to receive(:remote_name)
115
- subject.send(:process_remote, remote1)
116
- end
117
-
118
- it 'should always attempt to change the remote' do
119
- expect(local_code).to receive(:change_remote)
120
- subject.send(:process_remote, remote1)
121
- end
122
-
123
- it 'should attempt to get the remote repo exactly once' do
124
- expect(local_code).to receive(:remote_project).exactly(:once)
125
- subject.send(:process_remote, remote1)
126
- end
127
-
128
- it 'should attempt to get the remote source exactly once' do
129
- expect(local_code).to receive(:remote_source).exactly(:once)
130
- subject.send(:process_remote, remote1)
131
- end
132
-
133
- it 'should ask if the remote is SSH' do
134
- expect(local_code).to receive(:ssh_remote?)
135
- subject.send(:process_remote, remote1)
136
- end
137
-
138
- context 'https remote' do
139
- let(:local_code) do
140
- double(:local_code,
141
- remotes: [remote1],
142
- remote_name: Faker::Lorem.word,
143
- ssh_remote?: false,
144
- https_remote?: false,
145
- remote_project: project,
146
- remote_source: 'github.com',
147
- change_remote: true
148
- )
149
- end
150
-
151
- it 'should ask if the remote is SSH' do
152
- expect(local_code).to receive(:ssh_remote?)
153
- subject.send(:process_remote, remote1)
154
- end
155
-
156
- it 'should ask if the remote is https' do
157
- expect(local_code).to receive(:https_remote?)
158
- subject.send(:process_remote, remote1)
159
- end
160
- end
161
- end
162
-
163
- describe '#local_code' do
164
- it 'should create a new local code instance' do
165
- expect(GitHelper::LocalCode).to receive(:new)
166
- subject.send(:local_code)
167
- end
168
- end
169
-
170
- describe '#cli' do
171
- it 'should create a new highline CLI instance' do
172
- expect(GitHelper::HighlineCli).to receive(:new)
173
- subject.send(:cli)
174
- end
175
- end
176
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
- require 'git_helper'
3
-
4
- describe GitHelper::CheckoutDefault do
5
- let(:local_code) { double(:local_code, checkout_default: :done) }
6
-
7
- subject { GitHelper::CheckoutDefault.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 checkout_default method from the local code class' do
15
- allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
16
- expect(local_code).to receive(:checkout_default)
17
- subject.execute
18
- end
19
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
- require 'git_helper'
3
-
4
- describe GitHelper::CleanBranches do
5
- let(:local_code) { double(:local_code, clean_branches: :commit) }
6
-
7
- subject { GitHelper::CleanBranches.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 clean_branches method from the local code class' do
15
- allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
16
- expect(local_code).to receive(:clean_branches)
17
- subject.execute
18
- end
19
- end
@@ -1,263 +0,0 @@
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: Faker::Lorem.word, branch: Faker::Lorem.word) }
7
- let(:process_project) { double(:process_project, create: :created, merge: :merged) }
8
- let(:base_branch) { Faker::Lorem.word }
9
- let(:title) { Faker::Lorem.sentence }
10
-
11
- subject { GitHelper::CodeRequest.new }
12
-
13
- before do
14
- allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
15
- allow(GitHelper::HighlineCli).to receive(:new).and_return(highline_cli)
16
- allow(subject).to receive(:puts)
17
- end
18
-
19
- describe '#create' do
20
- before do
21
- allow(subject).to receive(:base_branch).and_return(base_branch)
22
- allow(subject).to receive(:new_code_request_title).and_return(title)
23
- end
24
-
25
- it 'should call to process the project' do
26
- expect(subject).to receive(:process_project).and_return(process_project)
27
- subject.create
28
- end
29
-
30
- it 'should call create' do
31
- allow(subject).to receive(:process_project).and_return(process_project)
32
- expect(process_project).to receive(:create)
33
- subject.create
34
- end
35
-
36
- it 'should call base_branch and new_code_request_title' do
37
- expect(subject).to receive(:base_branch).and_return(base_branch)
38
- expect(subject).to receive(:new_code_request_title).and_return(title)
39
- allow(subject).to receive(:process_project).and_return(process_project)
40
- allow(process_project).to receive(:create)
41
- subject.create
42
- end
43
- end
44
-
45
- describe '#merge' do
46
- it 'should call to process the project' do
47
- expect(subject).to receive(:process_project).and_return(process_project)
48
- subject.merge
49
- end
50
-
51
- it 'should call merge' do
52
- allow(subject).to receive(:process_project).and_return(process_project)
53
- expect(process_project).to receive(:merge)
54
- subject.merge
55
- end
56
- end
57
-
58
- describe '#process_project' do
59
- it 'should call the local code to see if it is a github or gitlab project' do
60
- expect(local_code).to receive(:gitlab_project?).and_return(false)
61
- expect(local_code).to receive(:github_repo?).and_return(true)
62
- subject.send(:process_project)
63
- end
64
-
65
- context 'when github and gitlab remotes are found' do
66
- it 'should ask for clarification' do
67
- allow(local_code).to receive(:gitlab_project?).and_return(true)
68
- allow(local_code).to receive(:github_repo?).and_return(true)
69
- expect(subject).to receive(:ask_for_clarification)
70
- subject.send(:process_project)
71
- end
72
- end
73
-
74
- context 'when github' do
75
- it 'should call the github_pull_request' do
76
- allow(local_code).to receive(:gitlab_project?).and_return(false)
77
- allow(local_code).to receive(:github_repo?).and_return(true)
78
- expect(subject).to receive(:github_pull_request)
79
- subject.send(:process_project)
80
- end
81
- end
82
-
83
- context 'when gitlab' do
84
- it 'should call the gitlab_merge_request' do
85
- allow(local_code).to receive(:gitlab_project?).and_return(true)
86
- allow(local_code).to receive(:github_repo?).and_return(false)
87
- expect(subject).to receive(:gitlab_merge_request)
88
- subject.send(:process_project)
89
- end
90
- end
91
-
92
- context 'when no github or gitlab remotes are found' do
93
- it 'should raise error' do
94
- allow(local_code).to receive(:gitlab_project?).and_return(false)
95
- allow(local_code).to receive(:github_repo?).and_return(false)
96
- expect(subject).to receive(:exit)
97
- subject.send(:process_project)
98
- end
99
- end
100
- end
101
-
102
- describe '#ask_for_clarification' do
103
- it 'should ask the CLI' do
104
- expect(highline_cli).to receive(:ask).and_return('github')
105
- subject.send(:ask_for_clarification)
106
- end
107
-
108
- context 'when response is github' do
109
- it 'should return github_pull_request' do
110
- allow(highline_cli).to receive(:ask).and_return('github')
111
- expect(subject).to receive(:github_pull_request)
112
- subject.send(:ask_for_clarification)
113
- end
114
-
115
- it 'should return github_pull_request' do
116
- allow(highline_cli).to receive(:ask).and_return('Github')
117
- expect(subject).to receive(:github_pull_request)
118
- subject.send(:ask_for_clarification)
119
- end
120
- end
121
-
122
- context 'when response is gitlab' do
123
- it 'should return gitlab_merge_request' do
124
- allow(highline_cli).to receive(:ask).and_return('gitlab')
125
- expect(subject).to receive(:gitlab_merge_request)
126
- subject.send(:ask_for_clarification)
127
- end
128
-
129
- it 'should return gitlab_merge_request' do
130
- allow(highline_cli).to receive(:ask).and_return('Gitlab')
131
- expect(subject).to receive(:gitlab_merge_request)
132
- subject.send(:ask_for_clarification)
133
- end
134
- end
135
-
136
- # Unfortunately this test sometimes fails... just rerun the tests if it does
137
- context 'when response is neither' do
138
- it 'should raise an error' do
139
- allow(highline_cli).to receive(:ask).and_return(Faker::Lorem.word)
140
- expect(subject).to receive(:exit)
141
- subject.send(:ask_for_clarification)
142
- end
143
- end
144
- end
145
-
146
- describe '#github_pull_request' do
147
- it 'should call the GitHelper::GitHubPullRequest' do
148
- expect(GitHelper::GitHubPullRequest).to receive(:new)
149
- subject.send(:github_pull_request)
150
- end
151
- end
152
-
153
- describe '#gitlab_merge_request' do
154
- it 'should call the GitHelper::GitLabMergeRequest' do
155
- expect(GitHelper::GitLabMergeRequest).to receive(:new)
156
- subject.send(:gitlab_merge_request)
157
- end
158
- end
159
-
160
- describe '#local_project' do
161
- it 'should call the name of the local_code' do
162
- expect(local_code).to receive(:project_name)
163
- subject.send(:local_project)
164
- end
165
- end
166
-
167
- describe '#default_branch' do
168
- it 'should call the name of the local_code' do
169
- expect(local_code).to receive(:default_branch)
170
- subject.send(:default_branch)
171
- end
172
- end
173
-
174
- describe '#base_branch' do
175
- it 'should call the default branch' do
176
- expect(subject).to receive(:default_branch)
177
- allow(highline_cli).to receive(:ask_yes_no).at_least(:once)
178
- allow(highline_cli).to receive(:ask).at_least(:once).and_return(base_branch)
179
- subject.send(:base_branch)
180
- end
181
-
182
- it 'should ask the CLI to ask the user' do
183
- allow(subject).to receive(:default_branch)
184
- expect(highline_cli).to receive(:ask_yes_no).at_least(:once)
185
- allow(highline_cli).to receive(:ask).at_least(:once).and_return(base_branch)
186
- subject.send(:base_branch)
187
- end
188
-
189
- context 'if the user says no' do
190
- it 'definitely asks for the users base branch' do
191
- allow(subject).to receive(:default_branch)
192
- expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(false)
193
- expect(highline_cli).to receive(:ask).at_least(:once).and_return(base_branch)
194
- subject.send(:base_branch)
195
- end
196
- end
197
-
198
- context 'if the user says yes' do
199
- it 'does not ask for the users base branch' do
200
- allow(subject).to receive(:default_branch)
201
- expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(true)
202
- expect(highline_cli).not_to receive(:base_branch)
203
- subject.send(:base_branch)
204
- end
205
- end
206
- end
207
-
208
- describe '#autogenerated_title' do
209
- it 'should generate a title based on the branch' do
210
- expect(subject).to receive(:local_branch).and_return(Faker::Lorem.word)
211
- expect(local_code).to receive(:generate_title)
212
- subject.send(:autogenerated_title)
213
- end
214
- end
215
-
216
- describe '#new_code_request_title' do
217
- it 'should call autogenerated title method' do
218
- expect(subject).to receive(:autogenerated_title)
219
- allow(highline_cli).to receive(:ask_yes_no).at_least(:once)
220
- allow(highline_cli).to receive(:ask).at_least(:once).and_return(title)
221
- subject.send(:new_code_request_title)
222
- end
223
-
224
- it 'should ask the CLI to ask the user' do
225
- allow(subject).to receive(:autogenerated_title).and_return(Faker::Lorem.sentence)
226
- expect(highline_cli).to receive(:ask_yes_no).at_least(:once)
227
- allow(highline_cli).to receive(:ask).at_least(:once).and_return(title)
228
- subject.send(:new_code_request_title)
229
- end
230
-
231
- context 'if the user says no' do
232
- it 'definitely asks for the users title' do
233
- allow(subject).to receive(:autogenerated_title).and_return(Faker::Lorem.sentence)
234
- expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(false)
235
- expect(highline_cli).to receive(:ask).at_least(:once).and_return(title)
236
- subject.send(:new_code_request_title)
237
- end
238
- end
239
-
240
- context 'if the user says yes to original title' do
241
- it 'does not ask for the users chosen title' do
242
- allow(subject).to receive(:autogenerated_title).and_return(Faker::Lorem.sentence)
243
- expect(highline_cli).to receive(:ask_yes_no).at_least(:once).and_return(true)
244
- expect(highline_cli).not_to receive(:ask)
245
- subject.send(:new_code_request_title)
246
- end
247
- end
248
- end
249
-
250
- describe '#local_code' do
251
- it 'should call the octokit client' do
252
- expect(GitHelper::LocalCode).to receive(:new).and_return(local_code)
253
- subject.send(:local_code)
254
- end
255
- end
256
-
257
- describe '#cli' do
258
- it 'should call the octokit client' do
259
- expect(GitHelper::HighlineCli).to receive(:new).and_return(highline_cli)
260
- subject.send(:cli)
261
- end
262
- end
263
- end
@@ -1,19 +0,0 @@
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
@@ -1,19 +0,0 @@
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
@@ -1,62 +0,0 @@
1
- require 'spec_helper'
2
- require 'git_helper'
3
-
4
- describe GitHelper::GitConfigReader do
5
- let(:github_token) { Faker::Internet.password(max_length: 10) }
6
- let(:gitlab_token) { Faker::Internet.password(max_length: 10) }
7
-
8
- let(:config_file) {
9
- {
10
- github_user: Faker::Internet.username,
11
- github_token: github_token,
12
- gitlab_user: Faker::Internet.username,
13
- gitlab_token: gitlab_token
14
- }
15
- }
16
-
17
- subject { GitHelper::GitConfigReader.new }
18
-
19
- describe '#gitlab_token' do
20
- it 'should locate the gitlab_token' do
21
- expect(subject).to receive(:config_file).and_return(config_file)
22
- expect(subject.gitlab_token).to eq(gitlab_token)
23
- end
24
-
25
- it 'should call the config file' do
26
- expect(subject).to receive(:config_file).and_return(config_file)
27
- subject.gitlab_token
28
- end
29
- end
30
-
31
- describe '#github_token' do
32
- it 'should locate the github_token' do
33
- expect(subject).to receive(:config_file).and_return(config_file)
34
- expect(subject.github_token).to eq(github_token)
35
- end
36
-
37
- it 'should call the config file' do
38
- expect(subject).to receive(:config_file).and_return(config_file)
39
- subject.github_token
40
- end
41
- end
42
-
43
- describe '#config_file' do
44
- it 'should yaml load the file path' do
45
- expect(YAML).to receive(:load_file)
46
- subject.send(:config_file)
47
- end
48
- end
49
-
50
- describe '#git_config_file_path' do
51
- it 'should look in the current directory' do
52
- expect(Dir).to receive(:pwd).and_return("/Users/#{Faker::Name.first_name}/#{Faker::Lorem.word}")
53
- subject.send(:git_config_file_path)
54
- end
55
-
56
- it 'should return the base path with the git config file at the end' do
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")
60
- end
61
- end
62
- end
@@ -1,26 +0,0 @@
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
@@ -1,51 +0,0 @@
1
- require 'spec_helper'
2
- require 'git_helper'
3
-
4
- describe GitHelper::HighlineCli do
5
- let(:response) { double(:response, readline: true, to_i: 3) }
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 '#ask' do
15
- it 'should ask the highline client ask'do
16
- expect(highline_client).to receive(:ask)
17
- subject.ask(Faker::Lorem.sentence)
18
- end
19
-
20
- it 'should return a string' do
21
- expect(subject.ask(Faker::Lorem.sentence)).to be_a(String)
22
- end
23
- end
24
-
25
- describe '#ask_yes_no' do
26
- it 'should ask the highline client ask'do
27
- expect(highline_client).to receive(:ask)
28
- subject.ask_yes_no(Faker::Lorem.sentence)
29
- end
30
-
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
38
- end
39
- end
40
-
41
- describe '#ask_options' do
42
- it 'should ask the highline client ask'do
43
- expect(highline_client).to receive(:ask)
44
- subject.ask_options(Faker::Lorem.sentence, ['one', 'two', 'three'])
45
- end
46
-
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)
49
- end
50
- end
51
- end