git_helper 2.0.2 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,20 +3,23 @@ require 'git_helper'
3
3
 
4
4
  describe GitHelper::CodeRequest do
5
5
  let(:highline_cli) { double(:highline_cli) }
6
- let(:local_code) { double(:local_code, project_name: '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
 
11
13
  before do
12
14
  allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
13
15
  allow(GitHelper::HighlineCli).to receive(:new).and_return(highline_cli)
16
+ allow(subject).to receive(:puts)
14
17
  end
15
18
 
16
19
  describe '#create' do
17
20
  before do
18
- allow(subject).to receive(:base_branch).and_return('base')
19
- allow(subject).to receive(:new_code_request_title).and_return('Title')
21
+ allow(subject).to receive(:base_branch).and_return(base_branch)
22
+ allow(subject).to receive(:new_code_request_title).and_return(title)
20
23
  end
21
24
 
22
25
  it 'should call to process the project' do
@@ -31,8 +34,8 @@ describe GitHelper::CodeRequest do
31
34
  end
32
35
 
33
36
  it 'should call base_branch and new_code_request_title' do
34
- expect(subject).to receive(:base_branch).and_return('base')
35
- expect(subject).to receive(:new_code_request_title).and_return('Title')
37
+ expect(subject).to receive(:base_branch).and_return(base_branch)
38
+ expect(subject).to receive(:new_code_request_title).and_return(title)
36
39
  allow(subject).to receive(:process_project).and_return(process_project)
37
40
  allow(process_project).to receive(:create)
38
41
  subject.create
@@ -132,7 +135,7 @@ describe GitHelper::CodeRequest do
132
135
 
133
136
  context 'when response is neither' do
134
137
  it 'should raise an error' do
135
- allow(highline_cli).to receive(:conflicting_remote_clarification).and_return('huh?')
138
+ allow(highline_cli).to receive(:conflicting_remote_clarification).and_return(Faker::Lorem.word)
136
139
  expect(subject).to receive(:exit)
137
140
  subject.send(:ask_for_clarification)
138
141
  end
@@ -171,28 +174,28 @@ describe GitHelper::CodeRequest do
171
174
  it 'should call the default branch' do
172
175
  expect(subject).to receive(:default_branch)
173
176
  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')
177
+ allow(highline_cli).to receive(:base_branch).at_least(:once).and_return(base_branch)
175
178
  subject.send(:base_branch)
176
179
  end
177
180
 
178
181
  it 'should ask the CLI to ask the user' do
179
182
  allow(subject).to receive(:default_branch)
180
183
  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')
184
+ allow(highline_cli).to receive(:base_branch).at_least(:once).and_return(base_branch)
182
185
  subject.send(:base_branch)
183
186
  end
184
187
 
185
188
  context 'if the user says no' do
186
- it "definitely asks for the user's base branch" do
189
+ it 'definitely asks for the users base branch' do
187
190
  allow(subject).to receive(:default_branch)
188
191
  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')
192
+ expect(highline_cli).to receive(:base_branch).at_least(:once).and_return(base_branch)
190
193
  subject.send(:base_branch)
191
194
  end
192
195
  end
193
196
 
194
197
  context 'if the user says yes' do
195
- it "does not ask for the user's base branch" do
198
+ it 'does not ask for the users base branch' do
196
199
  allow(subject).to receive(:default_branch)
197
200
  expect(highline_cli).to receive(:base_branch_default?).at_least(:once).and_return(true)
198
201
  expect(highline_cli).not_to receive(:base_branch)
@@ -203,7 +206,7 @@ describe GitHelper::CodeRequest do
203
206
 
204
207
  describe '#autogenerated_title' do
205
208
  it 'should generate a title based on the branch' do
206
- expect(subject).to receive(:local_branch).and_return('branch')
209
+ expect(subject).to receive(:local_branch).and_return(Faker::Lorem.word)
207
210
  expect(local_code).to receive(:generate_title)
208
211
  subject.send(:autogenerated_title)
209
212
  end
@@ -213,28 +216,28 @@ describe GitHelper::CodeRequest do
213
216
  it 'should call autogenerated title method' do
214
217
  expect(subject).to receive(:autogenerated_title)
215
218
  allow(highline_cli).to receive(:accept_autogenerated_title?).at_least(:once)
216
- allow(highline_cli).to receive(:title).at_least(:once).and_return('Title')
219
+ allow(highline_cli).to receive(:title).at_least(:once).and_return(title)
217
220
  subject.send(:new_code_request_title)
218
221
  end
219
222
 
220
223
  it 'should ask the CLI to ask the user' do
221
224
  allow(subject).to receive(:autogenerated_title)
222
225
  expect(highline_cli).to receive(:accept_autogenerated_title?).at_least(:once)
223
- allow(highline_cli).to receive(:title).at_least(:once).and_return('Title')
226
+ allow(highline_cli).to receive(:title).at_least(:once).and_return(title)
224
227
  subject.send(:new_code_request_title)
225
228
  end
226
229
 
227
230
  context 'if the user says no' do
228
- it "definitely asks for the user's title" do
231
+ it 'definitely asks for the users title' do
229
232
  allow(subject).to receive(:autogenerated_title)
230
233
  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')
234
+ expect(highline_cli).to receive(:title).at_least(:once).and_return(title)
232
235
  subject.send(:new_code_request_title)
233
236
  end
234
237
  end
235
238
 
236
239
  context 'if the user says yes to original title' do
237
- it "does not ask for the user's chosen title" do
240
+ it 'does not ask for the users chosen title' do
238
241
  allow(subject).to receive(:autogenerated_title)
239
242
  expect(highline_cli).to receive(:accept_autogenerated_title?).at_least(:once).and_return(true)
240
243
  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,14 @@ 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
+ allow(subject).to receive(:`).and_return(Faker::Lorem.word)
74
+ expect(subject.change_remote(Faker::Lorem.word, Faker::Internet.url)).to be_a(String)
61
75
  end
62
76
  end
63
77
 
@@ -96,11 +110,11 @@ describe GitHelper::LocalCode do
96
110
 
97
111
  describe '#remote_project' do
98
112
  it 'should return just the plain project if ssh' do
99
- expect(subject.remote_project(ssh_remote)).to eq('git_helper')
113
+ expect(subject.remote_project(ssh_remote)).to eq(project_name)
100
114
  end
101
115
 
102
116
  it 'should return just the plain project if https' do
103
- expect(subject.remote_project(https_remote)).to eq('git_helper')
117
+ expect(subject.remote_project(https_remote)).to eq(project_name)
104
118
  end
105
119
  end
106
120
 
@@ -144,8 +158,8 @@ describe GitHelper::LocalCode do
144
158
  end
145
159
 
146
160
  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')
161
+ allow_any_instance_of(String).to receive(:scan).and_return([["#{owner}/#{project_name}"]])
162
+ expect(subject.project_name).to eq("#{owner}/#{project_name}")
149
163
  end
150
164
  end
151
165
 
@@ -164,6 +178,7 @@ describe GitHelper::LocalCode do
164
178
  describe '#template_options' do
165
179
  let(:template_identifiers) do
166
180
  {
181
+ template_directory: '.github',
167
182
  nested_directory_name: 'PULL_REQUEST_TEMPLATE',
168
183
  non_nested_file_name: 'pull_request_template'
169
184
  }
@@ -189,43 +204,65 @@ describe GitHelper::LocalCode do
189
204
 
190
205
  describe '#generate_title' do
191
206
  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')
207
+ prefix = Faker::Lorem.word
208
+ word1 = Faker::Lorem.word
209
+ word2 = Faker::Lorem.word
210
+ description = [word1, word2].join('-')
211
+ branch = "#{prefix}-123-#{description}"
212
+ expect(subject.generate_title(branch)).to eq("#{prefix.upcase}-123 #{[word1.capitalize, word2].join(' ')}")
194
213
  end
195
214
 
196
215
  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')
216
+ prefix = Faker::Lorem.word
217
+ word1 = Faker::Lorem.word
218
+ word2 = Faker::Lorem.word
219
+ description = [word1, word2].join('_')
220
+ branch = "#{prefix}_123_#{description}"
221
+ expect(subject.generate_title(branch)).to eq("#{prefix.upcase}-123 #{[word1.capitalize, word2].join(' ')}")
199
222
  end
200
223
 
201
224
  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')
225
+ prefix = Faker::Lorem.word
226
+ word1 = Faker::Lorem.word
227
+ word2 = Faker::Lorem.word
228
+ description = [word1, word2].join('_')
229
+ branch = "#{prefix}-123_#{description}"
230
+ expect(subject.generate_title(branch)).to eq("#{prefix.upcase}-123 #{[word1.capitalize, word2].join(' ')}")
204
231
  end
205
232
 
206
233
  it 'should return a title based on the branch' do
207
- branch = 'test_branch'
208
- expect(subject.generate_title(branch)).to eq('Test branch')
234
+ word1 = Faker::Lorem.word
235
+ word2 = Faker::Lorem.word
236
+ branch = [word1, word2].join('_')
237
+ expect(subject.generate_title(branch)).to eq([word1.capitalize, word2].join(' '))
209
238
  end
210
239
 
211
240
  it 'should return a title based on the branch' do
212
- branch = 'test-branch'
213
- expect(subject.generate_title(branch)).to eq('Test branch')
241
+ word1 = Faker::Lorem.word
242
+ word2 = Faker::Lorem.word
243
+ branch = [word1, word2].join('-')
244
+ expect(subject.generate_title(branch)).to eq([word1.capitalize, word2].join(' '))
214
245
  end
215
246
 
216
247
  it 'should return a title based on the branch' do
217
- branch = 'test'
218
- expect(subject.generate_title(branch)).to eq('Test')
248
+ branch = Faker::Lorem.word
249
+ expect(subject.generate_title(branch)).to eq(branch.capitalize)
219
250
  end
220
251
 
221
252
  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')
253
+ word1 = Faker::Lorem.word
254
+ word2 = Faker::Lorem.word
255
+ word3 = Faker::Lorem.word
256
+ branch = [word1, word2, word3].join('_')
257
+ expect(subject.generate_title(branch)).to eq([word1.capitalize, word2, word3].join(' '))
224
258
  end
225
259
 
226
260
  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')
261
+ word1 = Faker::Lorem.word
262
+ word2 = Faker::Lorem.word
263
+ word3 = Faker::Lorem.word
264
+ branch = [word1, word2, word3].join('-')
265
+ expect(subject.generate_title(branch)).to eq([word1.capitalize, word2, word3].join(' '))
229
266
  end
230
267
  end
231
268
  end