git_helper 2.0.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,8 +3,10 @@ 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: 'name', branch: 'branch') }
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
 
@@ -15,8 +17,8 @@ describe GitHelper::CodeRequest do
15
17
 
16
18
  describe '#create' do
17
19
  before do
18
- allow(subject).to receive(:base_branch).and_return('base')
19
- allow(subject).to receive(:new_code_request_title).and_return('Title')
20
+ allow(subject).to receive(:base_branch).and_return(base_branch)
21
+ allow(subject).to receive(:new_code_request_title).and_return(title)
20
22
  end
21
23
 
22
24
  it 'should call to process the project' do
@@ -31,8 +33,8 @@ describe GitHelper::CodeRequest do
31
33
  end
32
34
 
33
35
  it 'should call base_branch and new_code_request_title' do
34
- expect(subject).to receive(:base_branch).and_return('base')
35
- expect(subject).to receive(:new_code_request_title).and_return('Title')
36
+ expect(subject).to receive(:base_branch).and_return(base_branch)
37
+ expect(subject).to receive(:new_code_request_title).and_return(title)
36
38
  allow(subject).to receive(:process_project).and_return(process_project)
37
39
  allow(process_project).to receive(:create)
38
40
  subject.create
@@ -132,7 +134,7 @@ describe GitHelper::CodeRequest do
132
134
 
133
135
  context 'when response is neither' do
134
136
  it 'should raise an error' do
135
- allow(highline_cli).to receive(:conflicting_remote_clarification).and_return('huh?')
137
+ allow(highline_cli).to receive(:conflicting_remote_clarification).and_return(Faker::Lorem.word)
136
138
  expect(subject).to receive(:exit)
137
139
  subject.send(:ask_for_clarification)
138
140
  end
@@ -171,28 +173,28 @@ describe GitHelper::CodeRequest do
171
173
  it 'should call the default branch' do
172
174
  expect(subject).to receive(:default_branch)
173
175
  allow(highline_cli).to receive(:base_branch_default?).at_least(:once)
174
- allow(highline_cli).to receive(:base_branch).at_least(:once).and_return('base')
176
+ allow(highline_cli).to receive(:base_branch).at_least(:once).and_return(base_branch)
175
177
  subject.send(:base_branch)
176
178
  end
177
179
 
178
180
  it 'should ask the CLI to ask the user' do
179
181
  allow(subject).to receive(:default_branch)
180
182
  expect(highline_cli).to receive(:base_branch_default?).at_least(:once)
181
- allow(highline_cli).to receive(:base_branch).at_least(:once).and_return('base')
183
+ allow(highline_cli).to receive(:base_branch).at_least(:once).and_return(base_branch)
182
184
  subject.send(:base_branch)
183
185
  end
184
186
 
185
187
  context 'if the user says no' do
186
- it "definitely asks for the user's base branch" do
188
+ it 'definitely asks for the users base branch' do
187
189
  allow(subject).to receive(:default_branch)
188
190
  expect(highline_cli).to receive(:base_branch_default?).at_least(:once).and_return(false)
189
- expect(highline_cli).to receive(:base_branch).at_least(:once).and_return('base')
191
+ expect(highline_cli).to receive(:base_branch).at_least(:once).and_return(base_branch)
190
192
  subject.send(:base_branch)
191
193
  end
192
194
  end
193
195
 
194
196
  context 'if the user says yes' do
195
- it "does not ask for the user's base branch" do
197
+ it 'does not ask for the users base branch' do
196
198
  allow(subject).to receive(:default_branch)
197
199
  expect(highline_cli).to receive(:base_branch_default?).at_least(:once).and_return(true)
198
200
  expect(highline_cli).not_to receive(:base_branch)
@@ -203,7 +205,7 @@ describe GitHelper::CodeRequest do
203
205
 
204
206
  describe '#autogenerated_title' do
205
207
  it 'should generate a title based on the branch' do
206
- expect(subject).to receive(:local_branch).and_return('branch')
208
+ expect(subject).to receive(:local_branch).and_return(Faker::Lorem.word)
207
209
  expect(local_code).to receive(:generate_title)
208
210
  subject.send(:autogenerated_title)
209
211
  end
@@ -213,28 +215,28 @@ describe GitHelper::CodeRequest do
213
215
  it 'should call autogenerated title method' do
214
216
  expect(subject).to receive(:autogenerated_title)
215
217
  allow(highline_cli).to receive(:accept_autogenerated_title?).at_least(:once)
216
- allow(highline_cli).to receive(:title).at_least(:once).and_return('Title')
218
+ allow(highline_cli).to receive(:title).at_least(:once).and_return(title)
217
219
  subject.send(:new_code_request_title)
218
220
  end
219
221
 
220
222
  it 'should ask the CLI to ask the user' do
221
223
  allow(subject).to receive(:autogenerated_title)
222
224
  expect(highline_cli).to receive(:accept_autogenerated_title?).at_least(:once)
223
- allow(highline_cli).to receive(:title).at_least(:once).and_return('Title')
225
+ allow(highline_cli).to receive(:title).at_least(:once).and_return(title)
224
226
  subject.send(:new_code_request_title)
225
227
  end
226
228
 
227
229
  context 'if the user says no' do
228
- it "definitely asks for the user's title" do
230
+ it 'definitely asks for the users title' do
229
231
  allow(subject).to receive(:autogenerated_title)
230
232
  expect(highline_cli).to receive(:accept_autogenerated_title?).at_least(:once).and_return(false)
231
- expect(highline_cli).to receive(:title).at_least(:once).and_return('Title')
233
+ expect(highline_cli).to receive(:title).at_least(:once).and_return(title)
232
234
  subject.send(:new_code_request_title)
233
235
  end
234
236
  end
235
237
 
236
238
  context 'if the user says yes to original title' do
237
- it "does not ask for the user's chosen title" do
239
+ it 'does not ask for the users chosen title' do
238
240
  allow(subject).to receive(:autogenerated_title)
239
241
  expect(highline_cli).to receive(:accept_autogenerated_title?).at_least(:once).and_return(true)
240
242
  expect(highline_cli).not_to receive(:title)
@@ -2,13 +2,14 @@ require 'spec_helper'
2
2
  require 'git_helper'
3
3
 
4
4
  describe GitHelper::GitConfigReader do
5
- let(:github_token) { '1234ASDF1234ASDF' }
6
- let(:gitlab_token) { 'ASDF123ASDF1234' }
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: 'github-user-name',
10
+ github_user: Faker::Internet.username,
10
11
  github_token: github_token,
11
- gitlab_user: 'gitlab-user-name',
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('/Users/firstnamelastname/path/to/git_helper')
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
- allow(Dir).to receive(:pwd).and_return('/Users/firstnamelastname/path/to/git_helper')
57
- expect(subject.send(:git_config_file_path)).to eq('/Users/firstnamelastname/.git_config.yml')
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
@@ -12,7 +12,7 @@ describe GitHelper::HighlineCli do
12
12
  end
13
13
 
14
14
  describe '#new_branch_name' do
15
- it "should ask the subject's ask method" do
15
+ it 'should ask the subjects ask method' do
16
16
  expect(subject).to receive(:ask).with('New branch name?')
17
17
  subject.new_branch_name
18
18
  end
@@ -23,34 +23,34 @@ describe GitHelper::HighlineCli do
23
23
  end
24
24
 
25
25
  describe '#process_directory_remotes' do
26
- it "should ask the subject's ask method" do
26
+ it 'should ask the subjects ask method' do
27
27
  expect(subject).to receive(:ask).and_return('y')
28
- subject.process_directory_remotes?('directory')
28
+ subject.process_directory_remotes?(Faker::Lorem.word)
29
29
  end
30
30
 
31
31
  it 'should be a boolean at the end' do
32
32
  allow(subject).to receive(:ask).and_return('y')
33
- expect([true, false]).to include(subject.process_directory_remotes?('directory'))
33
+ expect([true, false]).to include(subject.process_directory_remotes?(Faker::Lorem.word))
34
34
  end
35
35
 
36
36
  it 'should come out as a true boolean if somebody responds y' do
37
37
  allow(subject).to receive(:ask).and_return('y')
38
- expect(subject.process_directory_remotes?('directory')).to eq(true)
38
+ expect(subject.process_directory_remotes?(Faker::Lorem.word)).to eq(true)
39
39
  end
40
40
 
41
41
  it 'should come out as a false boolean if somebody responds n' do
42
42
  allow(subject).to receive(:ask).and_return('n')
43
- expect(subject.process_directory_remotes?('directory')).to eq(false)
43
+ expect(subject.process_directory_remotes?(Faker::Lorem.word)).to eq(false)
44
44
  end
45
45
 
46
46
  it 'should come out as true if somebody presses enter' do
47
47
  allow(subject).to receive(:ask).and_return('')
48
- expect(subject.accept_autogenerated_title?('directory')).to eq(true)
48
+ expect(subject.accept_autogenerated_title?(Faker::Lorem.word)).to eq(true)
49
49
  end
50
50
  end
51
51
 
52
52
  describe '#conflicting_remote_clarification' do
53
- it "should ask the subject's ask method" do
53
+ it 'should ask the subjects ask method' do
54
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
55
  subject.conflicting_remote_clarification
56
56
  end
@@ -61,7 +61,7 @@ describe GitHelper::HighlineCli do
61
61
  end
62
62
 
63
63
  describe '#title' do
64
- it "should ask the subject's ask method" do
64
+ it 'should ask the subjects ask method' do
65
65
  expect(subject).to receive(:ask).with('Title?')
66
66
  subject.title
67
67
  end
@@ -72,7 +72,7 @@ describe GitHelper::HighlineCli do
72
72
  end
73
73
 
74
74
  describe '#base_branch' do
75
- it "should ask the subject's ask method" do
75
+ it 'should ask the subjects ask method' do
76
76
  expect(subject).to receive(:ask).with('Base branch?')
77
77
  subject.base_branch
78
78
  end
@@ -83,92 +83,94 @@ describe GitHelper::HighlineCli do
83
83
  end
84
84
 
85
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')
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)
89
91
  end
90
92
 
91
93
  it 'should come out a string' do
92
- expect(subject.code_request_id('Example')).to be_a(String)
94
+ expect(subject.code_request_id(phrase)).to be_a(String)
93
95
  end
94
96
  end
95
97
 
96
98
  describe '#accept_autogenerated_title' do
97
- it "should ask the subject's ask method" do
99
+ it 'should ask the subjects ask method' do
98
100
  expect(subject).to receive(:ask).and_return('y')
99
- subject.accept_autogenerated_title?('Title Example')
101
+ subject.accept_autogenerated_title?(Faker::Lorem.sentence)
100
102
  end
101
103
 
102
104
  it 'should be a boolean at the end' do
103
105
  allow(subject).to receive(:ask).and_return('y')
104
- expect([true, false]).to include(subject.accept_autogenerated_title?('Title Example'))
106
+ expect([true, false]).to include(subject.accept_autogenerated_title?(Faker::Lorem.sentence))
105
107
  end
106
108
 
107
109
  it 'should come out as a true boolean if somebody responds y' do
108
110
  allow(subject).to receive(:ask).and_return('y')
109
- expect(subject.accept_autogenerated_title?('Title Example')).to eq(true)
111
+ expect(subject.accept_autogenerated_title?(Faker::Lorem.sentence)).to eq(true)
110
112
  end
111
113
 
112
114
  it 'should come out as a true boolean if somebody responds n' do
113
115
  allow(subject).to receive(:ask).and_return('n')
114
- expect(subject.accept_autogenerated_title?('Title Example')).to eq(false)
116
+ expect(subject.accept_autogenerated_title?(Faker::Lorem.sentence)).to eq(false)
115
117
  end
116
118
 
117
119
  it 'should come out as a true boolean if somebody responds yes' do
118
120
  allow(subject).to receive(:ask).and_return('yes')
119
- expect(subject.accept_autogenerated_title?('Title Example')).to eq(true)
121
+ expect(subject.accept_autogenerated_title?(Faker::Lorem.sentence)).to eq(true)
120
122
  end
121
123
 
122
124
  it 'should come out as a false boolean if somebody responds no' do
123
125
  allow(subject).to receive(:ask).and_return('no')
124
- expect(subject.accept_autogenerated_title?('Title Example')).to eq(false)
126
+ expect(subject.accept_autogenerated_title?(Faker::Lorem.sentence)).to eq(false)
125
127
  end
126
128
 
127
129
  it 'should come out as true if somebody presses enter' do
128
130
  allow(subject).to receive(:ask).and_return('')
129
- expect(subject.accept_autogenerated_title?('Title Example')).to eq(true)
131
+ expect(subject.accept_autogenerated_title?(Faker::Lorem.sentence)).to eq(true)
130
132
  end
131
133
  end
132
134
 
133
135
  describe '#base_branch_default' do
134
- it "should ask the subject's ask method" do
136
+ it 'should ask the subjects ask method' do
135
137
  expect(subject).to receive(:ask).and_return('y')
136
- subject.base_branch_default?('default_branch')
138
+ subject.base_branch_default?(Faker::Lorem.word)
137
139
  end
138
140
 
139
141
  it 'should be a boolean at the end' do
140
142
  allow(subject).to receive(:ask).and_return('y')
141
- expect([true, false]).to include(subject.base_branch_default?('default_branch'))
143
+ expect([true, false]).to include(subject.base_branch_default?(Faker::Lorem.word))
142
144
  end
143
145
 
144
146
  it 'should come out as a true boolean if somebody responds y' do
145
147
  allow(subject).to receive(:ask).and_return('y')
146
- expect(subject.base_branch_default?('default_branch')).to eq(true)
148
+ expect(subject.base_branch_default?(Faker::Lorem.word)).to eq(true)
147
149
  end
148
150
 
149
151
  it 'should come out as a true boolean if somebody responds n' do
150
152
  allow(subject).to receive(:ask).and_return('n')
151
- expect(subject.base_branch_default?('default_branch')).to eq(false)
153
+ expect(subject.base_branch_default?(Faker::Lorem.word)).to eq(false)
152
154
  end
153
155
 
154
156
  it 'should come out as a true boolean if somebody responds yes' do
155
157
  allow(subject).to receive(:ask).and_return('yes')
156
- expect(subject.base_branch_default?('default_branch')).to eq(true)
158
+ expect(subject.base_branch_default?(Faker::Lorem.word)).to eq(true)
157
159
  end
158
160
 
159
161
  it 'should come out as a false boolean if somebody responds no' do
160
162
  allow(subject).to receive(:ask).and_return('no')
161
- expect(subject.base_branch_default?('default_branch')).to eq(false)
163
+ expect(subject.base_branch_default?(Faker::Lorem.word)).to eq(false)
162
164
  end
163
165
 
164
166
  it 'should come out as true if somebody presses enter' do
165
167
  allow(subject).to receive(:ask).and_return('')
166
- expect(subject.base_branch_default?('default_branch')).to eq(true)
168
+ expect(subject.base_branch_default?(Faker::Lorem.word)).to eq(true)
167
169
  end
168
170
  end
169
171
 
170
172
  describe '#merge_method' do
171
- it "should ask the subject's ask_options method" do
173
+ it 'should ask the subjects ask_options method' do
172
174
  expect(subject).to receive(:ask_options).and_return(3)
173
175
  subject.merge_method(['1', '2', '3'])
174
176
  end
@@ -180,7 +182,7 @@ describe GitHelper::HighlineCli do
180
182
  end
181
183
 
182
184
  describe '#template_to_apply' do
183
- it "should ask the subject's ask_options method" do
185
+ it 'should ask the subjects ask_options method' do
184
186
  expect(subject).to receive(:ask_options).and_return(3)
185
187
  subject.template_to_apply(['option1', 'option2', 'option3'], 'example type')
186
188
  end
@@ -194,22 +196,22 @@ describe GitHelper::HighlineCli do
194
196
  describe '#ask' do
195
197
  it 'should ask the highline client ask'do
196
198
  expect(highline_client).to receive(:ask)
197
- subject.send(:ask, 'prompt goes here')
199
+ subject.send(:ask, Faker::Lorem.sentence)
198
200
  end
199
201
 
200
202
  it 'should return a string' do
201
- expect(subject.send(:ask, 'prompt goes here')).to be_a(String)
203
+ expect(subject.send(:ask, Faker::Lorem.sentence)).to be_a(String)
202
204
  end
203
205
  end
204
206
 
205
207
  describe '#ask_options' do
206
208
  it 'should ask the highline client ask'do
207
209
  expect(highline_client).to receive(:ask)
208
- subject.send(:ask_options, 'prompt goes here', ['1', '2', '3'])
210
+ subject.send(:ask_options, Faker::Lorem.sentence, ['1', '2', '3'])
209
211
  end
210
212
 
211
213
  it 'should return an integer' do
212
- expect(subject.send(:ask_options, 'prompt goes here', ['1', '2', '3'])).to be_a(Integer)
214
+ expect(subject.send(:ask_options, Faker::Lorem.sentence, ['1', '2', '3'])).to be_a(Integer)
213
215
  end
214
216
  end
215
217
  end
@@ -4,11 +4,24 @@ require 'git_helper'
4
4
  describe GitHelper::LocalCode do
5
5
  let(:response) { double(:response, readline: true, to_i: 5) }
6
6
  let(:local_codeent) { double(:local_code, ask: response) }
7
- let(:ssh_remote) { 'origin\tgit@github.com:emmasax4/git_helper.git (fetch)' }
8
- let(:https_remote) { 'origin\thttps://github.com/emmasax4/git_helper.git (fetch)' }
9
- let(:github_remotes) { ['origin\tgit@github.com:emmasax4/git_helper.git (fetch)', 'origin\thttps://github.com/emmasax4/git_helper.git (fetch)' ] }
10
- let(:gitlab_remotes) { ['origin\tgit@gitlab.com:emmasax4/git_helper.git (fetch)', 'origin\thttps://gitlab.com/emmasax4/git_helper.git (fetch)' ] }
7
+ let(:project_name) { Faker::Lorem.word }
8
+ let(:owner) { Faker::Name.first_name }
9
+ let(:ssh_remote) { "origin\tgit@github.com:#{owner}/#{project_name}.git (fetch)" }
10
+ let(:https_remote) { "origin\thttps://github.com/#{owner}/#{project_name}.git (fetch)" }
11
+
12
+ let(:github_remotes) do
13
+ [
14
+ "origin\tgit@github.com:#{owner}/#{project_name}.git (fetch)",
15
+ "origin\thttps://github.com/#{owner}/#{project_name}.git (fetch)"
16
+ ]
17
+ end
11
18
 
19
+ let(:gitlab_remotes) do
20
+ [
21
+ "origin\tgit@gitlab.com:#{owner}/#{project_name}.git (fetch)",
22
+ "origin\thttps://gitlab.com/#{owner}/#{project_name}.git (fetch)"
23
+ ]
24
+ end
12
25
 
13
26
  subject { GitHelper::LocalCode.new }
14
27
 
@@ -51,13 +64,13 @@ describe GitHelper::LocalCode do
51
64
  describe '#new_branch' do
52
65
  it 'should make a system call' do
53
66
  expect(subject).to receive(:system).exactly(4).times
54
- subject.new_branch('branch_name')
67
+ subject.new_branch(Faker::Lorem.word)
55
68
  end
56
69
  end
57
70
 
58
71
  describe '#change_remote' do
59
72
  it 'should return a string' do
60
- expect(subject.change_remote('name', 'url')).to be_a(String)
73
+ expect(subject.change_remote(Faker::Lorem.word, Faker::Internet.url)).to be_a(String)
61
74
  end
62
75
  end
63
76
 
@@ -96,11 +109,11 @@ describe GitHelper::LocalCode do
96
109
 
97
110
  describe '#remote_project' do
98
111
  it 'should return just the plain project if ssh' do
99
- expect(subject.remote_project(ssh_remote)).to eq('git_helper')
112
+ expect(subject.remote_project(ssh_remote)).to eq(project_name)
100
113
  end
101
114
 
102
115
  it 'should return just the plain project if https' do
103
- expect(subject.remote_project(https_remote)).to eq('git_helper')
116
+ expect(subject.remote_project(https_remote)).to eq(project_name)
104
117
  end
105
118
  end
106
119
 
@@ -144,8 +157,8 @@ describe GitHelper::LocalCode do
144
157
  end
145
158
 
146
159
  it 'should equal this project name' do
147
- allow_any_instance_of(String).to receive(:scan).and_return([['emmasax4/git_helper']])
148
- expect(subject.project_name).to eq('emmasax4/git_helper')
160
+ allow_any_instance_of(String).to receive(:scan).and_return([["#{owner}/#{project_name}"]])
161
+ expect(subject.project_name).to eq("#{owner}/#{project_name}")
149
162
  end
150
163
  end
151
164
 
@@ -164,6 +177,7 @@ describe GitHelper::LocalCode do
164
177
  describe '#template_options' do
165
178
  let(:template_identifiers) do
166
179
  {
180
+ template_directory: '.github',
167
181
  nested_directory_name: 'PULL_REQUEST_TEMPLATE',
168
182
  non_nested_file_name: 'pull_request_template'
169
183
  }
@@ -189,43 +203,65 @@ describe GitHelper::LocalCode do
189
203
 
190
204
  describe '#generate_title' do
191
205
  it 'should return a title based on the branch' do
192
- branch = 'jira-123-test-branch'
193
- expect(subject.generate_title(branch)).to eq('JIRA-123 Test branch')
206
+ prefix = Faker::Lorem.word
207
+ word1 = Faker::Lorem.word
208
+ word2 = Faker::Lorem.word
209
+ description = [word1, word2].join('-')
210
+ branch = "#{prefix}-123-#{description}"
211
+ expect(subject.generate_title(branch)).to eq("#{prefix.upcase}-123 #{[word1.capitalize, word2].join(' ')}")
194
212
  end
195
213
 
196
214
  it 'should return a title based on the branch' do
197
- branch = 'jira_123_test_branch'
198
- expect(subject.generate_title(branch)).to eq('JIRA-123 Test branch')
215
+ prefix = Faker::Lorem.word
216
+ word1 = Faker::Lorem.word
217
+ word2 = Faker::Lorem.word
218
+ description = [word1, word2].join('_')
219
+ branch = "#{prefix}_123_#{description}"
220
+ expect(subject.generate_title(branch)).to eq("#{prefix.upcase}-123 #{[word1.capitalize, word2].join(' ')}")
199
221
  end
200
222
 
201
223
  it 'should return a title based on the branch' do
202
- branch = 'jira-123_test_branch'
203
- expect(subject.generate_title(branch)).to eq('JIRA-123 Test branch')
224
+ prefix = Faker::Lorem.word
225
+ word1 = Faker::Lorem.word
226
+ word2 = Faker::Lorem.word
227
+ description = [word1, word2].join('_')
228
+ branch = "#{prefix}-123_#{description}"
229
+ expect(subject.generate_title(branch)).to eq("#{prefix.upcase}-123 #{[word1.capitalize, word2].join(' ')}")
204
230
  end
205
231
 
206
232
  it 'should return a title based on the branch' do
207
- branch = 'test_branch'
208
- expect(subject.generate_title(branch)).to eq('Test branch')
233
+ word1 = Faker::Lorem.word
234
+ word2 = Faker::Lorem.word
235
+ branch = [word1, word2].join('_')
236
+ expect(subject.generate_title(branch)).to eq([word1.capitalize, word2].join(' '))
209
237
  end
210
238
 
211
239
  it 'should return a title based on the branch' do
212
- branch = 'test-branch'
213
- expect(subject.generate_title(branch)).to eq('Test branch')
240
+ word1 = Faker::Lorem.word
241
+ word2 = Faker::Lorem.word
242
+ branch = [word1, word2].join('-')
243
+ expect(subject.generate_title(branch)).to eq([word1.capitalize, word2].join(' '))
214
244
  end
215
245
 
216
246
  it 'should return a title based on the branch' do
217
- branch = 'test'
218
- expect(subject.generate_title(branch)).to eq('Test')
247
+ branch = Faker::Lorem.word
248
+ expect(subject.generate_title(branch)).to eq(branch.capitalize)
219
249
  end
220
250
 
221
251
  it 'should return a title based on the branch' do
222
- branch = 'some_other_words_in_this_test_branch'
223
- expect(subject.generate_title(branch)).to eq('Some other words in this test branch')
252
+ word1 = Faker::Lorem.word
253
+ word2 = Faker::Lorem.word
254
+ word3 = Faker::Lorem.word
255
+ branch = [word1, word2, word3].join('_')
256
+ expect(subject.generate_title(branch)).to eq([word1.capitalize, word2, word3].join(' '))
224
257
  end
225
258
 
226
259
  it 'should return a title based on the branch' do
227
- branch = 'some-other-words-in-this-test-branch'
228
- expect(subject.generate_title(branch)).to eq('Some other words in this test branch')
260
+ word1 = Faker::Lorem.word
261
+ word2 = Faker::Lorem.word
262
+ word3 = Faker::Lorem.word
263
+ branch = [word1, word2, word3].join('-')
264
+ expect(subject.generate_title(branch)).to eq([word1.capitalize, word2, word3].join(' '))
229
265
  end
230
266
  end
231
267
  end