github_api 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::PullRequests, '#commits' do
6
+ let(:repo) { 'github' }
7
+ let(:user) { 'peter-murach' }
8
+ let(:number) { 1 }
9
+ let(:request_path) { "/repos/#{user}/#{repo}/pulls/#{number}/commits" }
10
+
11
+ before {
12
+ stub_get(request_path).to_return(:body => body, :status => status,
13
+ :headers => {:content_type => "application/json; charset=utf-8"})
14
+ }
15
+
16
+ after { reset_authentication_for(subject) }
17
+
18
+ context 'resource found' do
19
+ let(:body) { fixture('pull_requests/commits.json') }
20
+ let(:status) { 200 }
21
+
22
+ it "throws error if pull_request_id not provided" do
23
+ expect { subject.commits user, repo, nil }.to raise_error(ArgumentError)
24
+ end
25
+
26
+ it "should get the resources" do
27
+ subject.commits user, repo, number
28
+ a_get(request_path).should have_been_made
29
+ end
30
+
31
+ it_should_behave_like 'an array of resources' do
32
+ let(:requestable) { subject.commits user, repo, number }
33
+ end
34
+
35
+ it "should get pull request information" do
36
+ pull_requests = subject.commits user, repo, number
37
+ pull_requests.first.committer.name.should == 'Scott Chacon'
38
+ end
39
+
40
+ it "should yield to a block" do
41
+ yielded = []
42
+ result = subject.commits(user, repo, number) { |obj| yielded << obj }
43
+ yielded.should == result
44
+ end
45
+ end
46
+
47
+ it_should_behave_like 'request failure' do
48
+ let(:requestable) { subject.commits user, repo, number }
49
+ end
50
+
51
+ end # commits
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::PullRequests, '#create' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:repo) { 'github' }
8
+ let(:request_path) { "/repos/#{user}/#{repo}/pulls" }
9
+ let(:inputs) {
10
+ {
11
+ "title" => "Amazing new feature",
12
+ "body" => "Please pull this in!",
13
+ "head" => "octocat:new-feature",
14
+ "base" => "master",
15
+ "state" => "open",
16
+ 'unrelated' => 'giberrish'
17
+ }
18
+ }
19
+
20
+ before {
21
+ stub_post(request_path).with(inputs.except('unrelated')).
22
+ to_return(:body => body, :status => status,
23
+ :headers => {:content_type => "application/json; charset=utf-8"})
24
+ }
25
+
26
+ after { reset_authentication_for(subject) }
27
+
28
+ context "resouce created" do
29
+ let(:body) { fixture('pull_requests/pull_request.json') }
30
+ let(:status) { 201 }
31
+
32
+ it "should create resource successfully" do
33
+ subject.create user, repo, inputs
34
+ a_post(request_path).with(inputs).should have_been_made
35
+ end
36
+
37
+ it "should return the resource" do
38
+ pull_request = subject.create user, repo, inputs
39
+ pull_request.should be_a Hashie::Mash
40
+ end
41
+
42
+ it "should get the request information" do
43
+ pull_request = subject.create user, repo, inputs
44
+ pull_request.title.should eql "new-feature"
45
+ end
46
+ end
47
+
48
+ it_should_behave_like 'request failure' do
49
+ let(:requestable) { subject.create user, repo, inputs }
50
+ end
51
+
52
+ end # create
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::PullRequests, '#files' do
6
+ let(:repo) { 'github' }
7
+ let(:user) { 'peter-murach' }
8
+ let(:number) { 1 }
9
+ let(:request_path) { "/repos/#{user}/#{repo}/pulls/#{number}/files" }
10
+
11
+ before {
12
+ stub_get(request_path).to_return(:body => body, :status => status,
13
+ :headers => {:content_type => "application/json; charset=utf-8"})
14
+ }
15
+
16
+ after { reset_authentication_for(subject) }
17
+
18
+ context 'resource found' do
19
+ let(:body) { fixture('pull_requests/files.json') }
20
+ let(:status) { 200 }
21
+
22
+ it "should get the resources" do
23
+ subject.files user, repo, number
24
+ a_get(request_path).should have_been_made
25
+ end
26
+
27
+ it_should_behave_like 'an array of resources' do
28
+ let(:requestable) { subject.files user, repo, number }
29
+ end
30
+
31
+ it "should get pull request information" do
32
+ pull_requests = subject.files user, repo, number
33
+ pull_requests.first.filename.should == 'file1.txt'
34
+ end
35
+
36
+ it "should yield to a block" do
37
+ yielded = []
38
+ result = subject.files(user, repo, number) { |obj| yielded << obj }
39
+ yielded.should == result
40
+ end
41
+ end
42
+
43
+ it_should_behave_like 'request failure' do
44
+ let(:requestable) { subject.files user, repo, number }
45
+ end
46
+
47
+ end # files
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::PullRequests, '#get' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:repo) { 'github' }
8
+ let(:number) { 1 }
9
+ let(:request_path) { "/repos/#{user}/#{repo}/pulls/#{number}" }
10
+
11
+ before {
12
+ stub_get(request_path).to_return(:body => body, :status => status,
13
+ :headers => {:content_type => "application/json; charset=utf-8"})
14
+ }
15
+
16
+ after { reset_authentication_for(subject) }
17
+
18
+ context 'resource found' do
19
+ let(:body) { fixture('pull_requests/pull_request.json') }
20
+ let(:status) { 200 }
21
+
22
+ it { should respond_to :find }
23
+
24
+ it "should fail to get resource without pull_request id" do
25
+ expect { subject.get nil }.to raise_error(ArgumentError)
26
+ end
27
+
28
+ it "should get the resource" do
29
+ subject.get user, repo, number
30
+ a_get(request_path).should have_been_made
31
+ end
32
+
33
+ it "should get pull_request information" do
34
+ pull_request = subject.get user, repo, number
35
+ pull_request.number.should eq number
36
+ pull_request.head.user.login.should == 'octocat'
37
+ end
38
+
39
+ it "should return mash" do
40
+ pull_request = subject.get user, repo, number
41
+ pull_request.should be_a Hashie::Mash
42
+ end
43
+ end
44
+
45
+ it_should_behave_like 'request failure' do
46
+ let(:requestable) { subject.get user, repo, number }
47
+ end
48
+
49
+ end # get
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::PullRequests, '#list' do
6
+ let(:repo) { 'github' }
7
+ let(:user) { 'peter-murach' }
8
+ let(:inputs) { { 'state'=> 'closed', 'unrelated' => true } }
9
+ let(:request_path) { "/repos/#{user}/#{repo}/pulls" }
10
+
11
+ before {
12
+ stub_get(request_path).with(:query => inputs.except('unrelated')).
13
+ to_return(:body => body, :status => status,
14
+ :headers => {:content_type => "application/json; charset=utf-8"})
15
+ }
16
+
17
+ after { reset_authentication_for(subject) }
18
+
19
+ context 'resource found' do
20
+ let(:body) { fixture('pull_requests/pull_requests.json') }
21
+ let(:status) { 200 }
22
+
23
+ it { should respond_to :all }
24
+
25
+ it "throws error if pull_request id not provided" do
26
+ expect { subject.list nil }.to raise_error(ArgumentError)
27
+ end
28
+
29
+ it "should get the resources" do
30
+ subject.list user, repo, inputs
31
+ a_get(request_path).with(:query => inputs).should have_been_made
32
+ end
33
+
34
+ it_should_behave_like 'an array of resources' do
35
+ let(:requestable) { subject.list user, repo, inputs }
36
+ end
37
+
38
+ it "should get pull request information" do
39
+ pull_requests = subject.list user, repo, inputs
40
+ pull_requests.first.title.should == 'new-feature'
41
+ end
42
+
43
+ it "should yield to a block" do
44
+ yielded = []
45
+ result = subject.list(user, repo, inputs) { |obj| yielded << obj }
46
+ yielded.should == result
47
+ end
48
+ end
49
+
50
+ it_should_behave_like 'request failure' do
51
+ let(:requestable) { subject.list user, repo, inputs }
52
+ end
53
+
54
+ end # list
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::PullRequests, '#merge' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:repo) { 'github' }
8
+ let(:number) { 1347 }
9
+ let(:request_path) { "/repos/#{user}/#{repo}/pulls/#{number}/merge" }
10
+
11
+ before {
12
+ stub_put(request_path).to_return(:body => body, :status => status,
13
+ :headers => {:content_type => "application/json; charset=utf-8"})
14
+ }
15
+
16
+ after { reset_authentication_for(subject) }
17
+
18
+ context 'successful' do
19
+ let(:body) { fixture('pull_requests/merge_success.json') }
20
+ let(:status) { 200 }
21
+
22
+ it 'performs request' do
23
+ subject.merge user, repo, number
24
+ a_put(request_path).should have_been_made
25
+ end
26
+
27
+ it 'response contains merge success flag' do
28
+ response = subject.merge(user, repo, number)
29
+ response.merged.should be_true
30
+ end
31
+ end
32
+
33
+ context 'cannot be performed' do
34
+ let(:body) { fixture('pull_requests/merge_failure.json') }
35
+ let(:status) { 200 }
36
+
37
+ it 'response contains merge failure flag' do
38
+ response = subject.merge(user, repo, number)
39
+ response.merged.should be_false
40
+ end
41
+ end
42
+ end # merge
@@ -0,0 +1,37 @@
1
+
2
+ # encoding: utf-8
3
+
4
+ require 'spec_helper'
5
+
6
+ describe Github::PullRequests, '#merged?' do
7
+ let(:user) { 'peter-murach' }
8
+ let(:repo) { 'github' }
9
+ let(:number) { 1347 }
10
+ let(:request_path) { "/repos/#{user}/#{repo}/pulls/#{number}/merge" }
11
+
12
+ before { reset_authentication_for(subject) }
13
+ after { reset_authentication_for(subject) }
14
+
15
+ context "checks whetehr pull request has been merged" do
16
+ before {
17
+ stub_get(request_path).to_return(:body => "[]", :status => 404,
18
+ :headers => {:user_agent => subject.user_agent})
19
+ }
20
+
21
+ it "should fail validation " do
22
+ expect { subject.merged?(nil, nil, number) }.to raise_error(ArgumentError)
23
+ end
24
+
25
+ it "should return false if resource not found" do
26
+ merged = subject.merged? user, repo, number
27
+ merged.should be_false
28
+ end
29
+
30
+ it "should return true if resoure found" do
31
+ stub_get(request_path).to_return(:body => "[]", :status => 200,
32
+ :headers => {:user_agent => subject.user_agent})
33
+ merged = subject.merged? user, repo, number
34
+ merged.should be_true
35
+ end
36
+ end
37
+ end # merged?
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::PullRequests, 'integration' do
6
+
7
+ after { reset_authentication_for subject }
8
+
9
+ it_should_behave_like 'api interface'
10
+
11
+ its(:comments) { should be_a Github::PullRequests::Comments }
12
+
13
+ end # Github::PullRequests
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::PullRequests, '#update' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:repo) { 'github' }
8
+ let(:number) { 1347 }
9
+ let(:request_path) { "/repos/#{user}/#{repo}/pulls/#{number}" }
10
+ let(:inputs) {
11
+ {
12
+ "title" => "new title",
13
+ "body" => "updated body",
14
+ "state" => "open",
15
+ "unrelated" => true
16
+ }
17
+ }
18
+
19
+ before {
20
+ stub_patch(request_path).with(inputs.except('unrelated')).
21
+ to_return(:body => body, :status => status,
22
+ :headers => {:content_type => "application/json; charset=utf-8"})
23
+ }
24
+
25
+ after { reset_authentication_for(subject) }
26
+
27
+ context "resouce updateed" do
28
+ let(:body) { fixture('pull_requests/pull_request.json') }
29
+ let(:status) { 201 }
30
+
31
+ it "should create resource successfully" do
32
+ subject.update user, repo, number, inputs
33
+ a_patch(request_path).with(inputs).should have_been_made
34
+ end
35
+
36
+ it "should return the resource" do
37
+ pull_request = subject.update user, repo, number, inputs
38
+ pull_request.should be_a Hashie::Mash
39
+ end
40
+
41
+ it "should get the pull_request information" do
42
+ pull_request = subject.update user, repo, number, inputs
43
+ pull_request.title.should == 'new-feature'
44
+ end
45
+ end
46
+
47
+ it_should_behave_like 'request failure' do
48
+ let(:requestable) { subject.update user, repo, number, inputs }
49
+ end
50
+
51
+ end # update
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-02 00:00:00.000000000Z
12
+ date: 2013-01-15 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie
16
- requirement: &2152507880 !ruby/object:Gem::Requirement
16
+ requirement: &2152561220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152507880
24
+ version_requirements: *2152561220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faraday
27
- requirement: &2152438200 !ruby/object:Gem::Requirement
27
+ requirement: &2152560660 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.8.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2152438200
35
+ version_requirements: *2152560660
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: multi_json
38
- requirement: &2152437500 !ruby/object:Gem::Requirement
38
+ requirement: &2152560040 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.4'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2152437500
46
+ version_requirements: *2152560040
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: oauth2
49
- requirement: &2152436880 !ruby/object:Gem::Requirement
49
+ requirement: &2152559520 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2152436880
57
+ version_requirements: *2152559520
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
- requirement: &2152436280 !ruby/object:Gem::Requirement
60
+ requirement: &2152558760 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.5.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2152436280
68
+ version_requirements: *2152558760
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &2152435780 !ruby/object:Gem::Requirement
71
+ requirement: &2152521820 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2152435780
79
+ version_requirements: *2152521820
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: cucumber
82
- requirement: &2152435260 !ruby/object:Gem::Requirement
82
+ requirement: &2152520480 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2152435260
90
+ version_requirements: *2152520480
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: webmock
93
- requirement: &2152434700 !ruby/object:Gem::Requirement
93
+ requirement: &2152519500 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.9.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2152434700
101
+ version_requirements: *2152519500
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: vcr
104
- requirement: &2152434220 !ruby/object:Gem::Requirement
104
+ requirement: &2152517700 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 2.3.0
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2152434220
112
+ version_requirements: *2152517700
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: simplecov
115
- requirement: &2152433700 !ruby/object:Gem::Requirement
115
+ requirement: &2152515940 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 0.7.1
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2152433700
123
+ version_requirements: *2152515940
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: guard
126
- requirement: &2152433180 !ruby/object:Gem::Requirement
126
+ requirement: &2152514200 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *2152433180
134
+ version_requirements: *2152514200
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: guard-rspec
137
- requirement: &2152432620 !ruby/object:Gem::Requirement
137
+ requirement: &2152511420 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *2152432620
145
+ version_requirements: *2152511420
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: guard-cucumber
148
- requirement: &2152432040 !ruby/object:Gem::Requirement
148
+ requirement: &2152509720 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *2152432040
156
+ version_requirements: *2152509720
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: rake
159
- requirement: &2152414660 !ruby/object:Gem::Requirement
159
+ requirement: &2152507700 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: '0'
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *2152414660
167
+ version_requirements: *2152507700
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: bundler
170
- requirement: &2152414180 !ruby/object:Gem::Requirement
170
+ requirement: &2152506840 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ! '>='
@@ -175,7 +175,7 @@ dependencies:
175
175
  version: '0'
176
176
  type: :development
177
177
  prerelease: false
178
- version_requirements: *2152414180
178
+ version_requirements: *2152506840
179
179
  description: ! ' Ruby wrapper that supports all of the GitHub API v3 methods(nearly
180
180
  200). It''s build in a modular way, that is, you can either instantiate the whole
181
181
  api wrapper Github.new or use parts of it e.i. Github::Repos.new if working solely
@@ -650,8 +650,17 @@ files:
650
650
  - spec/github/page_links_spec.rb
651
651
  - spec/github/paged_request_spec.rb
652
652
  - spec/github/parameter_filter_spec.rb
653
+ - spec/github/pull_requests/comments/list_spec.rb
653
654
  - spec/github/pull_requests/comments_spec.rb
654
- - spec/github/pull_requests_spec.rb
655
+ - spec/github/pull_requests/commits_spec.rb
656
+ - spec/github/pull_requests/create_spec.rb
657
+ - spec/github/pull_requests/files_spec.rb
658
+ - spec/github/pull_requests/get_spec.rb
659
+ - spec/github/pull_requests/list_spec.rb
660
+ - spec/github/pull_requests/merge_spec.rb
661
+ - spec/github/pull_requests/merged_spec.rb
662
+ - spec/github/pull_requests/pull_requests_spec.rb
663
+ - spec/github/pull_requests/update_spec.rb
655
664
  - spec/github/repos/branch_spec.rb
656
665
  - spec/github/repos/branches_spec.rb
657
666
  - spec/github/repos/collaborators/add_spec.rb