github_api_v3 0.3.3 → 0.4.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.
- checksums.yaml +4 -4
- data/README.md +16 -6
- data/lib/github_api_v3/client/feeds.rb +1 -1
- data/lib/github_api_v3/client/gists.rb +10 -10
- data/lib/github_api_v3/client/issues.rb +8 -8
- data/lib/github_api_v3/client/markdown.rb +1 -1
- data/lib/github_api_v3/client/oauth.rb +101 -0
- data/lib/github_api_v3/client/orgs.rb +22 -22
- data/lib/github_api_v3/client/pull_requests.rb +14 -14
- data/lib/github_api_v3/client/repos.rb +23 -23
- data/lib/github_api_v3/client/stats.rb +5 -5
- data/lib/github_api_v3/client/users.rb +30 -20
- data/lib/github_api_v3/client.rb +73 -64
- data/lib/github_api_v3/error.rb +20 -2
- data/lib/github_api_v3/version.rb +1 -1
- data/lib/github_api_v3.rb +2 -2
- data/spec/cassettes/GitHub_Client_Gists/_create_gist/creates_a_gist.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_create_gist_comment/creates_the_comment.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_create_gist_comment/returns_comment_information_after_creation.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_delete_gist/deletes_a_gist.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_delete_gist_comment/deletes_the_comment.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_delete_gist_comment/returns_true_or_false.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_edit_gist/edits_a_gist.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_edit_gist_comment/edits_the_comment.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_edit_gist_comment/returns_comment_information_after_editing.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_fork_gist/forks_a_gist.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_fork_gist/returns_false_when_not_found.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_gist/returns_a_404_when_not_found.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_gist/returns_gist_information.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_gist_comment/returns_a_404_when_not_found.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_gist_comment/returns_a_comment.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_gist_comments/returns_a_404_when_not_found.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_gist_comments/returns_a_list_of_comments.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_gist_starred_/returns_false_when_not_found.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_gist_starred_/should_return_true_or_false.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_gists/returns_an_array_of_gists.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_gists/returns_an_array_of_gists_for_authenticated_user.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_gists/returns_public_gists_for_unauthenticated_user.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_star_gist/returns_false_when_not_found.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_star_gist/stars_a_gist.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_unstar_gist/returns_false_when_not_found.json +1 -1
- data/spec/cassettes/GitHub_Client_Gists/_unstar_gist/unstars_a_gist.json +1 -1
- data/spec/cassettes/GitHub_Client_Issues/_issues/returns_an_array_of_issues.json +1 -1
- data/spec/cassettes/GitHub_Client_Issues/_issues/returns_the_correct_information.json +1 -1
- data/spec/cassettes/GitHub_Client_OAuth/_authorization/returns_a_404_if_using_access_token_authentication.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_authorization/returns_a_404_if_using_no_authentication.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_authorization/returns_a_404_when_not_found.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_authorization/returns_authorization_information.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_authorization/returns_the_correct_information.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_authorizations/returns_a_404_if_using_access_token_authentication.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_authorizations/returns_a_404_if_using_no_authentication.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_authorizations/returns_a_list_of_authorizations.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_authorizations/returns_the_correct_array.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_create_authorization/creates_the_correct_authorization.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_create_authorization/returns_authorization_information_hash.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_delete_authorization/deletes_the_authorization.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_delete_authorization/returns_true.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_update_authorization/returns_authorization_information_hash.json +1 -0
- data/spec/cassettes/GitHub_Client_OAuth/_update_authorization/updates_the_authorization.json +1 -0
- data/spec/cassettes/GitHub_Client_Users/_follows_/returns_false_when_not_following.json +1 -1
- data/spec/cassettes/GitHub_Client_Users/_follows_/returns_true_when_following.json +1 -1
- data/spec/cassettes/GitHub_Client_Users/_rate_limit/returns_authenticated_rate_limit_information.json +1 -0
- data/spec/cassettes/GitHub_Client_Users/_rate_limit/returns_unauthenticated_rate_limit_information.json +1 -0
- data/spec/config.sample.yml +3 -1
- data/spec/github_api_v3/client/gists_spec.rb +25 -25
- data/spec/github_api_v3/client/oauth_spec.rb +87 -0
- data/spec/github_api_v3/client/users_spec.rb +16 -0
- data/spec/spec_helper.rb +21 -11
- metadata +38 -1
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GitHub::Client::OAuth do
|
4
|
+
|
5
|
+
describe '.authorizations', :vcr do
|
6
|
+
let(:response) { test_basic_client.authorizations }
|
7
|
+
|
8
|
+
it 'returns a list of authorizations' do
|
9
|
+
response.should be_instance_of Array
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns the correct array' do
|
13
|
+
response[-1].app.name.should == "GitHub API"
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'returns a 404 if using access token authentication' do
|
17
|
+
expect { test_client.authorizations }.to raise_error GitHub::NotFound
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'returns a 404 if using no authentication' do
|
21
|
+
expect { GitHub.authorizations }.to raise_error GitHub::NotFound
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.authorization', :vcr do
|
26
|
+
let(:response) { test_basic_client.authorization(3410354) }
|
27
|
+
|
28
|
+
it 'returns authorization information' do
|
29
|
+
response.should be_instance_of Hash
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'returns the correct information' do
|
33
|
+
response.id.should == 3410354
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'returns a 404 when not found' do
|
37
|
+
expect { test_basic_client.authorization(341035423) }.to raise_error GitHub::NotFound
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns a 404 if using access token authentication' do
|
41
|
+
expect { test_client.authorization(341035423) }.to raise_error GitHub::NotFound
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'returns a 404 if using no authentication' do
|
45
|
+
expect { GitHub.authorization(341035423) }.to raise_error GitHub::NotFound
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
authorization_id = ""
|
50
|
+
describe '.create_authorization', :vcr do
|
51
|
+
let(:response) { test_basic_client.create_authorization(:note => "Test authorization.", :client_id => test_client_id, :client_secret => test_client_secret) }
|
52
|
+
|
53
|
+
it 'returns authorization information hash' do
|
54
|
+
response.should be_instance_of Hash
|
55
|
+
authorization_id = response.id
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'creates the correct authorization' do
|
59
|
+
response.app.client_id.should == test_client_id
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '.update_authorization', :vcr do
|
64
|
+
let(:response) { test_basic_client.update_authorization(authorization_id, :note => "Updated test authorization.") }
|
65
|
+
|
66
|
+
it 'returns authorization information hash' do
|
67
|
+
response.should be_instance_of Hash
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'updates the authorization' do
|
71
|
+
response.note.should == "Updated test authorization."
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '.delete authorization', :vcr do
|
76
|
+
let(:response) { test_basic_client.delete_authorization(authorization_id) }
|
77
|
+
|
78
|
+
it 'returns true' do
|
79
|
+
response.should be_true
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'deletes the authorization' do
|
83
|
+
expect { test_basic_client.authorization(authorization_id) }.to raise_error GitHub::NotFound
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -179,4 +179,20 @@ describe GitHub::Client::Users do
|
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
182
|
+
describe '.rate_limit', :vcr do
|
183
|
+
let(:response) { GitHub.rate_limit }
|
184
|
+
let(:auth_response) { test_client.rate_limit }
|
185
|
+
|
186
|
+
it 'returns unauthenticated rate limit information' do
|
187
|
+
response.should be_instance_of Hash
|
188
|
+
response.rate.limit.should == 60
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'returns authenticated rate limit information' do
|
192
|
+
auth_response.should be_instance_of Hash
|
193
|
+
auth_response.rate.limit.should == 5000
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
182
198
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,15 +13,13 @@ end
|
|
13
13
|
|
14
14
|
VCR.configure do |c|
|
15
15
|
c.configure_rspec_metadata!
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
c.filter_sensitive_data("<
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
CONFIG['test_password']
|
24
|
-
end
|
16
|
+
|
17
|
+
c.filter_sensitive_data("<TEST_ACCESS_TOKEN>") { CONFIG['test_access_token'] }
|
18
|
+
c.filter_sensitive_data("<TEST_LOGIN>") { CONFIG['test_login'] }
|
19
|
+
c.filter_sensitive_data("<TEST_PASSWORD>") { CONFIG['test_password'] }
|
20
|
+
c.filter_sensitive_data("<TEST_CLIENT_ID>") { CONFIG['test_client_id'] }
|
21
|
+
c.filter_sensitive_data("<TEST_CLIENT_SECRET") { CONFIG['test_client_secret'] }
|
22
|
+
|
25
23
|
c.cassette_library_dir = 'spec/cassettes'
|
26
24
|
c.default_cassette_options = {
|
27
25
|
:serialize_with => :json,
|
@@ -43,6 +41,18 @@ def test_access_token
|
|
43
41
|
CONFIG['test_access_token']
|
44
42
|
end
|
45
43
|
|
46
|
-
def
|
47
|
-
|
44
|
+
def test_client_id
|
45
|
+
CONFIG['test_client_id']
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_client_secret
|
49
|
+
CONFIG['test_client_secret']
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_basic_client
|
53
|
+
GitHub::Client.new(login: test_login, password: test_password)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_client
|
57
|
+
GitHub::Client.new(login: test_login, access_token: test_access_token)
|
48
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github_api_v3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Casey Scarborough
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/github_api_v3/client/gitignore.rb
|
117
117
|
- lib/github_api_v3/client/issues.rb
|
118
118
|
- lib/github_api_v3/client/markdown.rb
|
119
|
+
- lib/github_api_v3/client/oauth.rb
|
119
120
|
- lib/github_api_v3/client/orgs.rb
|
120
121
|
- lib/github_api_v3/client/pull_requests.rb
|
121
122
|
- lib/github_api_v3/client/repos.rb
|
@@ -179,6 +180,21 @@ files:
|
|
179
180
|
- spec/cassettes/GitHub_Client_Issues/_user_issues/returns_an_array_of_issues.json
|
180
181
|
- spec/cassettes/GitHub_Client_Issues/_user_issues/returns_the_correct_information.json
|
181
182
|
- spec/cassettes/GitHub_Client_Markdown/_markdown/returns_rendered_markdown.json
|
183
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorization/returns_a_404_if_using_access_token_authentication.json
|
184
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorization/returns_a_404_if_using_no_authentication.json
|
185
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorization/returns_a_404_when_not_found.json
|
186
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorization/returns_authorization_information.json
|
187
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorization/returns_the_correct_information.json
|
188
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorizations/returns_a_404_if_using_access_token_authentication.json
|
189
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorizations/returns_a_404_if_using_no_authentication.json
|
190
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorizations/returns_a_list_of_authorizations.json
|
191
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorizations/returns_the_correct_array.json
|
192
|
+
- spec/cassettes/GitHub_Client_OAuth/_create_authorization/creates_the_correct_authorization.json
|
193
|
+
- spec/cassettes/GitHub_Client_OAuth/_create_authorization/returns_authorization_information_hash.json
|
194
|
+
- spec/cassettes/GitHub_Client_OAuth/_delete_authorization/deletes_the_authorization.json
|
195
|
+
- spec/cassettes/GitHub_Client_OAuth/_delete_authorization/returns_true.json
|
196
|
+
- spec/cassettes/GitHub_Client_OAuth/_update_authorization/returns_authorization_information_hash.json
|
197
|
+
- spec/cassettes/GitHub_Client_OAuth/_update_authorization/updates_the_authorization.json
|
182
198
|
- spec/cassettes/GitHub_Client_Orgs/_add_team_member/adds_a_team_member.json
|
183
199
|
- spec/cassettes/GitHub_Client_Orgs/_add_team_repo/adds_a_team_repo.json
|
184
200
|
- spec/cassettes/GitHub_Client_Orgs/_create_team/creates_a_team.json
|
@@ -273,6 +289,8 @@ files:
|
|
273
289
|
- spec/cassettes/GitHub_Client_Users/_notifications/returns_an_array_of_notifications.json
|
274
290
|
- spec/cassettes/GitHub_Client_Users/_organizations/returns_an_authenticated_users_organizations.json
|
275
291
|
- spec/cassettes/GitHub_Client_Users/_organizations/returns_an_unauthenticated_users_organizations.json
|
292
|
+
- spec/cassettes/GitHub_Client_Users/_rate_limit/returns_authenticated_rate_limit_information.json
|
293
|
+
- spec/cassettes/GitHub_Client_Users/_rate_limit/returns_unauthenticated_rate_limit_information.json
|
276
294
|
- spec/cassettes/GitHub_Client_Users/_repo_notifications/returns_an_array_of_notifications.json
|
277
295
|
- spec/cassettes/GitHub_Client_Users/_starring/returns_a_404_for_not_found.json
|
278
296
|
- spec/cassettes/GitHub_Client_Users/_starring/returns_an_authenticated_users_repos.json
|
@@ -297,6 +315,7 @@ files:
|
|
297
315
|
- spec/github_api_v3/client/gitignore_spec.rb
|
298
316
|
- spec/github_api_v3/client/issues_spec.rb
|
299
317
|
- spec/github_api_v3/client/markdown_spec.rb
|
318
|
+
- spec/github_api_v3/client/oauth_spec.rb
|
300
319
|
- spec/github_api_v3/client/orgs_spec.rb
|
301
320
|
- spec/github_api_v3/client/pull_requests_spec.rb
|
302
321
|
- spec/github_api_v3/client/repos_spec.rb
|
@@ -384,6 +403,21 @@ test_files:
|
|
384
403
|
- spec/cassettes/GitHub_Client_Issues/_user_issues/returns_an_array_of_issues.json
|
385
404
|
- spec/cassettes/GitHub_Client_Issues/_user_issues/returns_the_correct_information.json
|
386
405
|
- spec/cassettes/GitHub_Client_Markdown/_markdown/returns_rendered_markdown.json
|
406
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorization/returns_a_404_if_using_access_token_authentication.json
|
407
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorization/returns_a_404_if_using_no_authentication.json
|
408
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorization/returns_a_404_when_not_found.json
|
409
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorization/returns_authorization_information.json
|
410
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorization/returns_the_correct_information.json
|
411
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorizations/returns_a_404_if_using_access_token_authentication.json
|
412
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorizations/returns_a_404_if_using_no_authentication.json
|
413
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorizations/returns_a_list_of_authorizations.json
|
414
|
+
- spec/cassettes/GitHub_Client_OAuth/_authorizations/returns_the_correct_array.json
|
415
|
+
- spec/cassettes/GitHub_Client_OAuth/_create_authorization/creates_the_correct_authorization.json
|
416
|
+
- spec/cassettes/GitHub_Client_OAuth/_create_authorization/returns_authorization_information_hash.json
|
417
|
+
- spec/cassettes/GitHub_Client_OAuth/_delete_authorization/deletes_the_authorization.json
|
418
|
+
- spec/cassettes/GitHub_Client_OAuth/_delete_authorization/returns_true.json
|
419
|
+
- spec/cassettes/GitHub_Client_OAuth/_update_authorization/returns_authorization_information_hash.json
|
420
|
+
- spec/cassettes/GitHub_Client_OAuth/_update_authorization/updates_the_authorization.json
|
387
421
|
- spec/cassettes/GitHub_Client_Orgs/_add_team_member/adds_a_team_member.json
|
388
422
|
- spec/cassettes/GitHub_Client_Orgs/_add_team_repo/adds_a_team_repo.json
|
389
423
|
- spec/cassettes/GitHub_Client_Orgs/_create_team/creates_a_team.json
|
@@ -478,6 +512,8 @@ test_files:
|
|
478
512
|
- spec/cassettes/GitHub_Client_Users/_notifications/returns_an_array_of_notifications.json
|
479
513
|
- spec/cassettes/GitHub_Client_Users/_organizations/returns_an_authenticated_users_organizations.json
|
480
514
|
- spec/cassettes/GitHub_Client_Users/_organizations/returns_an_unauthenticated_users_organizations.json
|
515
|
+
- spec/cassettes/GitHub_Client_Users/_rate_limit/returns_authenticated_rate_limit_information.json
|
516
|
+
- spec/cassettes/GitHub_Client_Users/_rate_limit/returns_unauthenticated_rate_limit_information.json
|
481
517
|
- spec/cassettes/GitHub_Client_Users/_repo_notifications/returns_an_array_of_notifications.json
|
482
518
|
- spec/cassettes/GitHub_Client_Users/_starring/returns_a_404_for_not_found.json
|
483
519
|
- spec/cassettes/GitHub_Client_Users/_starring/returns_an_authenticated_users_repos.json
|
@@ -502,6 +538,7 @@ test_files:
|
|
502
538
|
- spec/github_api_v3/client/gitignore_spec.rb
|
503
539
|
- spec/github_api_v3/client/issues_spec.rb
|
504
540
|
- spec/github_api_v3/client/markdown_spec.rb
|
541
|
+
- spec/github_api_v3/client/oauth_spec.rb
|
505
542
|
- spec/github_api_v3/client/orgs_spec.rb
|
506
543
|
- spec/github_api_v3/client/pull_requests_spec.rb
|
507
544
|
- spec/github_api_v3/client/repos_spec.rb
|