git_reflow 0.8.9 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/multi-ruby-tests.yml +33 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +2 -0
  5. data/.ruby-version +1 -0
  6. data/Appraisals +1 -6
  7. data/CHANGELOG.md +466 -348
  8. data/Gemfile.lock +99 -72
  9. data/LICENSE +20 -20
  10. data/README.md +481 -0
  11. data/Rakefile +15 -8
  12. data/Workflow +3 -0
  13. data/_config.yml +1 -0
  14. data/bin/console +7 -7
  15. data/bin/setup +6 -6
  16. data/exe/git-reflow +20 -36
  17. data/git_reflow.gemspec +26 -30
  18. data/lib/git_reflow.rb +3 -15
  19. data/lib/git_reflow/config.rb +48 -13
  20. data/lib/git_reflow/git_helpers.rb +69 -22
  21. data/lib/git_reflow/git_server.rb +63 -63
  22. data/lib/git_reflow/git_server/base.rb +68 -68
  23. data/lib/git_reflow/git_server/bit_bucket.rb +101 -101
  24. data/lib/git_reflow/git_server/bit_bucket/pull_request.rb +84 -84
  25. data/lib/git_reflow/git_server/git_hub.rb +53 -41
  26. data/lib/git_reflow/git_server/git_hub/pull_request.rb +16 -14
  27. data/lib/git_reflow/git_server/pull_request.rb +4 -2
  28. data/lib/git_reflow/merge_error.rb +9 -9
  29. data/lib/git_reflow/rspec.rb +3 -2
  30. data/lib/git_reflow/rspec/command_line_helpers.rb +23 -6
  31. data/lib/git_reflow/rspec/stub_helpers.rb +13 -13
  32. data/lib/git_reflow/rspec/workflow_helpers.rb +18 -0
  33. data/lib/git_reflow/sandbox.rb +16 -6
  34. data/lib/git_reflow/version.rb +1 -1
  35. data/lib/git_reflow/workflow.rb +304 -9
  36. data/lib/git_reflow/workflows/FlatMergeWorkflow +38 -0
  37. data/lib/git_reflow/workflows/core.rb +364 -238
  38. data/spec/fixtures/authentication_failure.json +3 -0
  39. data/spec/fixtures/awesome_workflow.rb +3 -7
  40. data/spec/fixtures/git/git_config +7 -7
  41. data/spec/fixtures/issues/comment.json.erb +27 -27
  42. data/spec/fixtures/issues/comments.json +29 -29
  43. data/spec/fixtures/issues/comments.json.erb +15 -15
  44. data/spec/fixtures/pull_requests/comment.json.erb +45 -45
  45. data/spec/fixtures/pull_requests/comments.json +47 -47
  46. data/spec/fixtures/pull_requests/comments.json.erb +15 -15
  47. data/spec/fixtures/pull_requests/commits.json +29 -29
  48. data/spec/fixtures/pull_requests/external_pull_request.json +145 -145
  49. data/spec/fixtures/pull_requests/pull_request.json +142 -142
  50. data/spec/fixtures/pull_requests/pull_request.json.erb +142 -142
  51. data/spec/fixtures/pull_requests/pull_request_branch_nonexistent_error.json +32 -0
  52. data/spec/fixtures/pull_requests/pull_request_exists_error.json +32 -32
  53. data/spec/fixtures/pull_requests/pull_requests.json +136 -136
  54. data/spec/fixtures/repositories/commit.json +53 -53
  55. data/spec/fixtures/repositories/commit.json.erb +53 -53
  56. data/spec/fixtures/repositories/commits.json.erb +13 -13
  57. data/spec/fixtures/repositories/statuses.json +31 -31
  58. data/spec/fixtures/users/user.json +32 -0
  59. data/spec/lib/git_reflow/git_helpers_spec.rb +115 -12
  60. data/spec/lib/git_reflow/git_server/bit_bucket_spec.rb +81 -81
  61. data/spec/lib/git_reflow/git_server/git_hub/pull_request_spec.rb +10 -10
  62. data/spec/lib/git_reflow/git_server/git_hub_spec.rb +77 -3
  63. data/spec/lib/git_reflow/git_server/pull_request_spec.rb +9 -3
  64. data/spec/lib/git_reflow/git_server_spec.rb +101 -101
  65. data/spec/lib/git_reflow/sandbox_spec.rb +1 -1
  66. data/spec/lib/git_reflow/workflow_spec.rb +304 -59
  67. data/spec/lib/git_reflow/workflows/core_spec.rb +225 -67
  68. data/spec/lib/git_reflow/workflows/flat_merge_spec.rb +71 -59
  69. data/spec/lib/git_reflow_spec.rb +2 -25
  70. data/spec/spec_helper.rb +3 -0
  71. data/spec/support/fixtures.rb +54 -54
  72. data/spec/support/github_helpers.rb +99 -109
  73. data/spec/support/mock_pull_request.rb +17 -17
  74. data/spec/support/web_mocks.rb +39 -39
  75. metadata +51 -74
  76. data/README.rdoc +0 -461
  77. data/circle.yml +0 -26
  78. data/lib/git_reflow/commands/deliver.rb +0 -10
  79. data/lib/git_reflow/commands/refresh.rb +0 -20
  80. data/lib/git_reflow/commands/review.rb +0 -13
  81. data/lib/git_reflow/commands/setup.rb +0 -11
  82. data/lib/git_reflow/commands/stage.rb +0 -9
  83. data/lib/git_reflow/commands/start.rb +0 -18
  84. data/lib/git_reflow/commands/status.rb +0 -7
  85. data/lib/git_reflow/os_detector.rb +0 -23
  86. data/lib/git_reflow/workflows/flat_merge.rb +0 -10
  87. data/spec/fixtures/workflow_with_super.rb +0 -8
@@ -1,81 +1,81 @@
1
- require 'spec_helper'
2
-
3
- describe GitReflow::GitServer::BitBucket do
4
- let(:user) { 'reenhanced' }
5
- let(:password) { 'shazam' }
6
- let(:repo) { 'repo' }
7
- let(:api_key) { 'a1b2c3d4e5f6g7h8i9j0' }
8
- let(:hostname) { 'hostname.local' }
9
- let(:api_endpoint) { 'https://bitbucket.org/api/1.0' }
10
- let(:site) { 'https://bitbucket.org' }
11
- let(:remote_url) { "git@bitbucket.org:#{user}/#{repo}.git" }
12
-
13
- before do
14
- allow_any_instance_of(HighLine).to receive(:ask) do |terminal, question|
15
- values = {
16
- "Please enter your BitBucket username: " => user
17
- }
18
- return_value = values[question]
19
- question = ""
20
- return_value
21
- end
22
- end
23
-
24
- describe '#initialize(options)' do
25
- subject { GitReflow::GitServer::BitBucket.new({}) }
26
-
27
- it 'sets the reflow git server provider to BitBucket in the git config' do
28
- expect(GitReflow::Config).to receive(:set).once.with('reflow.git-server', 'BitBucket', local: false)
29
- subject
30
- end
31
-
32
- context 'storing git config settings only for this project' do
33
- subject { GitReflow::GitServer::BitBucket.new(project_only: true) }
34
-
35
- it 'sets the enterprise site and api as the site and api endpoints for the BitBucket provider in the git config' do
36
- expect(GitReflow::Config).to receive(:set).once.with('reflow.git-server', 'BitBucket', local: true)
37
- subject
38
- end
39
- end
40
-
41
- end
42
-
43
- describe '#authenticate' do
44
- let(:bitbucket) { GitReflow::GitServer::BitBucket.new( { }) }
45
- let!(:bitbucket_api) { BitBucket.new }
46
- subject { bitbucket.authenticate }
47
-
48
- context 'already authenticated' do
49
- it "notifies the user of successful setup" do
50
- allow(GitReflow::Config).to receive(:set).with('reflow.git-server', 'BitBucket', local: false)
51
- allow(GitReflow::Config).to receive(:get).with('remote.origin.url').and_return(remote_url)
52
- allow(GitReflow::Config).to receive(:get).with('bitbucket.user', local: false).and_return(user)
53
- allow(GitReflow::Config).to receive(:get).with('bitbucket.api-key', reload: true, local: false).and_return(api_key)
54
- allow(GitReflow::Config).to receive(:get).with('reflow.local-projects', all: true).and_return('')
55
- expect { subject }.to have_said "\nYour BitBucket account was already setup with:"
56
- expect { subject }.to have_said "\tUser Name: #{user}"
57
- end
58
- end
59
-
60
- context 'not yet authenticated' do
61
- context 'with valid BitBucket credentials' do
62
- before do
63
- allow(GitReflow::Config).to receive(:get).and_return('')
64
- allow(GitReflow::Config).to receive(:set)
65
- allow(GitReflow::Config).to receive(:set).with('bitbucket.api-key', reload: true).and_return(api_key)
66
- allow(GitReflow::Config).to receive(:get).with('bitbucket.api-key', reload: true).and_return('')
67
- allow(GitReflow::Config).to receive(:get).with('remote.origin.url').and_return(remote_url)
68
- allow(GitReflow::Config).to receive(:get).with('reflow.local-projects').and_return('')
69
- allow(bitbucket).to receive(:connection).and_return double(repos: double(all: []))
70
- end
71
-
72
- it "prompts me to setup an API key" do
73
- expect { subject }.to have_said "\nIn order to connect your BitBucket account,"
74
- expect { subject }.to have_said "you'll need to generate an API key for your team"
75
- expect { subject }.to have_said "Visit https://bitbucket.org/account/user/reenhanced/api-key/, to generate it\n"
76
- end
77
- end
78
- end
79
- end
80
-
81
- end
1
+ require 'spec_helper'
2
+
3
+ describe GitReflow::GitServer::BitBucket do
4
+ let(:user) { 'reenhanced' }
5
+ let(:password) { 'shazam' }
6
+ let(:repo) { 'repo' }
7
+ let(:api_key) { 'a1b2c3d4e5f6g7h8i9j0' }
8
+ let(:hostname) { 'hostname.local' }
9
+ let(:api_endpoint) { 'https://bitbucket.org/api/1.0' }
10
+ let(:site) { 'https://bitbucket.org' }
11
+ let(:remote_url) { "git@bitbucket.org:#{user}/#{repo}.git" }
12
+
13
+ before do
14
+ allow_any_instance_of(HighLine).to receive(:ask) do |terminal, question|
15
+ values = {
16
+ "Please enter your BitBucket username: " => user
17
+ }
18
+ return_value = values[question]
19
+ question = ""
20
+ return_value
21
+ end
22
+ end
23
+
24
+ describe '#initialize(options)' do
25
+ subject { GitReflow::GitServer::BitBucket.new({}) }
26
+
27
+ it 'sets the reflow git server provider to BitBucket in the git config' do
28
+ expect(GitReflow::Config).to receive(:set).once.with('reflow.git-server', 'BitBucket', local: false)
29
+ subject
30
+ end
31
+
32
+ context 'storing git config settings only for this project' do
33
+ subject { GitReflow::GitServer::BitBucket.new(project_only: true) }
34
+
35
+ it 'sets the enterprise site and api as the site and api endpoints for the BitBucket provider in the git config' do
36
+ expect(GitReflow::Config).to receive(:set).once.with('reflow.git-server', 'BitBucket', local: true)
37
+ subject
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ describe '#authenticate' do
44
+ let(:bitbucket) { GitReflow::GitServer::BitBucket.new( { }) }
45
+ let!(:bitbucket_api) { BitBucket.new }
46
+ subject { bitbucket.authenticate }
47
+
48
+ context 'already authenticated' do
49
+ it "notifies the user of successful setup" do
50
+ allow(GitReflow::Config).to receive(:set).with('reflow.git-server', 'BitBucket', local: false)
51
+ allow(GitReflow::Config).to receive(:get).with('remote.origin.url').and_return(remote_url)
52
+ allow(GitReflow::Config).to receive(:get).with('bitbucket.user', local: false).and_return(user)
53
+ allow(GitReflow::Config).to receive(:get).with('bitbucket.api-key', reload: true, local: false).and_return(api_key)
54
+ allow(GitReflow::Config).to receive(:get).with('reflow.local-projects', all: true).and_return('')
55
+ expect { subject }.to have_said "\nYour BitBucket account was already setup with:"
56
+ expect { subject }.to have_said "\tUser Name: #{user}"
57
+ end
58
+ end
59
+
60
+ context 'not yet authenticated' do
61
+ context 'with valid BitBucket credentials' do
62
+ before do
63
+ allow(GitReflow::Config).to receive(:get).and_return('')
64
+ allow(GitReflow::Config).to receive(:set)
65
+ allow(GitReflow::Config).to receive(:set).with('bitbucket.api-key', reload: true).and_return(api_key)
66
+ allow(GitReflow::Config).to receive(:get).with('bitbucket.api-key', reload: true).and_return('')
67
+ allow(GitReflow::Config).to receive(:get).with('remote.origin.url').and_return(remote_url)
68
+ allow(GitReflow::Config).to receive(:get).with('reflow.local-projects').and_return('')
69
+ allow(bitbucket).to receive(:connection).and_return double(repos: double(all: []))
70
+ end
71
+
72
+ it "prompts me to setup an API key" do
73
+ expect { subject }.to have_said "\nIn order to connect your BitBucket account,"
74
+ expect { subject }.to have_said "you'll need to generate an API key for your team"
75
+ expect { subject }.to have_said "Visit https://bitbucket.org/account/user/reenhanced/api-key/, to generate it\n"
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ end
@@ -86,21 +86,21 @@ describe GitReflow::GitServer::GitHub::PullRequest do
86
86
  pull_request: {
87
87
  number: existing_pull_request.number,
88
88
  comments: [{author: comment_author}],
89
- reviews: []
89
+ reviews: [{author: existing_pull_request.user.login}]
90
90
  },
91
91
  issue: {
92
92
  number: existing_pull_request.number,
93
- comments: [{author: comment_author}]
93
+ comments: [{author: comment_author}, {author: existing_pull_request.user.login}]
94
94
  }
95
95
  )
96
96
  end
97
- specify { expect(subject).to eql(existing_pull_comments.to_a + existing_issue_comments.to_a) }
97
+ specify { expect(subject).to eql(existing_pull_comments.to_a + existing_issue_comments.to_a - [existing_pull_request.user.login]) }
98
98
  end
99
99
 
100
100
  context "Testing Nil Comments" do
101
101
  before do
102
102
  stub_request(:get, "https://api.github.com/repos/reenhanced/repo/pulls/2/comments?access_token=a1b2c3d4e5f6g7h8i9j0").
103
- with(:headers => {'Accept'=>'application/vnd.github.v3+json,application/vnd.github.beta+json;q=0.5,application/json;q=0.1', 'Accept-Charset'=>'utf-8', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'token a1b2c3d4e5f6g7h8i9j0', 'User-Agent'=>'Github API Ruby Gem 0.15.0'}).
103
+ with(:headers => {'Accept'=>'application/vnd.github.v3+json,application/vnd.github.beta+json;q=0.5,application/json;q=0.1', 'Accept-Charset'=>'utf-8', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'token a1b2c3d4e5f6g7h8i9j0', 'User-Agent'=>'Github API Ruby Gem 0.18.2'}).
104
104
  to_return(:status => 200, :body => "", :headers => {})
105
105
 
106
106
  FakeGitHub.new(
@@ -133,7 +133,7 @@ describe GitReflow::GitServer::GitHub::PullRequest do
133
133
  number: existing_pull_request.number,
134
134
  owner: existing_pull_request.user.login,
135
135
  comments: [{author: 'tito'}, {author: 'bobby'}, {author: 'ringo'}],
136
- reviews: [{author: 'nature-boy'}]
136
+ reviews: [{author: 'ringo'}, {author: 'nature-boy'}]
137
137
  },
138
138
  issue: {
139
139
  number: existing_pull_request.number,
@@ -484,16 +484,16 @@ describe GitReflow::GitServer::GitHub::PullRequest do
484
484
  allow(GitReflow.git_server).to receive(:connection).and_return(github_api)
485
485
  allow(GitReflow.git_server).to receive(:get_build_status).and_return(Struct.new(:state, :description, :target_url).new())
486
486
  allow_any_instance_of(GitReflow::GitServer::PullRequest).to receive(:commit_message_for_merge).and_return('Bingo')
487
- allow_any_instance_of(GitReflow).to receive(:append_to_squashed_commit_message).and_return(true)
487
+ allow_any_instance_of(GitReflow).to receive(:append_to_merge_commit_message).and_return(true)
488
488
  end
489
489
 
490
490
  context "and force-merging" do
491
491
  let(:inputs) do
492
492
  {
493
- base: "base_branch",
494
- title: "title",
495
- message: "message",
496
- skip_lgtm: true
493
+ base: "base_branch",
494
+ title: "title",
495
+ message: "message",
496
+ force: true
497
497
  }
498
498
  end
499
499
 
@@ -78,7 +78,7 @@ describe GitReflow::GitServer::GitHub do
78
78
  subject { github.authenticate }
79
79
 
80
80
  before do
81
- allow(GitReflow::GitServer::GitHub).to receive(:user).and_return('reenhanced')
81
+ allow(GitReflow::GitServer::GitHub).to receive(:user).and_return(user)
82
82
  allow(github_api).to receive(:oauth).and_return(github_authorizations)
83
83
  allow(github_api).to receive_message_chain(:oauth, :all).and_return([])
84
84
  allow(github).to receive(:run).with('hostname', loud: false).and_return(hostname)
@@ -151,12 +151,86 @@ describe GitReflow::GitServer::GitHub do
151
151
  body: { error: "GET https://api.github.com/authorizations: 401 Bad credentials" }
152
152
  }}
153
153
 
154
+ before do
155
+ allow(GitReflow::Config).to receive(:get).and_call_original
156
+ allow(GitReflow::Config).to receive(:get).with('github.oauth-token').and_return(oauth_token_hash[:token])
157
+ allow(Github::Client).to receive(:new).and_return(github_api)
158
+ allow(github_authorizations).to receive(:authenticated?).and_return(true)
159
+ allow(github_api.oauth).to receive(:create).with({ scopes: ['repo'], note: "git-reflow (#{hostname})" }).and_return(oauth_token_hash)
160
+
161
+ stub_request(:get, %r{/user}).
162
+ to_return(
163
+ body: Fixture.new('authentication_failure.json').to_s,
164
+ status: 401,
165
+ headers: {'content-type' => 'application/json; charset=utf-8', status: 'Unauthorized'},
166
+ )
167
+ end
168
+
169
+ it "notifies the user of successful setup" do
170
+ expect { subject }.to have_said "Your GitHub account was successfully setup!", :success
171
+ end
172
+
173
+ it "creates a new GitHub oauth token" do
174
+ expect(github_api.oauth).to receive(:create).and_return(oauth_token_hash)
175
+ subject
176
+ end
177
+
178
+ it "creates git config keys for github connections" do
179
+ expect{ subject }.to have_run_command_silently "git config -f #{GitReflow::Config::CONFIG_FILE_PATH} --replace-all github.site \"#{github_site}\"", blocking: false
180
+ expect{ subject }.to have_run_command_silently "git config -f #{GitReflow::Config::CONFIG_FILE_PATH} --replace-all github.endpoint \"#{github_api_endpoint}\"", blocking: false
181
+ expect{ subject }.to have_run_command_silently "git config -f #{GitReflow::Config::CONFIG_FILE_PATH} --replace-all github.oauth-token \"#{oauth_token_hash[:token]}\"", blocking: false
182
+ expect{ subject }.to have_run_command_silently "git config -f #{GitReflow::Config::CONFIG_FILE_PATH} --replace-all reflow.git-server \"GitHub\"", blocking: false
183
+ end
184
+
185
+ end
186
+ end
187
+
188
+ context 'already authenticated' do
189
+ let(:oauth_token) { "abc123" }
190
+
191
+ before do
192
+ allow(GitReflow::Config).to receive(:get).and_call_original
193
+ allow(GitReflow::Config).to receive(:get).with('github.oauth-token').and_return(oauth_token)
194
+ end
195
+
196
+ context "and authentication token is still valid" do
197
+ before do
198
+ stub_request(:get, %r{/user}).
199
+ to_return(
200
+ body: Fixture.new('users/user.json').to_s,
201
+ status: 200,
202
+ headers: { content_type: "application/json; charset=utf-8" }
203
+ )
204
+
205
+ allow(Github::Client).to receive(:new).and_return(github_api)
206
+ allow(github_api).to receive(:oauth).and_return(github_authorizations)
207
+ allow(github_authorizations).to receive(:authenticated?).and_return(true)
208
+ allow(github_api.oauth).to receive(:create).with({ scopes: ['repo'], note: "git-reflow (#{hostname})" }).and_return(oauth_token_hash)
209
+ end
210
+
211
+ it "resolves all missing git-reflow configurations" do
212
+ expect{ subject }.to have_run_command_silently "git config -f #{GitReflow::Config::CONFIG_FILE_PATH} --replace-all github.site \"#{github_site}\"", blocking: false
213
+ expect{ subject }.to have_run_command_silently "git config -f #{GitReflow::Config::CONFIG_FILE_PATH} --replace-all github.endpoint \"#{github_api_endpoint}\"", blocking: false
214
+ expect{ subject }.to have_run_command_silently "git config -f #{GitReflow::Config::CONFIG_FILE_PATH} --replace-all reflow.git-server \"GitHub\"", blocking: false
215
+ expect { subject }.to have_said "Your GitHub account was already setup with: "
216
+ expect { subject }.to have_said "\tUser Name: #{user}"
217
+ expect { subject }.to have_said "\tEndpoint: #{github_api_endpoint}"
218
+ end
219
+ end
220
+
221
+ context "and authentication token is expired" do
222
+ let(:unauthorized_error_response) {{
223
+ response_headers: {'content-type' => 'application/json; charset=utf-8', status: 'Unauthorized'},
224
+ method: 'GET',
225
+ status: '401',
226
+ body: { error: "GET https://api.github.com/authorizations: 401 Bad credentials" }
227
+ }}
228
+
154
229
  before do
155
230
  allow(Github::Client).to receive(:new).and_raise Github::Error::Unauthorized.new(unauthorized_error_response)
156
231
  end
157
232
 
158
- it "notifies user of invalid login details" do
159
- expect { subject }.to have_said "Github Authentication Error: #{Github::Error::Unauthorized.new(unauthorized_error_response).inspect}", :error
233
+ it "requests a new oauth token" do
160
234
  end
161
235
  end
162
236
  end
@@ -364,7 +364,7 @@ describe GitReflow::GitServer::PullRequest do
364
364
  subject { pr.merge! inputs }
365
365
 
366
366
  before do
367
- allow(GitReflow).to receive(:append_to_squashed_commit_message)
367
+ allow(GitReflow).to receive(:append_to_merge_commit_message)
368
368
  allow(pr).to receive(:commit_message_for_merge).and_return(commit_message_for_merge)
369
369
  end
370
370
 
@@ -376,7 +376,7 @@ describe GitReflow::GitServer::PullRequest do
376
376
  it "updates both feature and destination branch and squash-merges feature into base branch" do
377
377
  expect(GitReflow).to receive(:update_current_branch)
378
378
  expect(GitReflow).to receive(:fetch_destination).with(pr.base_branch_name)
379
- expect(GitReflow).to receive(:append_to_squashed_commit_message).with(pr.commit_message_for_merge)
379
+ expect(GitReflow).to receive(:append_to_merge_commit_message).with(pr.commit_message_for_merge)
380
380
  expect { subject }.to have_run_commands_in_order [
381
381
  "git checkout #{pr.base_branch_name}",
382
382
  "git pull origin #{pr.base_branch_name}",
@@ -470,6 +470,12 @@ describe GitReflow::GitServer::PullRequest do
470
470
  before { allow(pr).to receive(:approvals).and_return(['sally', 'joey']) }
471
471
  specify { expect(subject).to include "\nLGTM given by: @sally, @joey\n" }
472
472
  end
473
+
474
+ context "with custom merge commit message template" do
475
+ before { allow(GitReflow).to receive(:merge_commit_template).and_return("Super cool changes") }
476
+ specify { expect(subject).to include "Super cool changes" }
477
+ specify { expect(subject).to_not include "\nMerges ##{pr.number}\n" }
478
+ end
473
479
  end
474
480
 
475
481
  context "#cleanup_feature_branch?" do
@@ -490,7 +496,7 @@ describe GitReflow::GitServer::PullRequest do
490
496
  it { should be_truthy }
491
497
  end
492
498
 
493
- context "and user choose not to cleanup" do
499
+ context "and user chooses not to cleanup" do
494
500
  before { expect(pr).to receive(:ask).with('Would you like to push this branch to your remote repo and cleanup your feature branch? ').and_return('no') }
495
501
  it { should be_falsy }
496
502
  end
@@ -1,101 +1,101 @@
1
- require 'spec_helper'
2
-
3
- describe GitReflow::GitServer do
4
- let(:connection_options) { nil }
5
-
6
- subject { GitReflow::GitServer.connect connection_options }
7
-
8
- before do
9
- allow(GitReflow::GitServer::GitHub).to receive(:new)
10
-
11
- module GitReflow::GitServer
12
- class DummyHub < Base
13
- def initialize(options)
14
- "Initialized with #{options}"
15
- end
16
-
17
- def authenticate(options={})
18
- end
19
-
20
- def connection
21
- 'Connected!'
22
- end
23
- end
24
- end
25
- end
26
-
27
- describe '.connect(options)' do
28
- it 'initializes a new GitHub server provider by default' do
29
- stubbed_github = Class.new
30
- allow(stubbed_github).to receive(:authenticate)
31
- expect(GitReflow::GitServer::GitHub).to receive(:new).and_return(stubbed_github)
32
- subject
33
- end
34
-
35
- context 'provider is specified' do
36
- let(:connection_options) { {provider: 'DummyHub'}.merge(expected_server_options) }
37
- let(:expected_server_options) {{ basic_auth: 'user:pass', end_point: 'https://api.example.com' }}
38
-
39
- it 'initializes any server provider that has been implemented' do
40
- dummy_hub = GitReflow::GitServer::DummyHub.new({})
41
- expect(GitReflow::GitServer::DummyHub).to receive(:new).with(expected_server_options).and_return(dummy_hub)
42
- expect(subject).to eq(dummy_hub)
43
- expect($says).not_to include 'GitServer not setup for: DummyHub'
44
- end
45
- end
46
-
47
- context 'provider not yet implemented' do
48
- let(:connection_options) {{ provider: 'GitLab' }}
49
- it { expect{ subject }.to have_said "Error connecting to GitLab: GitServer not setup for \"GitLab\"", :error }
50
- end
51
- end
52
-
53
- describe '.current_provider' do
54
- subject { GitReflow::GitServer.current_provider }
55
-
56
- before { allow(GitReflow::Config).to receive(:get).with('reflow.git-server', local: true).and_return(nil) }
57
-
58
- context 'Reflow setup to use GitHub' do
59
- before { allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return('GitHub') }
60
- it { is_expected.to eq(GitReflow::GitServer::GitHub) }
61
- end
62
-
63
- context 'Reflow has not yet been setup' do
64
- before { allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return('') }
65
- it { is_expected.to be_nil }
66
- it { expect{ subject }.to have_said "Reflow hasn't been setup yet. Run 'git reflow setup' to continue", :notice }
67
- end
68
-
69
- context 'an unknown server provider is stored in the git config' do
70
- before { allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return('GittyUp') }
71
-
72
- it { is_expected.to be_nil }
73
- it { expect{ subject }.to have_said "GitServer not setup for \"GittyUp\"", :error }
74
- end
75
- end
76
-
77
- describe '.connection' do
78
- subject { GitReflow::GitServer.connection }
79
-
80
- before do
81
- allow(GitReflow::Config).to receive(:get).with('reflow.git-server', local: true).and_return(nil)
82
- allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return(nil)
83
- end
84
-
85
- it { is_expected.to be_nil }
86
-
87
- context "with a valid provider" do
88
- before { allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return('GitHub') }
89
- it 'calls connection on the provider' do
90
- expect(GitReflow::GitServer::GitHub).to receive(:connection)
91
- subject
92
- end
93
- end
94
-
95
- context "with an invalid provider" do
96
- before { allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return('GittyUp') }
97
- it { is_expected.to be_nil }
98
- it { expect{ subject }.to have_said "GitServer not setup for \"GittyUp\"", :error }
99
- end
100
- end
101
- end
1
+ require 'spec_helper'
2
+
3
+ describe GitReflow::GitServer do
4
+ let(:connection_options) { nil }
5
+
6
+ subject { GitReflow::GitServer.connect connection_options }
7
+
8
+ before do
9
+ allow(GitReflow::GitServer::GitHub).to receive(:new)
10
+
11
+ module GitReflow::GitServer
12
+ class DummyHub < Base
13
+ def initialize(options)
14
+ "Initialized with #{options}"
15
+ end
16
+
17
+ def authenticate(options={})
18
+ end
19
+
20
+ def connection
21
+ 'Connected!'
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '.connect(options)' do
28
+ it 'initializes a new GitHub server provider by default' do
29
+ stubbed_github = Class.new
30
+ allow(stubbed_github).to receive(:authenticate)
31
+ expect(GitReflow::GitServer::GitHub).to receive(:new).and_return(stubbed_github)
32
+ subject
33
+ end
34
+
35
+ context 'provider is specified' do
36
+ let(:connection_options) { {provider: 'DummyHub'}.merge(expected_server_options) }
37
+ let(:expected_server_options) {{ basic_auth: 'user:pass', end_point: 'https://api.example.com' }}
38
+
39
+ it 'initializes any server provider that has been implemented' do
40
+ dummy_hub = GitReflow::GitServer::DummyHub.new({})
41
+ expect(GitReflow::GitServer::DummyHub).to receive(:new).with(expected_server_options).and_return(dummy_hub)
42
+ expect(subject).to eq(dummy_hub)
43
+ expect($says).not_to include 'GitServer not setup for: DummyHub'
44
+ end
45
+ end
46
+
47
+ context 'provider not yet implemented' do
48
+ let(:connection_options) {{ provider: 'GitLab' }}
49
+ it { expect{ subject }.to have_said "Error connecting to GitLab: GitServer not setup for \"GitLab\"", :error }
50
+ end
51
+ end
52
+
53
+ describe '.current_provider' do
54
+ subject { GitReflow::GitServer.current_provider }
55
+
56
+ before { allow(GitReflow::Config).to receive(:get).with('reflow.git-server', local: true).and_return(nil) }
57
+
58
+ context 'Reflow setup to use GitHub' do
59
+ before { allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return('GitHub') }
60
+ it { is_expected.to eq(GitReflow::GitServer::GitHub) }
61
+ end
62
+
63
+ context 'Reflow has not yet been setup' do
64
+ before { allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return('') }
65
+ it { is_expected.to be_nil }
66
+ it { expect{ subject }.to have_said "Reflow hasn't been setup yet. Run 'git reflow setup' to continue", :notice }
67
+ end
68
+
69
+ context 'an unknown server provider is stored in the git config' do
70
+ before { allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return('GittyUp') }
71
+
72
+ it { is_expected.to be_nil }
73
+ it { expect{ subject }.to have_said "GitServer not setup for \"GittyUp\"", :error }
74
+ end
75
+ end
76
+
77
+ describe '.connection' do
78
+ subject { GitReflow::GitServer.connection }
79
+
80
+ before do
81
+ allow(GitReflow::Config).to receive(:get).with('reflow.git-server', local: true).and_return(nil)
82
+ allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return(nil)
83
+ end
84
+
85
+ it { is_expected.to be_nil }
86
+
87
+ context "with a valid provider" do
88
+ before { allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return('GitHub') }
89
+ it 'calls connection on the provider' do
90
+ expect(GitReflow::GitServer::GitHub).to receive(:connection)
91
+ subject
92
+ end
93
+ end
94
+
95
+ context "with an invalid provider" do
96
+ before { allow(GitReflow::Config).to receive(:get).with('reflow.git-server').and_return('GittyUp') }
97
+ it { is_expected.to be_nil }
98
+ it { expect{ subject }.to have_said "GitServer not setup for \"GittyUp\"", :error }
99
+ end
100
+ end
101
+ end