git_reflow 0.4.2 → 0.5.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.
@@ -2,6 +2,13 @@ module GitReflow
2
2
  module Sandbox
3
3
  extend self
4
4
 
5
+ COLOR_FOR_LABEL = {
6
+ notice: :yellow,
7
+ error: :red,
8
+ deliver_halted: :red,
9
+ success: :green
10
+ }
11
+
5
12
  def run(command, options = {})
6
13
  options = { loud: true }.merge(options)
7
14
 
@@ -20,6 +27,14 @@ module GitReflow
20
27
  run(command, options)
21
28
  end
22
29
 
30
+ def say(message, label_type = :plain)
31
+ if COLOR_FOR_LABEL[label_type]
32
+ puts "[#{ label_type.to_s.gsub('_', ' ').colorize(COLOR_FOR_LABEL[label_type]) }] #{message}"
33
+ else
34
+ puts message
35
+ end
36
+ end
37
+
23
38
  # WARNING: this currently only supports OS X and UBUNTU
24
39
  def ask_to_open_in_browser(url)
25
40
  if RUBY_PLATFORM =~ /darwin|linux/i
@@ -1,3 +1,3 @@
1
1
  module GitReflow
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -0,0 +1,53 @@
1
+ {
2
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
3
+ "commit": {
4
+ "url": "https://api.github.com/repos/reenhanced/repo/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
5
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
6
+ "author": {
7
+ "name": "Monalisa Octocat",
8
+ "email": "support@github.com",
9
+ "date": "2011-04-14T16:00:49Z"
10
+ },
11
+ "committer": {
12
+ "name": "Monalisa Octocat",
13
+ "email": "support@github.com",
14
+ "date": "2011-04-14T16:00:49Z"
15
+ },
16
+ "message": "Fix all the bugs",
17
+ "tree": {
18
+ "url": "https://api.github.com/repos/reenhanced/repo/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e",
19
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
20
+ }
21
+ },
22
+ "author": {
23
+ "login": "reenhanced",
24
+ "id": 1,
25
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
26
+ "url": "https://api.github.com/users/reenhanced"
27
+ },
28
+ "committer": {
29
+ "login": "reenhanced",
30
+ "id": 1,
31
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
32
+ "url": "https://api.github.com/users/reenhanced"
33
+ },
34
+ "parents": [
35
+ {
36
+ "url": "https://api.github.com/repos/reenhanced/repo/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
37
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
38
+ }
39
+ ],
40
+ "stats": {
41
+ "additions": 104,
42
+ "deletions": 4,
43
+ "total": 108
44
+ },
45
+ "files": [
46
+ {
47
+ "filename": "file1.txt",
48
+ "additions": 10,
49
+ "deletions": 2,
50
+ "total": 12
51
+ }
52
+ ]
53
+ }
@@ -15,7 +15,7 @@ describe GitReflow do
15
15
 
16
16
  let(:github_authorizations) { Github::Client::Authorizations.new }
17
17
  let(:existing_pull_requests) { JSON.parse(fixture('pull_requests/pull_requests.json').read).collect { |pull| Hashie::Mash.new(pull)} }
18
- let(:existing_pull_request) { existing_pull_requests.first }
18
+ let(:existing_pull_request) { GitReflow::GitServer::GitHub::PullRequest.new existing_pull_requests.first }
19
19
 
20
20
  before do
21
21
  HighLine.any_instance.stub(:ask) do |terminal, question|
@@ -45,13 +45,13 @@ describe GitReflow do
45
45
  end
46
46
 
47
47
  context 'with no existing pull request' do
48
- before { git_server.stub(:find_pull_request).with({from: feature_branch, to: base_branch}).and_return(nil) }
48
+ before { git_server.stub(:find_open_pull_request).with({from: feature_branch, to: base_branch}).and_return(nil) }
49
49
  it { expect{ subject }.to have_output "\n[notice] No pull request exists for #{feature_branch} -> #{base_branch}" }
50
50
  it { expect{ subject }.to have_output "[notice] Run 'git reflow review #{base_branch}' to start the review process" }
51
51
  end
52
52
 
53
53
  context 'with an existing pull request' do
54
- before { git_server.stub(:find_pull_request).with({from: feature_branch, to: base_branch}).and_return(existing_pull_request) }
54
+ before { git_server.stub(:find_open_pull_request).with({from: feature_branch, to: base_branch}).and_return(existing_pull_request) }
55
55
 
56
56
  it 'displays a summary of the pull request and asks to open it in the browser' do
57
57
  GitReflow.should_receive(:display_pull_request_summary).with(existing_pull_request)
@@ -82,7 +82,7 @@ describe GitReflow do
82
82
  :password => password,
83
83
  :repo => repo,
84
84
  :branch => branch,
85
- :pull => inputs
85
+ :pull => Hashie::Mash.new(inputs)
86
86
  })
87
87
  end
88
88
 
@@ -90,20 +90,20 @@ describe GitReflow do
90
90
 
91
91
  it "fetches the latest changes to the destination branch" do
92
92
  GitReflow.should_receive(:fetch_destination).with(inputs['base'])
93
- github.should_receive(:find_pull_request).and_return(nil)
93
+ github.should_receive(:find_open_pull_request).and_return(nil)
94
94
  github.stub(:create_pull_request).and_return(existing_pull_request)
95
95
  subject
96
96
  end
97
97
 
98
98
  it "pushes the latest current branch to the origin repo" do
99
99
  GitReflow.should_receive(:push_current_branch)
100
- github.should_receive(:find_pull_request).and_return(nil)
100
+ github.should_receive(:find_open_pull_request).and_return(nil)
101
101
  github.stub(:create_pull_request).and_return(existing_pull_request)
102
102
  subject
103
103
  end
104
104
 
105
105
  context "pull request doesn't exist" do
106
- before { github.stub(:find_pull_request).and_return(nil) }
106
+ before { github.stub(:find_open_pull_request).and_return(nil) }
107
107
 
108
108
  it "successfully creates a pull request if I do not provide one" do
109
109
  existing_pull_request.stub(:title).and_return(inputs['title'])
@@ -117,13 +117,13 @@ describe GitReflow do
117
117
  GitReflow.stub(:push_current_branch)
118
118
  github_error = Github::Error::UnprocessableEntity.new( eval(fixture('pull_requests/pull_request_exists_error.json').read) )
119
119
  github.stub(:create_pull_request).with(inputs.except('state')).and_raise(github_error)
120
- GitReflow.stub(:display_pull_request_summary).with(existing_pull_request)
120
+ GitReflow.stub(:display_pull_request_summary)
121
121
  end
122
122
 
123
123
  subject { GitReflow.review inputs }
124
124
 
125
125
  it "displays a pull request summary for the existing pull request" do
126
- GitReflow.should_receive(:display_pull_request_summary).with(existing_pull_request)
126
+ GitReflow.should_receive(:display_pull_request_summary)
127
127
  subject
128
128
  end
129
129
 
@@ -164,7 +164,7 @@ describe GitReflow do
164
164
  end
165
165
 
166
166
  it "looks for a pull request matching the feature branch and destination branch" do
167
- github.should_receive(:find_pull_request).with(from: branch, to: 'master')
167
+ github.should_receive(:find_open_pull_request).with(from: branch, to: 'master')
168
168
  subject
169
169
  end
170
170
 
@@ -172,7 +172,6 @@ describe GitReflow do
172
172
  before do
173
173
  github.stub(:get_build_status).and_return(build_status)
174
174
  github.stub(:has_pull_request_comments?).and_return(true)
175
- github.stub(:find_authors_of_open_pull_request_comments).and_return([])
176
175
  github.stub(:comment_authors_for_pull_request).and_return(['codenamev'])
177
176
  end
178
177
 
@@ -181,12 +180,11 @@ describe GitReflow do
181
180
 
182
181
  before do
183
182
  # just stubbing these in a locked state as the test is specific to this scenario
184
- GitReflow.stub(:find_authors_of_open_pull_request_comments).and_return([])
185
183
  GitReflow.stub(:has_pull_request_comments?).and_return(true)
186
184
  end
187
185
 
188
186
  it "halts delivery and notifies user of a failed build" do
189
- expect { subject }.to have_output "[#{ 'deliver halted'.colorize(:red) }] #{build_status.description}: #{build_status.target_url}"
187
+ expect { subject }.to have_said "#{build_status.description}: #{build_status.target_url}", :deliver_halted
190
188
  end
191
189
  end
192
190
 
@@ -196,7 +194,6 @@ describe GitReflow do
196
194
 
197
195
  before do
198
196
  # stubbing unrelated results so we can just test that it made it insdide the conditional block
199
- GitReflow.stub(:find_authors_of_open_pull_request_comments).and_return([])
200
197
  GitReflow.stub(:has_pull_request_comments?).and_return(true)
201
198
  GitReflow.stub(:comment_authors_for_pull_request).and_return([])
202
199
  GitReflow.stub(:update_destination).and_return(true)
@@ -205,7 +202,7 @@ describe GitReflow do
205
202
  end
206
203
 
207
204
  it "ignores build status when not setup" do
208
- expect { subject }.to have_output "Merge complete!"
205
+ expect { subject }.to have_said "Merge complete!", :success
209
206
  end
210
207
  end
211
208
 
@@ -215,12 +212,14 @@ describe GitReflow do
215
212
  context 'and has comments' do
216
213
  before do
217
214
  GitReflow.stub(:has_pull_request_comments?).and_return(true)
218
- GitReflow.stub(:find_authors_of_open_pull_request_comments).and_return([])
219
215
  end
220
216
 
221
217
  context 'but there is a LGTM' do
222
218
  let(:lgtm_comment_authors) { ['nhance'] }
223
- before { stub_with_fallback(github, :comment_authors_for_pull_request).with(existing_pull_request, with: GitReflow::LGTM).and_return(lgtm_comment_authors) }
219
+ before do
220
+ github.stub(:approvals).and_return(lgtm_comment_authors)
221
+ github.stub(:reviewers_pending_response).and_return([])
222
+ end
224
223
 
225
224
  it "includes the pull request body in the commit message" do
226
225
  squash_message = "#{existing_pull_request.body}\nCloses ##{existing_pull_request.number}\n\nLGTM given by: @nhance\n"
@@ -232,8 +231,8 @@ describe GitReflow do
232
231
  let(:first_commit_message) { "We'll do it live." }
233
232
 
234
233
  before do
235
- existing_pull_request[:body] = ''
236
- github.stub(:find_pull_request).and_return(existing_pull_request)
234
+ existing_pull_request.description = ''
235
+ github.stub(:find_open_pull_request).and_return(existing_pull_request)
237
236
  GitReflow.stub(:get_first_commit_message).and_return(first_commit_message)
238
237
  github.stub(:comment_authors_for_pull_request).and_return(lgtm_comment_authors)
239
238
  end
@@ -262,8 +261,7 @@ describe GitReflow do
262
261
  end
263
262
 
264
263
  it "commits the changes for the squash merge" do
265
- subject
266
- $output.should include 'Merge complete!'
264
+ expect{ subject }.to have_said 'Merge complete!', :success
267
265
  end
268
266
 
269
267
  context "and cleaning up feature branch" do
@@ -333,7 +331,7 @@ describe GitReflow do
333
331
  context "and there were issues commiting the squash merge to the base branch" do
334
332
  before { stub_with_fallback(GitReflow, :run_command_with_label).with('git commit', {with_system: true}).and_return false }
335
333
  it "notifies user of issues commiting the squash merge of the feature branch" do
336
- expect { subject }.to have_output("There were problems commiting your feature... please check the errors above and try again.")
334
+ expect { subject }.to have_said("There were problems commiting your feature... please check the errors above and try again.", :error)
337
335
  end
338
336
  end
339
337
 
@@ -341,9 +339,9 @@ describe GitReflow do
341
339
 
342
340
  context 'but there are still unaddressed comments' do
343
341
  let(:open_comment_authors) { ['nhance', 'codenamev'] }
344
- before { github.stub(:find_authors_of_open_pull_request_comments).and_return(open_comment_authors) }
342
+ before { github.stub(:reviewers_pending_response).and_return(open_comment_authors) }
345
343
  it "notifies the user to get their code reviewed" do
346
- expect { subject }.to have_output "[deliver halted] You still need a LGTM from: #{open_comment_authors.join(', ')}"
344
+ expect { subject }.to have_said "You still need a LGTM from: #{open_comment_authors.join(', ')}", :deliver_halted
347
345
  end
348
346
  end
349
347
  end
@@ -351,11 +349,10 @@ describe GitReflow do
351
349
  context 'but has no comments' do
352
350
  before do
353
351
  github.stub(:has_pull_request_comments?).and_return(false)
354
- github.stub(:find_authors_of_open_pull_request_comments).and_return([])
355
352
  end
356
353
 
357
354
  it "notifies the user to get their code reviewed" do
358
- expect { subject }.to have_output "[deliver halted] Your code has not been reviewed yet."
355
+ expect { subject }.to have_said "Your code has not been reviewed yet.", :deliver_halted
359
356
  end
360
357
  end
361
358
 
@@ -376,10 +373,10 @@ describe GitReflow do
376
373
  end
377
374
 
378
375
  context "and no pull request exists for the feature branch to the destination branch" do
379
- before { github.stub(:find_pull_request).and_return(nil) }
376
+ before { github.stub(:find_open_pull_request).and_return(nil) }
380
377
 
381
378
  it "notifies the user of a missing pull request" do
382
- expect { subject }.to have_output "Error: No pull request exists for #{user}:#{branch}\nPlease submit your branch for review first with \`git reflow review\`"
379
+ expect { subject }.to have_said "No pull request exists for #{user}:#{branch}\nPlease submit your branch for review first with \`git reflow review\`", :deliver_halted
383
380
  end
384
381
  end
385
382
  end
@@ -4,6 +4,11 @@ describe GitReflow::Config do
4
4
  describe ".get(key)" do
5
5
  subject { GitReflow::Config.get('chucknorris.roundhouse') }
6
6
  it { expect{ subject }.to have_run_command_silently 'git config --get chucknorris.roundhouse' }
7
+
8
+ context "and getting all values" do
9
+ subject { GitReflow::Config.get('chucknorris.roundhouse', all: true) }
10
+ it { expect{ subject }.to have_run_command_silently 'git config --get-all chucknorris.roundhouse' }
11
+ end
7
12
  end
8
13
 
9
14
  describe ".set(key)" do
@@ -15,4 +20,34 @@ describe GitReflow::Config do
15
20
  it { expect{ subject }.to have_run_command_silently 'git config --replace-all chucknorris.roundhouse "to the face"' }
16
21
  end
17
22
  end
23
+
24
+ describe ".unset(key)" do
25
+ subject { GitReflow::Config.unset('chucknorris.roundhouse') }
26
+ it { expect{ subject }.to have_run_command_silently 'git config --global --unset chucknorris.roundhouse ' }
27
+
28
+ context "for multi-value keys" do
29
+ subject { GitReflow::Config.unset('chucknorris.roundhouse', value: 'to the face') }
30
+ it { expect{ subject }.to have_run_command_silently 'git config --global --unset chucknorris.roundhouse "to the face"' }
31
+ end
32
+
33
+ context "for current project only" do
34
+ subject { GitReflow::Config.unset('chucknorris.roundhouse', local: true) }
35
+ it { expect{ subject }.to have_run_command_silently 'git config --unset chucknorris.roundhouse ' }
36
+
37
+ context "for multi-value keys" do
38
+ subject { GitReflow::Config.unset('chucknorris.roundhouse', value: 'to the face', local: true) }
39
+ it { expect{ subject }.to have_run_command_silently 'git config --unset chucknorris.roundhouse "to the face"' }
40
+ end
41
+ end
42
+ end
43
+
44
+ describe ".add(key)" do
45
+ subject { GitReflow::Config.add('chucknorris.roundhouse', 'to the face') }
46
+ it { expect{ subject }.to have_run_command_silently 'git config --global --add chucknorris.roundhouse "to the face"' }
47
+
48
+ context "for current project only" do
49
+ subject { GitReflow::Config.add('chucknorris.roundhouse', 'to the face', local: true) }
50
+ it { expect{ subject }.to have_run_command_silently 'git config --add chucknorris.roundhouse "to the face"' }
51
+ end
52
+ end
18
53
  end
@@ -0,0 +1,110 @@
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
+ HighLine.any_instance.stub(: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
+ GitReflow::Config.should_receive(:set).once.with('reflow.git-server', 'BitBucket')
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
+ GitReflow::Config.should_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
+ GitReflow::Config.should_receive(:set).with('reflow.git-server', 'BitBucket')
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').and_return(user)
53
+ allow(GitReflow::Config).to receive(:get).with('bitbucket.api-key', reload: true).and_return(api_key)
54
+ expect { subject }.to have_output "\nYour BitBucket account was already setup with:"
55
+ expect { subject }.to have_output "\tUser Name: #{user}"
56
+ end
57
+ end
58
+
59
+ context 'not yet authenticated' do
60
+ context 'with valid BitBucket credentials' do
61
+ before do
62
+ GitReflow::Config.stub(:get).and_return('')
63
+ GitReflow::Config.stub(:set)
64
+ GitReflow::Config.stub(:set).with('bitbucket.api-key', reload: true).and_return(api_key)
65
+ allow(GitReflow::Config).to receive(:get).with('bitbucket.api-key', reload: true).and_return('')
66
+ allow(GitReflow::Config).to receive(:get).with('remote.origin.url').and_return(remote_url)
67
+ allow(GitReflow::Config).to receive(:get).with('reflow.local-projects').and_return('')
68
+ bitbucket.stub(:connection).and_return double(repos: double(all: []))
69
+ end
70
+
71
+ it "prompts me to setup an API key" do
72
+ expect { subject }.to have_output "\nIn order to connect your BitBucket account,"
73
+ expect { subject }.to have_output "you'll need to generate an API key for your team"
74
+ expect { subject }.to have_output "Visit https://bitbucket.org/account/user/reenhanced/api-key/, to generate it\n"
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ xdescribe '#create_pull_request(options)' do
81
+ let(:title) { 'Fresh title' }
82
+ let(:body) { 'Funky body' }
83
+ let(:current_branch) { 'new-feature' }
84
+
85
+ it 'creates a pull request using the remote user and repo' do
86
+ end
87
+ end
88
+
89
+ xdescribe '#find_pull_request(from, to)' do
90
+ end
91
+
92
+ xdescribe '#pull_request_comments(pull_request)' do
93
+ end
94
+
95
+ xdescribe '#has_pull_request_comments?(pull_request)' do
96
+ end
97
+
98
+ xdescribe '#get_build_status(sha)' do
99
+ end
100
+
101
+ xdescribe '#find_authors_of_open_pull_request_comments(pull_request)' do
102
+ end
103
+
104
+ xdescribe '#comment_authors_for_pull_request(pull_request, options = {})' do
105
+ end
106
+
107
+ xdescribe '#get_commited_time(commit_sha)' do
108
+ end
109
+
110
+ end
@@ -28,9 +28,8 @@ describe GitReflow::GitServer::GitHub do
28
28
  return_value
29
29
  end
30
30
 
31
- github.stub(:remote_user).and_return(user)
32
- github.stub(:remote_repo_name).and_return(repo)
33
- github.stub(:run).with('hostname', loud: false).and_return(hostname)
31
+ github.class.stub(:remote_user).and_return(user)
32
+ github.class.stub(:remote_repo_name).and_return(repo)
34
33
  end
35
34
 
36
35
  describe '#initialize(options)' do
@@ -58,6 +57,10 @@ describe GitReflow::GitServer::GitHub do
58
57
  context 'storing git config settings only for this project' do
59
58
  subject { GitReflow::GitServer::GitHub.new(project_only: true) }
60
59
 
60
+ before do
61
+ GitReflow::Config.should_receive(:get).twice.with('reflow.local-projects', all: true).and_return("#{user}/#{repo}")
62
+ end
63
+
61
64
  it 'sets the enterprise site and api as the site and api endpoints for the GitHub provider in the git config' do
62
65
  GitReflow::Config.should_receive(:set).once.with('github.site', github_site, local: true).and_call_original
63
66
  GitReflow::Config.should_receive(:set).once.with('github.endpoint', github_api_endpoint, local: true)
@@ -107,8 +110,12 @@ describe GitReflow::GitServer::GitHub do
107
110
  end
108
111
 
109
112
  context "exclusive to project" do
110
- let(:github) { GitReflow::GitServer::GitHub.new(project_only: true) }
111
- before { GitReflow::GitServer::GitHub.stub(:@project_only).and_return(true) }
113
+ let(:github) do
114
+ allow(GitReflow::GitServer::GitHub).to receive(:project_only?).and_return(true)
115
+ allow(GitReflow::GitServer::GitHub).to receive(:remote_user).and_return(user)
116
+ allow(GitReflow::GitServer::GitHub).to receive(:remote_repo_name).and_return(repo)
117
+ GitReflow::GitServer::GitHub.new(project_only: true)
118
+ end
112
119
 
113
120
  it "creates _local_ git config keys for github connections" do
114
121
  expect{ subject }.to_not have_run_command_silently "git config --global --replace-all github.site \"#{GitReflow::GitServer::GitHub.site_url}\""
@@ -120,6 +127,7 @@ describe GitReflow::GitServer::GitHub do
120
127
  expect{ subject }.to have_run_command_silently "git config --replace-all github.endpoint \"#{GitReflow::GitServer::GitHub.api_endpoint}\""
121
128
  expect{ subject }.to have_run_command_silently "git config --replace-all github.oauth-token \"#{oauth_token_hash[:token]}\""
122
129
  expect{ subject }.to have_run_command_silently "git config --replace-all reflow.git-server \"GitHub\""
130
+ expect{ subject }.to have_run_command_silently "git config --global --add reflow.local-projects \"#{user}/#{repo}\""
123
131
  end
124
132
  end
125
133
 
@@ -159,7 +167,7 @@ describe GitReflow::GitServer::GitHub do
159
167
  let(:body) { 'Funky body' }
160
168
  let(:current_branch) { 'new-feature' }
161
169
 
162
- before { github.stub(:current_branch).and_return(current_branch) }
170
+ before { github.class.stub(:current_branch).and_return(current_branch) }
163
171
 
164
172
  it 'creates a pull request using the remote user and repo' do
165
173
  github_api.stub(:pull_requests)
@@ -168,16 +176,19 @@ describe GitReflow::GitServer::GitHub do
168
176
  end
169
177
  end
170
178
 
171
- describe '#find_pull_request(from, to)' do
172
- subject { github.find_pull_request({ from: 'new-feature', to: 'master'}) }
179
+ describe '#find_open_pull_request(from, to)' do
180
+ subject { github.find_open_pull_request({ from: 'new-feature', to: 'master'}) }
173
181
 
174
182
  it 'looks for an open pull request matching the remote user/repo' do
175
- subject.should == existing_pull_requests.first
183
+ subject.number.should == existing_pull_requests.first.number
176
184
  end
177
185
 
178
186
  context 'no pull request exists' do
179
- before { github.stub(:find_pull_request).and_return([]) }
180
- it { should == [] }
187
+ before do
188
+ github_api.stub(:pull_requests)
189
+ github_api.pull_requests.should_receive(:all).and_return([])
190
+ end
191
+ it { should == nil }
181
192
  end
182
193
  end
183
194
 
@@ -198,21 +209,6 @@ describe GitReflow::GitServer::GitHub do
198
209
  end
199
210
  end
200
211
 
201
- describe '#has_pull_request_comments?(pull_request)' do
202
- let(:existing_pull_request) { Hashie::Mash.new JSON.parse(fixture('pull_requests/pull_request.json').read) }
203
- let(:pull_request_comments) { JSON.parse(fixture('pull_requests/comments.json').read).collect {|c| Hashie::Mash.new(c) } }
204
-
205
- before { github.stub(:pull_request_comments).and_return([pull_request_comments]) }
206
- subject { github.has_pull_request_comments?(existing_pull_request) }
207
-
208
- it { should == true }
209
-
210
- context 'no comments exist for the given pull request' do
211
- before { github.stub(:pull_request_comments).and_return([]) }
212
- it { should == false }
213
- end
214
- end
215
-
216
212
  describe '#get_build_status(sha)' do
217
213
  let(:sha) { '6dcb09b5b57875f334f61aebed695e2e4193db5e' }
218
214
  subject { github.get_build_status(sha) }
@@ -224,9 +220,6 @@ describe GitReflow::GitServer::GitHub do
224
220
  end
225
221
  end
226
222
 
227
- describe '#find_authors_of_open_pull_request_comments(pull_request)' do
228
- end
229
-
230
223
  describe '#comment_authors_for_pull_request(pull_request, options = {})' do
231
224
  end
232
225