github_api 0.8.7 → 0.8.8
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.
- data/README.md +21 -1
- data/lib/github_api/client.rb +1 -0
- data/lib/github_api/configuration.rb +5 -0
- data/lib/github_api/connection.rb +1 -0
- data/lib/github_api/pull_requests/comments.rb +0 -8
- data/lib/github_api/search.rb +4 -3
- data/lib/github_api/version.rb +1 -1
- data/spec/github/pull_requests/comments/create_spec.rb +57 -0
- data/spec/github/pull_requests/comments/delete_spec.rb +35 -0
- data/spec/github/pull_requests/comments/edit_spec.rb +49 -0
- data/spec/github/pull_requests/comments/get_spec.rb +50 -0
- data/spec/github/pull_requests/comments_spec.rb +2 -196
- data/spec/integration/options_spec.rb +35 -0
- metadata +38 -33
data/README.md
CHANGED
@@ -52,7 +52,7 @@ or create a new client instance
|
|
52
52
|
github = Github.new
|
53
53
|
```
|
54
54
|
|
55
|
-
At this stage you can also supply various configuration parameters, such as `:user`,`:repo`, `:org`, `:oauth_token`, `:basic_auth`, `:endpoint` which are used throughout the API. These can be passed directly as hash options:
|
55
|
+
At this stage you can also supply various configuration parameters, such as `:user`,`:repo`, `:org`, `:oauth_token`, `:basic_auth`, `:endpoint`, `:ssl` which are used throughout the API. These can be passed directly as hash options:
|
56
56
|
|
57
57
|
```ruby
|
58
58
|
github = Github.new oauth_token: 'token'
|
@@ -65,6 +65,7 @@ github = Github.new do |config|
|
|
65
65
|
config.endpoint = 'https://github.company.com/api/v3'
|
66
66
|
config.oauth_token = 'token'
|
67
67
|
config.adapter = :net_http
|
68
|
+
config.ssl = {:verify => false}
|
68
69
|
end
|
69
70
|
```
|
70
71
|
|
@@ -257,6 +258,25 @@ To list the scopes that the particular Github API action checks for do:
|
|
257
258
|
|
258
259
|
To understand what each scope means refer to [documentation](http://developer.github.com/v3/oauth/#scopes)
|
259
260
|
|
261
|
+
## SSL
|
262
|
+
|
263
|
+
By default requests over SSL are set to OpenSSL::SSL::VERIFY_PEER. However, you can turn off peer verification by
|
264
|
+
|
265
|
+
```ruby
|
266
|
+
Github.new ssl: { verify: false }
|
267
|
+
```
|
268
|
+
|
269
|
+
If your client fails to find CA certs you can pass other SSL options to specify exactly how the information is sourced
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
ssl: {
|
273
|
+
client_cert: "/usr/local/www.example.com/client_cert.pem"
|
274
|
+
client_key: "/user/local/www.example.com/client_key.pem"
|
275
|
+
ca_file: "example.com.cert"
|
276
|
+
ca_path: "/etc/ssl/"
|
277
|
+
}
|
278
|
+
```
|
279
|
+
|
260
280
|
## MIME Types
|
261
281
|
|
262
282
|
Issues, PullRequests and few other API leverage custom mime types which are <tt>:json</tt>, <tt>:blob</tt>, <tt>:raw</tt>, <tt>:text</tt>, <tt>:html</tt>, <tt>:full</tt>. By default <tt>:raw</tt> is used.
|
data/lib/github_api/client.rb
CHANGED
@@ -10,6 +10,7 @@ module Github
|
|
10
10
|
:oauth_token,
|
11
11
|
:endpoint,
|
12
12
|
:site,
|
13
|
+
:ssl,
|
13
14
|
:mime_type,
|
14
15
|
:user_agent,
|
15
16
|
:connection_options,
|
@@ -47,6 +48,9 @@ module Github
|
|
47
48
|
# The web endpoint used to connect to GitHub if none is set
|
48
49
|
DEFAULT_SITE = 'https://github.com'.freeze
|
49
50
|
|
51
|
+
# The default SSL configuration
|
52
|
+
DEFAULT_SSL = {}
|
53
|
+
|
50
54
|
# The value sent in the http header for 'User-Agent' if none is set
|
51
55
|
DEFAULT_USER_AGENT = "Github Ruby Gem #{Github::VERSION::STRING}".freeze
|
52
56
|
|
@@ -86,6 +90,7 @@ module Github
|
|
86
90
|
self.oauth_token = DEFAULT_OAUTH_TOKEN
|
87
91
|
self.endpoint = DEFAULT_ENDPOINT
|
88
92
|
self.site = DEFAULT_SITE
|
93
|
+
self.ssl = DEFAULT_SSL
|
89
94
|
self.user_agent = DEFAULT_USER_AGENT
|
90
95
|
self.connection_options = DEFAULT_CONNECTION_OPTIONS
|
91
96
|
self.mime_type = DEFAULT_MIME_TYPE
|
@@ -58,9 +58,7 @@ module Github
|
|
58
58
|
def get(user_name, repo_name, comment_id, params={})
|
59
59
|
set :user => user_name, :repo => repo_name
|
60
60
|
assert_presence_of user, repo, comment_id
|
61
|
-
|
62
61
|
normalize! params
|
63
|
-
# _merge_mime_type(:pull_comment, params)
|
64
62
|
|
65
63
|
get_request("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}", params)
|
66
64
|
end
|
@@ -97,9 +95,7 @@ module Github
|
|
97
95
|
def create(user_name, repo_name, request_id, params={})
|
98
96
|
set :user => user_name, :repo => repo_name
|
99
97
|
assert_presence_of user, repo, request_id
|
100
|
-
|
101
98
|
normalize! params
|
102
|
-
# _merge_mime_type(:pull_comment, params)
|
103
99
|
filter! VALID_REQUEST_COM_PARAM_NAMES, params
|
104
100
|
# _validate_reply_to(params)
|
105
101
|
|
@@ -119,9 +115,7 @@ module Github
|
|
119
115
|
def edit(user_name, repo_name, comment_id, params={})
|
120
116
|
set :user => user_name, :repo => repo_name
|
121
117
|
assert_presence_of user, repo, comment_id
|
122
|
-
|
123
118
|
normalize! params
|
124
|
-
# _merge_mime_type(:pull_comment, params)
|
125
119
|
filter! VALID_REQUEST_COM_PARAM_NAMES, params
|
126
120
|
|
127
121
|
patch_request("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}", params)
|
@@ -136,9 +130,7 @@ module Github
|
|
136
130
|
def delete(user_name, repo_name, comment_id, params={})
|
137
131
|
set :user => user_name, :repo => repo_name
|
138
132
|
assert_presence_of user, repo, comment_id
|
139
|
-
|
140
133
|
normalize! params
|
141
|
-
# _merge_mime_type(:pull_comment, params)
|
142
134
|
|
143
135
|
delete_request("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}", params)
|
144
136
|
end
|
data/lib/github_api/search.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Github
|
4
4
|
class Search < API
|
5
|
+
include Github::Utils::Url
|
5
6
|
|
6
7
|
# Creates new Search API
|
7
8
|
def initialize(options = {})
|
@@ -32,7 +33,7 @@ module Github
|
|
32
33
|
hash
|
33
34
|
end
|
34
35
|
|
35
|
-
get_request("/legacy/issues/search/#{options['owner']}/#{options['repo']}/#{options['state']}/#{options['keyword']}", params)
|
36
|
+
get_request("/legacy/issues/search/#{options['owner']}/#{options['repo']}/#{options['state']}/#{escape(options['keyword'])}", params)
|
36
37
|
end
|
37
38
|
|
38
39
|
# Search repositories
|
@@ -51,7 +52,7 @@ module Github
|
|
51
52
|
normalize! params
|
52
53
|
assert_required_keys %w[ keyword ], params
|
53
54
|
|
54
|
-
get_request("/legacy/repos/search/#{params.delete('keyword')}", params)
|
55
|
+
get_request("/legacy/repos/search/#{escape(params.delete('keyword'))}", params)
|
55
56
|
end
|
56
57
|
alias :repositories :repos
|
57
58
|
|
@@ -71,7 +72,7 @@ module Github
|
|
71
72
|
normalize! params
|
72
73
|
assert_required_keys %w[ keyword ], params
|
73
74
|
|
74
|
-
get_request("/legacy/user/search/#{params.delete('keyword')}", params)
|
75
|
+
get_request("/legacy/user/search/#{escape(params.delete('keyword'))}", params)
|
75
76
|
end
|
76
77
|
|
77
78
|
# Search email
|
data/lib/github_api/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::PullRequests::Comments, '#create' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:request_path) { "/repos/#{user}/#{repo}/pulls/#{pull_request_id}/comments" }
|
9
|
+
let(:pull_request_id) { 1 }
|
10
|
+
let(:inputs) {
|
11
|
+
{
|
12
|
+
"body" => "Nice change",
|
13
|
+
"commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
|
14
|
+
"path" => "file1.txt",
|
15
|
+
"position" => 4,
|
16
|
+
"in_reply_to" => 4,
|
17
|
+
'unrelated' => 'giberrish'
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
before {
|
22
|
+
stub_post(request_path).with(inputs.except('unrelated')).
|
23
|
+
to_return(:body => body, :status => status,
|
24
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
25
|
+
}
|
26
|
+
|
27
|
+
after { reset_authentication_for(subject) }
|
28
|
+
|
29
|
+
context "resouce created" do
|
30
|
+
let(:body) { fixture('pull_requests/comment.json') }
|
31
|
+
let(:status) { 201 }
|
32
|
+
|
33
|
+
it 'raises error when pull_request_id is missing' do
|
34
|
+
expect { subject.create user, repo, nil }.to raise_error(ArgumentError)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should create resource successfully" do
|
38
|
+
subject.create user, repo, pull_request_id, inputs
|
39
|
+
a_post(request_path).with(inputs).should have_been_made
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return the resource" do
|
43
|
+
pull_request = subject.create user, repo, pull_request_id, inputs
|
44
|
+
pull_request.should be_a Hashie::Mash
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should get the request information" do
|
48
|
+
pull_request = subject.create user, repo, pull_request_id, inputs
|
49
|
+
pull_request.id.should == pull_request_id
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it_should_behave_like 'request failure' do
|
54
|
+
let(:requestable) { subject.create user, repo, pull_request_id, inputs }
|
55
|
+
end
|
56
|
+
|
57
|
+
end # create
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::PullRequests::Comments, '#delete' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:comment_id) { 1 }
|
9
|
+
|
10
|
+
let(:request_path) { "/repos/#{user}/#{repo}/pulls/comments/#{comment_id}" }
|
11
|
+
let(:status) { 204 }
|
12
|
+
let(:body) { fixture('pull_requests/comment.json') }
|
13
|
+
|
14
|
+
before {
|
15
|
+
stub_delete(request_path).to_return(:body => body, :status => status,
|
16
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
17
|
+
}
|
18
|
+
|
19
|
+
after { reset_authentication_for(subject) }
|
20
|
+
|
21
|
+
context 'resource removed' do
|
22
|
+
it 'should raise error if comment_id not present' do
|
23
|
+
expect { subject.delete user, repo, nil }.to raise_error(ArgumentError)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should remove resource successfully" do
|
27
|
+
subject.delete user, repo, comment_id
|
28
|
+
a_delete(request_path).should have_been_made
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it_should_behave_like 'request failure' do
|
33
|
+
let(:requestable) { subject.delete user, repo, comment_id }
|
34
|
+
end
|
35
|
+
end # delete
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::PullRequests::Comments, '#edit' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:request_path) { "/repos/#{user}/#{repo}/pulls/comments/#{comment_id}" }
|
9
|
+
let(:comment_id) { 1 }
|
10
|
+
let(:inputs) {
|
11
|
+
{
|
12
|
+
"body" => "Nice change",
|
13
|
+
'unrelated' => 'giberrish'
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
before {
|
18
|
+
stub_patch(request_path).with(inputs.except('unrelated')).
|
19
|
+
to_return(:body => body, :status => status,
|
20
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
21
|
+
}
|
22
|
+
|
23
|
+
after { reset_authentication_for(subject) }
|
24
|
+
|
25
|
+
context "resouce edited" do
|
26
|
+
let(:body) { fixture('pull_requests/comment.json') }
|
27
|
+
let(:status) { 200 }
|
28
|
+
|
29
|
+
it "should edit resource successfully" do
|
30
|
+
subject.edit user, repo, comment_id, inputs
|
31
|
+
a_patch(request_path).with(inputs).should have_been_made
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return the resource" do
|
35
|
+
comment = subject.edit user, repo, comment_id, inputs
|
36
|
+
comment.should be_a Hashie::Mash
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should get the comment information" do
|
40
|
+
comment = subject.edit user, repo, comment_id, inputs
|
41
|
+
comment.user.login.should == 'octocat'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it_should_behave_like 'request failure' do
|
46
|
+
let(:requestable) { subject.edit user, repo, comment_id, inputs }
|
47
|
+
end
|
48
|
+
|
49
|
+
end # edit
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::PullRequests::Comments, '#get' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:pull_request_id) { 1 }
|
9
|
+
let(:comment_id) { 1 }
|
10
|
+
let(:request_path) { "/repos/#{user}/#{repo}/pulls/comments/#{comment_id}" }
|
11
|
+
|
12
|
+
before {
|
13
|
+
stub_get(request_path).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/comment.json') }
|
21
|
+
let(:status) { 200 }
|
22
|
+
|
23
|
+
it { should respond_to :find }
|
24
|
+
|
25
|
+
it "should fail to get resource without comment id" do
|
26
|
+
expect { subject.get user, repo, nil }.to raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should get the resource" do
|
30
|
+
subject.get user, repo, pull_request_id
|
31
|
+
a_get(request_path).should have_been_made
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should get comment information" do
|
35
|
+
comment = subject.get user, repo, comment_id
|
36
|
+
comment.id.should eq comment_id
|
37
|
+
comment.user.login.should == 'octocat'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return mash" do
|
41
|
+
comment = subject.get user, repo, comment_id
|
42
|
+
comment.should be_a Hashie::Mash
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it_should_behave_like 'request failure' do
|
47
|
+
let(:requestable) { subject.get user, repo, comment_id }
|
48
|
+
end
|
49
|
+
|
50
|
+
end # get
|
@@ -3,203 +3,9 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Github::PullRequests::Comments do
|
6
|
-
let(:github) { Github.new }
|
7
|
-
let(:user) { 'peter-murach' }
|
8
|
-
let(:repo) { 'github' }
|
9
|
-
let(:pull_request_id) { 1 }
|
10
|
-
let(:comment_id) { 1 }
|
11
6
|
|
12
|
-
after { reset_authentication_for
|
7
|
+
after { reset_authentication_for subject }
|
13
8
|
|
14
|
-
|
15
|
-
it { github.pull_requests.comments.should respond_to :find }
|
16
|
-
|
17
|
-
context 'resource found' do
|
18
|
-
before do
|
19
|
-
stub_get("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}").
|
20
|
-
to_return(:body => fixture('pull_requests/comment.json'),
|
21
|
-
:status => 200,
|
22
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should fail to get resource without comment id" do
|
26
|
-
expect {
|
27
|
-
github.pull_requests.comments.get user, repo, nil
|
28
|
-
}.to raise_error(ArgumentError)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should get the resource" do
|
32
|
-
github.pull_requests.comments.get user, repo, pull_request_id
|
33
|
-
a_get("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}").
|
34
|
-
should have_been_made
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should get comment information" do
|
38
|
-
comment = github.pull_requests.comments.get user, repo, comment_id
|
39
|
-
comment.id.should eq comment_id
|
40
|
-
comment.user.login.should == 'octocat'
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should return mash" do
|
44
|
-
comment = github.pull_requests.comments.get user, repo, comment_id
|
45
|
-
comment.should be_a Hashie::Mash
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'resource not found' do
|
50
|
-
before do
|
51
|
-
stub_get("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}").
|
52
|
-
to_return(:body => fixture('pull_requests/comment.json'),
|
53
|
-
:status => 404,
|
54
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should fail to retrive resource" do
|
58
|
-
expect {
|
59
|
-
github.pull_requests.comments.get user, repo, comment_id
|
60
|
-
}.to raise_error(Github::Error::NotFound)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end # get
|
64
|
-
|
65
|
-
describe "#create" do
|
66
|
-
let(:inputs) {
|
67
|
-
{
|
68
|
-
"body" => "Nice change",
|
69
|
-
"commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
|
70
|
-
"path" => "file1.txt",
|
71
|
-
"position" => 4,
|
72
|
-
"in_reply_to" => 4,
|
73
|
-
'unrelated' => 'giberrish'
|
74
|
-
}
|
75
|
-
}
|
76
|
-
|
77
|
-
context "resouce created" do
|
78
|
-
before do
|
79
|
-
stub_post("/repos/#{user}/#{repo}/pulls/#{pull_request_id}/comments").
|
80
|
-
with(inputs.except('unrelated')).
|
81
|
-
to_return(:body => fixture('pull_requests/comment.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'raises error when pull_request_id is missing' do
|
85
|
-
expect {
|
86
|
-
github.pull_requests.comments.create user, repo, nil
|
87
|
-
}.to raise_error(ArgumentError)
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should create resource successfully" do
|
91
|
-
github.pull_requests.comments.create user, repo, pull_request_id, inputs
|
92
|
-
a_post("/repos/#{user}/#{repo}/pulls/#{pull_request_id}/comments").
|
93
|
-
with(inputs).should have_been_made
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should return the resource" do
|
97
|
-
pull_request = github.pull_requests.comments.create user, repo, pull_request_id, inputs
|
98
|
-
pull_request.should be_a Hashie::Mash
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should get the request information" do
|
102
|
-
pull_request = github.pull_requests.comments.create user, repo, pull_request_id, inputs
|
103
|
-
pull_request.id.should == pull_request_id
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context "fails to create resource" do
|
108
|
-
before do
|
109
|
-
stub_post("/repos/#{user}/#{repo}/pulls/#{pull_request_id}/comments").
|
110
|
-
with(inputs.except('unrelated')).
|
111
|
-
to_return(:body => fixture('pull_requests/comment.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should faile to retrieve resource" do
|
116
|
-
expect {
|
117
|
-
github.pull_requests.comments.create user, repo, pull_request_id, inputs
|
118
|
-
}.to raise_error(Github::Error::NotFound)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end # create
|
122
|
-
|
123
|
-
describe "#edit" do
|
124
|
-
let(:inputs) {
|
125
|
-
{
|
126
|
-
"body" => "Nice change",
|
127
|
-
'unrelated' => 'giberrish'
|
128
|
-
}
|
129
|
-
}
|
130
|
-
|
131
|
-
context "resouce edited" do
|
132
|
-
before do
|
133
|
-
stub_patch("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}").
|
134
|
-
with(inputs.except('unrelated')).
|
135
|
-
to_return(:body => fixture('pull_requests/comment.json'),
|
136
|
-
:status => 200,
|
137
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should edit resource successfully" do
|
141
|
-
github.pull_requests.comments.edit user, repo, comment_id, inputs
|
142
|
-
a_patch("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}").
|
143
|
-
with(inputs).should have_been_made
|
144
|
-
end
|
145
|
-
|
146
|
-
it "should return the resource" do
|
147
|
-
comment = github.pull_requests.comments.edit user, repo, comment_id, inputs
|
148
|
-
comment.should be_a Hashie::Mash
|
149
|
-
end
|
150
|
-
|
151
|
-
it "should get the comment information" do
|
152
|
-
comment = github.pull_requests.comments.edit user, repo, comment_id, inputs
|
153
|
-
comment.user.login.should == 'octocat'
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
context "failed to edit resource" do
|
158
|
-
before do
|
159
|
-
stub_patch("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}").
|
160
|
-
with(inputs).
|
161
|
-
to_return(:body => fixture('pull_requests/comment.json'),
|
162
|
-
:status => 404,
|
163
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
164
|
-
end
|
165
|
-
|
166
|
-
it "should fail to retrieve resource" do
|
167
|
-
expect {
|
168
|
-
github.pull_requests.comments.edit user, repo, comment_id, inputs
|
169
|
-
}.to raise_error(Github::Error::NotFound)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end # edit
|
173
|
-
|
174
|
-
context "#delete" do
|
175
|
-
before do
|
176
|
-
stub_delete("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}").
|
177
|
-
to_return(:body => fixture('pull_requests/comment.json'),
|
178
|
-
:status => 204,
|
179
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
180
|
-
end
|
181
|
-
|
182
|
-
it 'should raise error if comment_id not present' do
|
183
|
-
expect {
|
184
|
-
github.pull_requests.comments.delete user, repo, nil
|
185
|
-
}.to raise_error(ArgumentError)
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should remove resource successfully" do
|
189
|
-
github.pull_requests.comments.delete user, repo, comment_id
|
190
|
-
a_delete("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}").
|
191
|
-
should have_been_made
|
192
|
-
end
|
193
|
-
|
194
|
-
it "fails to delete resource" do
|
195
|
-
stub_delete("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}").
|
196
|
-
to_return(:body => '',
|
197
|
-
:status => 404,
|
198
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
199
|
-
expect {
|
200
|
-
github.pull_requests.comments.delete user, repo, comment_id
|
201
|
-
}.to raise_error(Github::Error::NotFound)
|
202
|
-
end
|
203
|
-
end # delete
|
9
|
+
it_should_behave_like 'api interface'
|
204
10
|
|
205
11
|
end # Github::PullRequests::Comments
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github, 'options' do
|
6
|
+
let(:default_adapter) { :net_http }
|
7
|
+
let(:adapter) { :patron }
|
8
|
+
let(:options) { { :adapter => adapter } }
|
9
|
+
|
10
|
+
|
11
|
+
context '' do
|
12
|
+
# let(:github) { Github.new options }
|
13
|
+
# let(:repos) { Github::Repos.new }
|
14
|
+
|
15
|
+
it '' do
|
16
|
+
# repos = Github::Repos.new
|
17
|
+
# expect(repos.adapter).to eql default_adapter
|
18
|
+
# expect(Github.current_api).to eql repos
|
19
|
+
#
|
20
|
+
# github = Github.new options
|
21
|
+
# expect(github.adapter).to eql adapter
|
22
|
+
# expect(Github.current_api).to eql github
|
23
|
+
#
|
24
|
+
# expect(github.repos.adapter).to eql adapter
|
25
|
+
# expect(Github.current_api).to_not eql github
|
26
|
+
# expect(Github.current_api).to eql github.repos
|
27
|
+
#
|
28
|
+
# expect(repos.adapter).to eql default_adapter
|
29
|
+
#
|
30
|
+
# new_github = Github.new
|
31
|
+
# expect(new_github.adapter).to eql default_adapter
|
32
|
+
# expect(Github.current_api).to eql new_github
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
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.
|
4
|
+
version: 0.8.8
|
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-
|
12
|
+
date: 2013-01-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|
16
|
-
requirement: &
|
16
|
+
requirement: &2154510820 !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: *
|
24
|
+
version_requirements: *2154510820
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: faraday
|
27
|
-
requirement: &
|
27
|
+
requirement: &2154510320 !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: *
|
35
|
+
version_requirements: *2154510320
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: multi_json
|
38
|
-
requirement: &
|
38
|
+
requirement: &2154509860 !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: *
|
46
|
+
version_requirements: *2154509860
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: oauth2
|
49
|
-
requirement: &
|
49
|
+
requirement: &2154509480 !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: *
|
57
|
+
version_requirements: *2154509480
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: nokogiri
|
60
|
-
requirement: &
|
60
|
+
requirement: &2154508940 !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: *
|
68
|
+
version_requirements: *2154508940
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &2154508440 !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: *
|
79
|
+
version_requirements: *2154508440
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: cucumber
|
82
|
-
requirement: &
|
82
|
+
requirement: &2154507980 !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: *
|
90
|
+
version_requirements: *2154507980
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: webmock
|
93
|
-
requirement: &
|
93
|
+
requirement: &2154507520 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,21 +98,21 @@ dependencies:
|
|
98
98
|
version: 1.9.0
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2154507520
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: vcr
|
104
|
-
requirement: &
|
104
|
+
requirement: &2154507060 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 2.
|
109
|
+
version: 2.4.0
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *2154507060
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: simplecov
|
115
|
-
requirement: &
|
115
|
+
requirement: &2154506600 !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: *
|
123
|
+
version_requirements: *2154506600
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: guard
|
126
|
-
requirement: &
|
126
|
+
requirement: &2154506220 !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: *
|
134
|
+
version_requirements: *2154506220
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: guard-rspec
|
137
|
-
requirement: &
|
137
|
+
requirement: &2154505760 !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: *
|
145
|
+
version_requirements: *2154505760
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: guard-cucumber
|
148
|
-
requirement: &
|
148
|
+
requirement: &2154505340 !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: *
|
156
|
+
version_requirements: *2154505340
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: rake
|
159
|
-
requirement: &
|
159
|
+
requirement: &2154504920 !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: *
|
167
|
+
version_requirements: *2154504920
|
168
168
|
- !ruby/object:Gem::Dependency
|
169
169
|
name: bundler
|
170
|
-
requirement: &
|
170
|
+
requirement: &2154504500 !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: *
|
178
|
+
version_requirements: *2154504500
|
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,6 +650,10 @@ 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/create_spec.rb
|
654
|
+
- spec/github/pull_requests/comments/delete_spec.rb
|
655
|
+
- spec/github/pull_requests/comments/edit_spec.rb
|
656
|
+
- spec/github/pull_requests/comments/get_spec.rb
|
653
657
|
- spec/github/pull_requests/comments/list_spec.rb
|
654
658
|
- spec/github/pull_requests/comments_spec.rb
|
655
659
|
- spec/github/pull_requests/commits_spec.rb
|
@@ -747,6 +751,7 @@ files:
|
|
747
751
|
- spec/github/validations/token_spec.rb
|
748
752
|
- spec/github/validations_spec.rb
|
749
753
|
- spec/github_spec.rb
|
754
|
+
- spec/integration/options_spec.rb
|
750
755
|
- spec/README.rdoc
|
751
756
|
- spec/shared/api_interface_behaviour.rb
|
752
757
|
- spec/shared/array_of_resources_behaviour.rb
|