git_helper 3.0.0 → 3.2.0

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.
@@ -11,6 +11,7 @@ describe GitHelper::NewBranch do
11
11
  before do
12
12
  allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
13
13
  allow(GitHelper::HighlineCli).to receive(:new).and_return(cli)
14
+ allow(subject).to receive(:puts)
14
15
  end
15
16
 
16
17
  it 'should call GitHelper::LocalCode' do
@@ -2,14 +2,15 @@ require 'spec_helper'
2
2
  require 'git_helper'
3
3
 
4
4
  describe GitHelper::GitHubPullRequest do
5
- let(:local_code) { double(:local_code, read_template: 'template') }
5
+ let(:local_code) { double(:local_code, read_template: Faker::Lorem.word) }
6
6
  let(:highline_cli) { double(:highline_cli) }
7
7
  let(:octokit_client_client) { double(:octokit_client_client, project: :project, merge_request: :merge_request, create_merge_request: :created) }
8
8
  let(:octokit_client) { double(:octokit_client, client: octokit_client_client) }
9
+
9
10
  let(:options) do
10
11
  {
11
- local_project: 'emmasax4/git_helper',
12
- local_branch: 'main',
12
+ local_project: Faker::Lorem.word,
13
+ local_branch: Faker::Lorem.word,
13
14
  local_code: local_code,
14
15
  cli: highline_cli
15
16
  }
@@ -19,49 +20,50 @@ describe GitHelper::GitHubPullRequest do
19
20
 
20
21
  before do
21
22
  allow(GitHelper::OctokitClient).to receive(:new).and_return(octokit_client)
23
+ allow(subject).to receive(:puts)
22
24
  end
23
25
 
24
26
  describe '#create' do
25
27
  it 'should call the octokit client to create' do
26
28
  allow(subject).to receive(:new_pr_body).and_return('')
27
- expect(octokit_client_client).to receive(:create_pull_request)
28
- subject.create({base_branch: 'base', new_title: 'title'})
29
+ expect(octokit_client_client).to receive(:create_pull_request).and_return(double(html_url: Faker::Internet.url))
30
+ subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})
29
31
  end
30
32
 
31
33
  it 'should call various other methods' do
32
34
  expect(subject).to receive(:new_pr_body).and_return('').at_least(:once)
33
- allow(octokit_client_client).to receive(:create_pull_request)
34
- subject.create({base_branch: 'base', new_title: 'title'})
35
+ allow(octokit_client_client).to receive(:create_pull_request).and_return(double(html_url: Faker::Internet.url))
36
+ subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})
35
37
  end
36
38
 
37
39
  it 'should catch the raised error if the creation does not work' do
38
40
  allow(subject).to receive(:new_pr_body).and_return('')
39
41
  allow(octokit_client_client).to receive(:create_pull_request).and_raise(StandardError)
40
- expect(subject.create({base_branch: 'base', new_title: 'title'})).to eq(nil)
42
+ expect(subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})).to eq(nil)
41
43
  end
42
44
  end
43
45
 
44
46
  describe '#merge' do
45
47
  it 'should call the octokit client to merge' do
46
- allow(subject).to receive(:existing_pr).and_return(double(title: 'title'))
48
+ allow(subject).to receive(:existing_pr).and_return(double(title: Faker::Lorem.word))
47
49
  allow(subject).to receive(:merge_method).and_return('rebase')
48
- allow(subject).to receive(:pr_id).and_return(123)
49
- expect(octokit_client_client).to receive(:merge_pull_request)
50
+ allow(subject).to receive(:pr_id).and_return(Faker::Number.number)
51
+ expect(octokit_client_client).to receive(:merge_pull_request).and_return(double(sha: Faker::Internet.password))
50
52
  subject.merge
51
53
  end
52
54
 
53
55
  it 'should call various other methods' do
54
- expect(subject).to receive(:existing_pr).and_return(double(title: 'title')).at_least(:once)
56
+ expect(subject).to receive(:existing_pr).and_return(double(title: Faker::Lorem.word)).at_least(:once)
55
57
  expect(subject).to receive(:merge_method).and_return('rebase').at_least(:once)
56
- expect(subject).to receive(:pr_id).and_return(123).at_least(:once)
57
- allow(octokit_client_client).to receive(:merge_pull_request)
58
+ expect(subject).to receive(:pr_id).and_return(Faker::Number.number).at_least(:once)
59
+ allow(octokit_client_client).to receive(:merge_pull_request).and_return(double(sha: Faker::Internet.password))
58
60
  subject.merge
59
61
  end
60
62
 
61
63
  it 'should catch the raised error if the merge does not work' do
62
- allow(subject).to receive(:existing_pr).and_return(double(title: 'title'))
64
+ allow(subject).to receive(:existing_pr).and_return(double(title: Faker::Lorem.word))
63
65
  allow(subject).to receive(:merge_method).and_return('rebase')
64
- allow(subject).to receive(:pr_id).and_return(123)
66
+ allow(subject).to receive(:pr_id).and_return(Faker::Number.number)
65
67
  allow(octokit_client_client).to receive(:merge_pull_request).and_raise(StandardError)
66
68
  expect(subject.merge).to eq(nil)
67
69
  end
@@ -95,40 +97,45 @@ describe GitHelper::GitHubPullRequest do
95
97
  end
96
98
 
97
99
  context 'if there is one template option' do
100
+ let(:template) { Faker::Lorem.word }
101
+
98
102
  it 'should call the CLI to ask about a single template' do
99
- allow(subject).to receive(:pr_template_options).and_return(['template1'])
103
+ allow(subject).to receive(:pr_template_options).and_return([template])
100
104
  expect(highline_cli).to receive(:apply_template?).and_return(true)
101
105
  subject.send(:template_name_to_apply)
102
106
  end
103
107
 
104
108
  it 'should return the single template if the user says yes' do
105
- allow(subject).to receive(:pr_template_options).and_return(['template1'])
109
+ allow(subject).to receive(:pr_template_options).and_return([template])
106
110
  allow(highline_cli).to receive(:apply_template?).and_return(true)
107
- expect(subject.send(:template_name_to_apply)).to eq('template1')
111
+ expect(subject.send(:template_name_to_apply)).to eq(template)
108
112
  end
109
113
 
110
114
  it 'should return nil if the user says no' do
111
- allow(subject).to receive(:pr_template_options).and_return(['template1'])
115
+ allow(subject).to receive(:pr_template_options).and_return([template])
112
116
  allow(highline_cli).to receive(:apply_template?).and_return(false)
113
117
  expect(subject.send(:template_name_to_apply)).to eq(nil)
114
118
  end
115
119
  end
116
120
 
117
121
  context 'if there are multiple template options' do
122
+ let(:template1) { Faker::Lorem.word }
123
+ let(:template2) { Faker::Lorem.word }
124
+
118
125
  it 'should call the CLI to ask which of multiple templates to apply' do
119
- allow(subject).to receive(:pr_template_options).and_return(['template1', 'template2'])
120
- expect(highline_cli).to receive(:template_to_apply).and_return('template1')
126
+ allow(subject).to receive(:pr_template_options).and_return([template1, template2])
127
+ expect(highline_cli).to receive(:template_to_apply).and_return(template1)
121
128
  subject.send(:template_name_to_apply)
122
129
  end
123
130
 
124
131
  it 'should return the answer template if the user says yes' do
125
- allow(subject).to receive(:pr_template_options).and_return(['template1', 'template2'])
126
- allow(highline_cli).to receive(:template_to_apply).and_return('template1')
127
- expect(subject.send(:template_name_to_apply)).to eq('template1')
132
+ allow(subject).to receive(:pr_template_options).and_return([template1, template2])
133
+ allow(highline_cli).to receive(:template_to_apply).and_return(template1)
134
+ expect(subject.send(:template_name_to_apply)).to eq(template1)
128
135
  end
129
136
 
130
137
  it 'should return nil if the user says no' do
131
- allow(subject).to receive(:pr_template_options).and_return(['template1', 'template2'])
138
+ allow(subject).to receive(:pr_template_options).and_return([template1, template2])
132
139
  allow(highline_cli).to receive(:template_to_apply).and_return('None')
133
140
  expect(subject.send(:template_name_to_apply)).to eq(nil)
134
141
  end
@@ -144,13 +151,14 @@ describe GitHelper::GitHubPullRequest do
144
151
 
145
152
  describe '#pr_id' do
146
153
  it 'should ask the CLI for the code request ID' do
147
- expect(highline_cli).to receive(:code_request_id).and_return(123)
154
+ expect(highline_cli).to receive(:code_request_id).and_return(Faker::Number.number)
148
155
  subject.send(:pr_id)
149
156
  end
150
157
 
151
158
  it 'should equal an integer' do
152
- expect(highline_cli).to receive(:code_request_id).and_return(123)
153
- expect(subject.send(:pr_id)).to eq(123)
159
+ pr_id = Faker::Number.number
160
+ expect(highline_cli).to receive(:code_request_id).and_return(pr_id)
161
+ expect(subject.send(:pr_id)).to eq(pr_id)
154
162
  end
155
163
  end
156
164
 
@@ -172,7 +180,7 @@ describe GitHelper::GitHubPullRequest do
172
180
  expect(subject.send(:merge_method)).to be_a(String)
173
181
  end
174
182
 
175
- context "if there's only one item" do
183
+ context 'if theres only one item' do
176
184
  let(:project) { double(:project, allow_merge_commit: true, allow_squash_merge: false, allow_rebase_merge: false) }
177
185
 
178
186
  it 'should not ask the CLI anything' do
@@ -231,7 +239,7 @@ describe GitHelper::GitHubPullRequest do
231
239
 
232
240
  describe '#existing_pr' do
233
241
  it 'should call the octokit client' do
234
- allow(highline_cli).to receive(:code_request_id).and_return(123)
242
+ allow(highline_cli).to receive(:code_request_id).and_return(Faker::Number.number)
235
243
  expect(octokit_client_client).to receive(:pull_request).and_return(:pull_request)
236
244
  subject.send(:existing_pr)
237
245
  end
@@ -1,3 +1,5 @@
1
+ require 'faker'
2
+
1
3
  # This file was generated by the `rspec --init` command. Conventionally, all
2
4
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
5
  # The generated `.rspec` file contains `--require spec_helper` which will cause
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.0.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emma Sax
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-15 00:00:00.000000000 Z
11
+ date: 2021-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -72,14 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.1'
75
+ version: '2.2'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.1'
82
+ version: '2.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: faker
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.15'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.15'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: guard-rspec
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -132,7 +146,6 @@ extensions: []
132
146
  extra_rdoc_files: []
133
147
  files:
134
148
  - Gemfile
135
- - Gemfile.lock
136
149
  - Guardfile
137
150
  - LICENSE
138
151
  - README.md
@@ -189,23 +202,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
202
  - !ruby/object:Gem::Version
190
203
  version: '0'
191
204
  requirements: []
192
- rubygems_version: 3.1.4
205
+ rubygems_version: 3.2.3
193
206
  signing_key:
194
207
  specification_version: 4
195
208
  summary: A set of GitHub and GitLab workflow scripts.
196
209
  test_files:
197
210
  - spec/spec_helper.rb
198
- - spec/git_helper/octokit_client_spec.rb
199
- - spec/git_helper/new_branch_spec.rb
200
- - spec/git_helper/forget_local_commits_spec.rb
201
- - spec/git_helper/clean_branches_spec.rb
202
211
  - spec/git_helper/change_remote_spec.rb
203
212
  - spec/git_helper/checkout_default_spec.rb
204
- - spec/git_helper/pull_request_spec.rb
205
- - spec/git_helper/gitlab_client_spec.rb
213
+ - spec/git_helper/clean_branches_spec.rb
206
214
  - spec/git_helper/code_request_spec.rb
207
215
  - spec/git_helper/empty_commit_spec.rb
208
- - spec/git_helper/highline_cli_spec.rb
216
+ - spec/git_helper/forget_local_commits_spec.rb
209
217
  - spec/git_helper/git_config_reader_spec.rb
210
- - spec/git_helper/merge_request_spec.rb
218
+ - spec/git_helper/gitlab_client_spec.rb
219
+ - spec/git_helper/highline_cli_spec.rb
211
220
  - spec/git_helper/local_code_spec.rb
221
+ - spec/git_helper/merge_request_spec.rb
222
+ - spec/git_helper/new_branch_spec.rb
223
+ - spec/git_helper/octokit_client_spec.rb
224
+ - spec/git_helper/pull_request_spec.rb
@@ -1,101 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- git_helper (2.0.2)
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
- diff-lcs (1.4.4)
17
- faraday (1.0.1)
18
- multipart-post (>= 1.2, < 3)
19
- ffi (1.13.1)
20
- formatador (0.2.5)
21
- gitlab (4.16.1)
22
- httparty (~> 0.14, >= 0.14.0)
23
- terminal-table (~> 1.5, >= 1.5.1)
24
- gli (2.19.2)
25
- guard (2.16.2)
26
- formatador (>= 0.2.4)
27
- listen (>= 2.7, < 4.0)
28
- lumberjack (>= 1.0.12, < 2.0)
29
- nenv (~> 0.1)
30
- notiffany (~> 0.0)
31
- pry (>= 0.9.12)
32
- shellany (~> 0.0)
33
- thor (>= 0.18.1)
34
- guard-compat (1.2.1)
35
- guard-rspec (4.7.3)
36
- guard (~> 2.1)
37
- guard-compat (~> 1.1)
38
- rspec (>= 2.99.0, < 4.0)
39
- highline (2.0.3)
40
- httparty (0.18.1)
41
- mime-types (~> 3.0)
42
- multi_xml (>= 0.5.2)
43
- listen (3.2.1)
44
- rb-fsevent (~> 0.10, >= 0.10.3)
45
- rb-inotify (~> 0.9, >= 0.9.10)
46
- lumberjack (1.2.8)
47
- method_source (1.0.0)
48
- mime-types (3.3.1)
49
- mime-types-data (~> 3.2015)
50
- mime-types-data (3.2020.0512)
51
- multi_xml (0.6.0)
52
- multipart-post (2.1.1)
53
- nenv (0.3.0)
54
- notiffany (0.1.3)
55
- nenv (~> 0.1)
56
- shellany (~> 0.0)
57
- octokit (4.18.0)
58
- faraday (>= 0.9)
59
- sawyer (~> 0.8.0, >= 0.5.3)
60
- pry (0.13.1)
61
- coderay (~> 1.1)
62
- method_source (~> 1.0)
63
- public_suffix (4.0.6)
64
- rake (13.0.1)
65
- rb-fsevent (0.10.4)
66
- rb-inotify (0.10.1)
67
- ffi (~> 1.0)
68
- rspec (3.9.0)
69
- rspec-core (~> 3.9.0)
70
- rspec-expectations (~> 3.9.0)
71
- rspec-mocks (~> 3.9.0)
72
- rspec-core (3.9.3)
73
- rspec-support (~> 3.9.3)
74
- rspec-expectations (3.9.2)
75
- diff-lcs (>= 1.2.0, < 2.0)
76
- rspec-support (~> 3.9.0)
77
- rspec-mocks (3.9.1)
78
- diff-lcs (>= 1.2.0, < 2.0)
79
- rspec-support (~> 3.9.0)
80
- rspec-support (3.9.3)
81
- sawyer (0.8.2)
82
- addressable (>= 2.3.5)
83
- faraday (> 0.8, < 2.0)
84
- shellany (0.0.1)
85
- terminal-table (1.8.0)
86
- unicode-display_width (~> 1.1, >= 1.1.1)
87
- thor (1.0.1)
88
- unicode-display_width (1.7.0)
89
-
90
- PLATFORMS
91
- ruby
92
-
93
- DEPENDENCIES
94
- bundler (~> 2.1)
95
- git_helper!
96
- guard-rspec (~> 4.3)
97
- rake (~> 13.0)
98
- rspec (~> 3.9)
99
-
100
- BUNDLED WITH
101
- 2.1.4