github_api 0.3.4 → 0.3.5
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.
- metadata +4 -140
- data/LICENSE.txt +0 -20
- data/README.rdoc +0 -228
- data/Rakefile +0 -52
- data/features/github_api.feature +0 -50
- data/features/step_definitions/github_api_steps.rb +0 -11
- data/features/support/env.rb +0 -13
- data/lib/github_api.rb +0 -73
- data/lib/github_api/api.rb +0 -175
- data/lib/github_api/api/utils.rb +0 -9
- data/lib/github_api/authorization.rb +0 -73
- data/lib/github_api/authorizations.rb +0 -119
- data/lib/github_api/cache_control.rb +0 -19
- data/lib/github_api/client.rb +0 -55
- data/lib/github_api/compatibility.rb +0 -23
- data/lib/github_api/configuration.rb +0 -96
- data/lib/github_api/connection.rb +0 -81
- data/lib/github_api/core_ext/array.rb +0 -14
- data/lib/github_api/core_ext/hash.rb +0 -42
- data/lib/github_api/error.rb +0 -35
- data/lib/github_api/events.rb +0 -202
- data/lib/github_api/gists.rb +0 -200
- data/lib/github_api/gists/comments.rb +0 -86
- data/lib/github_api/git_data.rb +0 -26
- data/lib/github_api/git_data/blobs.rb +0 -51
- data/lib/github_api/git_data/commits.rb +0 -78
- data/lib/github_api/git_data/references.rb +0 -113
- data/lib/github_api/git_data/tags.rb +0 -78
- data/lib/github_api/git_data/trees.rb +0 -89
- data/lib/github_api/issues.rb +0 -215
- data/lib/github_api/issues/comments.rb +0 -110
- data/lib/github_api/issues/events.rb +0 -50
- data/lib/github_api/issues/labels.rb +0 -191
- data/lib/github_api/issues/milestones.rb +0 -119
- data/lib/github_api/mime_type.rb +0 -55
- data/lib/github_api/orgs.rb +0 -95
- data/lib/github_api/orgs/members.rb +0 -120
- data/lib/github_api/orgs/teams.rb +0 -245
- data/lib/github_api/pull_requests.rb +0 -224
- data/lib/github_api/pull_requests/comments.rb +0 -144
- data/lib/github_api/repos.rb +0 -286
- data/lib/github_api/repos/collaborators.rb +0 -81
- data/lib/github_api/repos/commits.rb +0 -180
- data/lib/github_api/repos/downloads.rb +0 -155
- data/lib/github_api/repos/forks.rb +0 -48
- data/lib/github_api/repos/hooks.rb +0 -173
- data/lib/github_api/repos/keys.rb +0 -104
- data/lib/github_api/repos/pub_sub_hubbub.rb +0 -102
- data/lib/github_api/repos/watching.rb +0 -94
- data/lib/github_api/request.rb +0 -84
- data/lib/github_api/request/basic_auth.rb +0 -31
- data/lib/github_api/request/caching.rb +0 -33
- data/lib/github_api/request/oauth2.rb +0 -33
- data/lib/github_api/response.rb +0 -28
- data/lib/github_api/response/helpers.rb +0 -14
- data/lib/github_api/response/jsonize.rb +0 -26
- data/lib/github_api/response/mashify.rb +0 -24
- data/lib/github_api/response/raise_error.rb +0 -33
- data/lib/github_api/result.rb +0 -42
- data/lib/github_api/users.rb +0 -84
- data/lib/github_api/users/emails.rb +0 -49
- data/lib/github_api/users/followers.rb +0 -98
- data/lib/github_api/users/keys.rb +0 -84
- data/lib/github_api/version.rb +0 -12
- data/spec/README.rdoc +0 -22
- data/spec/coverage_adapter.rb +0 -14
- data/spec/fixtures/auths/authorization.json +0 -14
- data/spec/fixtures/auths/authorizations.json +0 -16
- data/spec/fixtures/events/events.json +0 -29
- data/spec/fixtures/issues/issue.json +0 -56
- data/spec/fixtures/issues/issues.json +0 -58
- data/spec/fixtures/orgs/members.json +0 -9
- data/spec/fixtures/orgs/org.json +0 -18
- data/spec/fixtures/orgs/orgs.json +0 -8
- data/spec/fixtures/orgs/team.json +0 -8
- data/spec/fixtures/orgs/team_repos.json +0 -29
- data/spec/fixtures/orgs/teams.json +0 -7
- data/spec/fixtures/repos/branches.json +0 -9
- data/spec/fixtures/repos/collaborators.json +0 -8
- data/spec/fixtures/repos/commit.json +0 -53
- data/spec/fixtures/repos/commit_comment.json +0 -16
- data/spec/fixtures/repos/commit_comments.json +0 -18
- data/spec/fixtures/repos/commits.json +0 -27
- data/spec/fixtures/repos/contributors.json +0 -8
- data/spec/fixtures/repos/download.json +0 -10
- data/spec/fixtures/repos/download_s3.json +0 -21
- data/spec/fixtures/repos/downloads.json +0 -12
- data/spec/fixtures/repos/fork.json +0 -27
- data/spec/fixtures/repos/forks.json +0 -29
- data/spec/fixtures/repos/hook.json +0 -15
- data/spec/fixtures/repos/hooks.json +0 -10
- data/spec/fixtures/repos/key.json +0 -6
- data/spec/fixtures/repos/keys.json +0 -8
- data/spec/fixtures/repos/languages.json +0 -4
- data/spec/fixtures/repos/repo.json +0 -90
- data/spec/fixtures/repos/repo_comments.json +0 -18
- data/spec/fixtures/repos/repos.json +0 -29
- data/spec/fixtures/repos/tags.json +0 -11
- data/spec/fixtures/repos/teams.json +0 -7
- data/spec/fixtures/repos/watched.json +0 -29
- data/spec/fixtures/repos/watchers.json +0 -8
- data/spec/fixtures/users/user.json +0 -32
- data/spec/github/api_spec.rb +0 -25
- data/spec/github/authorization_spec.rb +0 -176
- data/spec/github/authorizations_spec.rb +0 -242
- data/spec/github/client_spec.rb +0 -50
- data/spec/github/core_ext/hash_spec.rb +0 -44
- data/spec/github/events_spec.rb +0 -491
- data/spec/github/gists/comments_spec.rb +0 -5
- data/spec/github/gists_spec.rb +0 -5
- data/spec/github/git_data/blobs_spec.rb +0 -5
- data/spec/github/git_data/commits_spec.rb +0 -5
- data/spec/github/git_data/references_spec.rb +0 -5
- data/spec/github/git_data/tags_spec.rb +0 -5
- data/spec/github/git_data/trees_spec.rb +0 -5
- data/spec/github/git_data_spec.rb +0 -5
- data/spec/github/issues/comments_spec.rb +0 -5
- data/spec/github/issues/events_spec.rb +0 -5
- data/spec/github/issues/labels_spec.rb +0 -5
- data/spec/github/issues/milestones_spec.rb +0 -5
- data/spec/github/issues_spec.rb +0 -287
- data/spec/github/mime_type_spec.rb +0 -70
- data/spec/github/orgs/members_spec.rb +0 -275
- data/spec/github/orgs/teams_spec.rb +0 -563
- data/spec/github/orgs_spec.rb +0 -160
- data/spec/github/repos/collaborators_spec.rb +0 -169
- data/spec/github/repos/commits_spec.rb +0 -424
- data/spec/github/repos/downloads_spec.rb +0 -236
- data/spec/github/repos/forks_spec.rb +0 -103
- data/spec/github/repos/hooks_spec.rb +0 -307
- data/spec/github/repos/keys_spec.rb +0 -216
- data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -83
- data/spec/github/repos/watching_spec.rb +0 -222
- data/spec/github/repos_spec.rb +0 -571
- data/spec/github/result_spec.rb +0 -43
- data/spec/github/users_spec.rb +0 -140
- data/spec/github_spec.rb +0 -109
- data/spec/spec_helper.rb +0 -86
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"login": "octocat",
|
|
3
|
-
"id": 1,
|
|
4
|
-
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
|
5
|
-
"gravatar_id": "somehexcode",
|
|
6
|
-
"url": "https://api.github.com/users/octocat",
|
|
7
|
-
"name": "monalisa octocat",
|
|
8
|
-
"company": "GitHub",
|
|
9
|
-
"blog": "https://github.com/blog",
|
|
10
|
-
"location": "San Francisco",
|
|
11
|
-
"email": "octocat@github.com",
|
|
12
|
-
"hireable": false,
|
|
13
|
-
"bio": "There once was...",
|
|
14
|
-
"public_repos": 2,
|
|
15
|
-
"public_gists": 1,
|
|
16
|
-
"followers": 20,
|
|
17
|
-
"following": 0,
|
|
18
|
-
"html_url": "https://github.com/octocat",
|
|
19
|
-
"created_at": "2008-01-14T04:33:35Z",
|
|
20
|
-
"type": "User",
|
|
21
|
-
"total_private_repos": 100,
|
|
22
|
-
"owned_private_repos": 100,
|
|
23
|
-
"private_gists": 81,
|
|
24
|
-
"disk_usage": 10000,
|
|
25
|
-
"collaborators": 8,
|
|
26
|
-
"plan": {
|
|
27
|
-
"name": "Medium",
|
|
28
|
-
"space": 400,
|
|
29
|
-
"collaborators": 10,
|
|
30
|
-
"private_repos": 20
|
|
31
|
-
}
|
|
32
|
-
}
|
data/spec/github/api_spec.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Github::API do
|
|
4
|
-
|
|
5
|
-
let(:api) { Github::API.new }
|
|
6
|
-
|
|
7
|
-
before(:each) do
|
|
8
|
-
@params = { 'a' => { :b => { 'c' => 1 }, 'd' => [ 'a', { :e => 2 }] } }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "should stringify all the keys inside nested hash" do
|
|
12
|
-
actual = api.send(:_normalize_params_keys, @params)
|
|
13
|
-
expected = { 'a' => { 'b'=> { 'c' => 1 }, 'd' => [ 'a', { 'e'=> 2 }] } }
|
|
14
|
-
actual.should == expected
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "should filter param keys" do
|
|
18
|
-
valid = ['a', 'b', 'e']
|
|
19
|
-
hash = {'a' => 1, 'b' => 3, 'c' => 2, 'd'=> 4, 'e' => 5 }
|
|
20
|
-
actual = api.send(:_filter_params_keys, valid, hash)
|
|
21
|
-
expected = {'a' => 1, 'b' => 3, 'e' => 5 }
|
|
22
|
-
actual.should == expected
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
end
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Github::Authorization do
|
|
4
|
-
|
|
5
|
-
let(:client_id) { '234jl23j4l23j4l' }
|
|
6
|
-
let(:client_secret) { 'asasd79sdf9a7asfd7sfd97s' }
|
|
7
|
-
let(:code) { 'c9798sdf97df98ds'}
|
|
8
|
-
let(:github) { Github.new }
|
|
9
|
-
|
|
10
|
-
it "should instantiate oauth2 instance" do
|
|
11
|
-
github.client.should be_a OAuth2::Client
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "should assign site from the options hash" do
|
|
15
|
-
github.client.site.should == 'https://github.com'
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "should assign 'authorize_url" do
|
|
19
|
-
github.client.authorize_url.should == 'https://github.com/login/oauth/authorize'
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should assign 'token_url" do
|
|
23
|
-
github.client.token_url.should == 'https://github.com/login/oauth/access_token'
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context '.client' do
|
|
27
|
-
it { github.should respond_to :client }
|
|
28
|
-
|
|
29
|
-
it "should return OAuth2::Client instance" do
|
|
30
|
-
github.client.should be_a OAuth2::Client
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context '.auth_code' do
|
|
35
|
-
let(:oauth) { OAuth2::Client.new(client_id, client_secret) }
|
|
36
|
-
|
|
37
|
-
before do
|
|
38
|
-
github = Github.new :client_id => client_id, :client_secret => client_secret
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
after do
|
|
42
|
-
github.client_id, github.client_secret = nil, nil
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "should throw an error if no client_id" do
|
|
46
|
-
github.client_id = nil
|
|
47
|
-
expect { github.auth_code }.should raise_error(ArgumentError)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "should throw an error if no client_secret" do
|
|
51
|
-
github.client_secret = nil
|
|
52
|
-
expect { github.auth_code }.should raise_error(ArgumentError)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "should return authentication token code" do
|
|
56
|
-
github.client_id = client_id
|
|
57
|
-
github.client_secret = client_secret
|
|
58
|
-
github.client.stub(:auth_code).and_return code
|
|
59
|
-
github.auth_code.should == code
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
context "authorize_url" do
|
|
64
|
-
before do
|
|
65
|
-
github = Github.new :client_id => client_id, :client_secret => client_secret
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "should respond to 'authorize_url' " do
|
|
69
|
-
github.should respond_to :authorize_url
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it "should return address containing client_id" do
|
|
73
|
-
github.authorize_url.should =~ /client_id=#{client_id}/
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it "should return address containing scopes" do
|
|
77
|
-
github.authorize_url(:scope => 'user').should =~ /scope=user/
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it "should return address containing redirect_uri" do
|
|
81
|
-
github.authorize_url(:redirect_uri => 'http://localhost').should =~ /redirect_uri/
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
context "get_token" do
|
|
86
|
-
before do
|
|
87
|
-
github = Github.new :client_id => client_id, :client_secret => client_secret
|
|
88
|
-
stub_request(:post, 'https://github.com/login/oauth/access_token').
|
|
89
|
-
to_return(:body => '', :status => 200, :headers => {})
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it "should respond to 'get_token' " do
|
|
93
|
-
github.should respond_to :get_token
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "should make the authorization request" do
|
|
97
|
-
expect {
|
|
98
|
-
github.get_token code
|
|
99
|
-
a_request(:post, "https://github.com/login/oauth/access_token").should have_been_made
|
|
100
|
-
}.to raise_error(OAuth2::Error)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it "should fail to get_token without authorization code" do
|
|
104
|
-
expect { github.get_token }.to raise_error(ArgumentError)
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
context ".authenticated?" do
|
|
109
|
-
it { github.should respond_to :authenticated? }
|
|
110
|
-
|
|
111
|
-
it "should return false if falied on basic authentication" do
|
|
112
|
-
github.stub(:basic_authed?).and_return false
|
|
113
|
-
github.authenticated?.should be_false
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
it "should return true if basic authentication performed" do
|
|
117
|
-
github.stub(:basic_authed?).and_return true
|
|
118
|
-
github.authenticated?.should be_true
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
it "should return true if basic authentication performed" do
|
|
122
|
-
github.stub(:oauth_token?).and_return true
|
|
123
|
-
github.authenticated?.should be_true
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
context ".basic_authed?" do
|
|
128
|
-
it { github.should respond_to :basic_authed? }
|
|
129
|
-
|
|
130
|
-
it "should return false if login is missing" do
|
|
131
|
-
github.stub(:login?).and_return false
|
|
132
|
-
github.basic_authed?.should be_false
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
it "should return true if login && password provided" do
|
|
136
|
-
github.stub(:login?).and_return true
|
|
137
|
-
github.stub(:password?).and_return true
|
|
138
|
-
github.basic_authed?.should be_true
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
context "authentication" do
|
|
143
|
-
it "should respond to 'authentication'" do
|
|
144
|
-
github.should respond_to :authentication
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
it "should return empty hash if no basic authentication params available" do
|
|
148
|
-
github.stub(:login?).and_return false
|
|
149
|
-
github.stub(:basic_auth?).and_return false
|
|
150
|
-
github.authentication.should be_empty
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
context 'basic_auth' do
|
|
154
|
-
before do
|
|
155
|
-
github = Github.new :basic_auth => 'github:pass'
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
it "should return hash with basic auth params" do
|
|
159
|
-
github.authentication.should be_a Hash
|
|
160
|
-
github.authentication.should have_key :basic_auth
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
context 'login & password' do
|
|
165
|
-
before do
|
|
166
|
-
github = Github.new :login => 'github', :password => 'pass'
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
it "should return hash with login & password params" do
|
|
170
|
-
github.authentication.should be_a Hash
|
|
171
|
-
github.authentication.should have_key :login
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
end # authentication
|
|
175
|
-
|
|
176
|
-
end # Github::Authorization
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Github::Authorizations do
|
|
4
|
-
|
|
5
|
-
let(:github) { Github.new }
|
|
6
|
-
let(:basic_auth) { 'login:password' }
|
|
7
|
-
|
|
8
|
-
before do
|
|
9
|
-
github.basic_auth = basic_auth
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
after do
|
|
13
|
-
reset_authentication_for github
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe "authorizations" do
|
|
17
|
-
context "resource found" do
|
|
18
|
-
before do
|
|
19
|
-
stub_get("/authorizations", "https://#{basic_auth}@api.github.com").
|
|
20
|
-
to_return(:body => fixture('auths/authorizations.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
it "should fail to get resource without basic authentication" do
|
|
25
|
-
reset_authentication_for github
|
|
26
|
-
expect { github.oauth.authorizations }.to raise_error(ArgumentError)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "should get the resources" do
|
|
30
|
-
github.oauth.authorizations
|
|
31
|
-
a_get("/authorizations", "https://#{basic_auth}@api.github.com").should have_been_made
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should return array of resources" do
|
|
35
|
-
authorizations = github.oauth.authorizations
|
|
36
|
-
authorizations.should be_an Array
|
|
37
|
-
authorizations.should have(1).items
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "should be a mash type" do
|
|
41
|
-
authorizations = github.oauth.authorizations
|
|
42
|
-
authorizations.first.should be_a Hashie::Mash
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "should get authorization information" do
|
|
46
|
-
authorizations = github.oauth.authorizations
|
|
47
|
-
authorizations.first.token.should == 'abc123'
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "should yield to a block" do
|
|
51
|
-
github.oauth.should_receive(:authorizations).and_yield('web')
|
|
52
|
-
github.oauth.authorizations { |param| 'web' }
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context "resource not found" do
|
|
57
|
-
before do
|
|
58
|
-
stub_get("/authorizations", "https://#{basic_auth}@api.github.com").
|
|
59
|
-
to_return(:body => "", :status => [404, "Not Found"])
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "should return 404 with a message 'Not Found'" do
|
|
63
|
-
expect { github.oauth.authorizations }.to raise_error(Github::ResourceNotFound)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end # authorizations
|
|
67
|
-
|
|
68
|
-
describe "authorization" do
|
|
69
|
-
let(:authorization_id) { 1 }
|
|
70
|
-
|
|
71
|
-
context "resource found" do
|
|
72
|
-
before do
|
|
73
|
-
stub_get("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").
|
|
74
|
-
to_return(:body => fixture('auths/authorization.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "should fail to get resource without authorization id" do
|
|
78
|
-
expect { github.oauth.authorization nil }.to raise_error(ArgumentError)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "should get the resource" do
|
|
82
|
-
github.oauth.authorization authorization_id
|
|
83
|
-
a_get("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").should have_been_made
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it "should get authorization information" do
|
|
87
|
-
authorization = github.oauth.authorization authorization_id
|
|
88
|
-
authorization.id.should == authorization_id
|
|
89
|
-
authorization.token.should == 'abc123'
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it "should return mash" do
|
|
93
|
-
authorization = github.oauth.authorization authorization_id
|
|
94
|
-
authorization.should be_a Hashie::Mash
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
context "resource not found" do
|
|
99
|
-
before do
|
|
100
|
-
stub_get("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").
|
|
101
|
-
to_return(:body => fixture('auths/authorization.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it "should fail to retrive resource" do
|
|
105
|
-
expect {
|
|
106
|
-
github.oauth.authorization authorization_id
|
|
107
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end # authorization
|
|
111
|
-
|
|
112
|
-
describe "create_authorization" do
|
|
113
|
-
let(:inputs) { { :scopes => ['repo'] } }
|
|
114
|
-
|
|
115
|
-
context "resouce created" do
|
|
116
|
-
|
|
117
|
-
it "should fail to get resource without basic authentication" do
|
|
118
|
-
reset_authentication_for github
|
|
119
|
-
expect { github.oauth.create_authorization }.to raise_error(ArgumentError)
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
before do
|
|
123
|
-
stub_post("/authorizations", "https://#{basic_auth}@api.github.com").with(inputs).
|
|
124
|
-
to_return(:body => fixture('auths/authorization.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it "should create resource successfully" do
|
|
128
|
-
github.oauth.create_authorization inputs
|
|
129
|
-
a_post("/authorizations", "https://#{basic_auth}@api.github.com").with(inputs).should have_been_made
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
it "should return the resource" do
|
|
133
|
-
authorization = github.oauth.create_authorization inputs
|
|
134
|
-
authorization.should be_a Hashie::Mash
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
it "should get the authorization information" do
|
|
138
|
-
authorization = github.oauth.create_authorization inputs
|
|
139
|
-
authorization.token.should == 'abc123'
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
context "failed to create resource" do
|
|
144
|
-
before do
|
|
145
|
-
stub_post("/authorizations", "https://#{basic_auth}@api.github.com").with(inputs).
|
|
146
|
-
to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
147
|
-
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
it "should fail to retrieve resource" do
|
|
151
|
-
expect {
|
|
152
|
-
github.oauth.create_authorization inputs
|
|
153
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
end # create_authorization
|
|
157
|
-
|
|
158
|
-
describe "update_authorization" do
|
|
159
|
-
let(:authorization_id) { 1 }
|
|
160
|
-
let(:inputs) { { :add_scopes => ['repo'] } }
|
|
161
|
-
|
|
162
|
-
context "resouce updated" do
|
|
163
|
-
|
|
164
|
-
it "should fail to get resource without basic authentication" do
|
|
165
|
-
reset_authentication_for github
|
|
166
|
-
expect { github.oauth.update_authorization }.to raise_error(ArgumentError)
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
before do
|
|
170
|
-
stub_patch("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").with(inputs).
|
|
171
|
-
to_return(:body => fixture('auths/authorization.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
it "should update resource successfully" do
|
|
175
|
-
github.oauth.update_authorization authorization_id, inputs
|
|
176
|
-
a_patch("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").with(inputs).should have_been_made
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
it "should return the resource" do
|
|
180
|
-
authorization = github.oauth.update_authorization authorization_id, inputs
|
|
181
|
-
authorization.should be_a Hashie::Mash
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
it "should get the authorization information" do
|
|
185
|
-
authorization = github.oauth.update_authorization authorization_id, inputs
|
|
186
|
-
authorization.token.should == 'abc123'
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
context "failed to update resource" do
|
|
191
|
-
before do
|
|
192
|
-
stub_patch("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").with(inputs).
|
|
193
|
-
to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
194
|
-
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
it "should fail to retrieve resource" do
|
|
198
|
-
expect {
|
|
199
|
-
github.oauth.update_authorization authorization_id, inputs
|
|
200
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
end # update_authorization
|
|
204
|
-
|
|
205
|
-
describe "delete_authorization" do
|
|
206
|
-
let(:authorization_id) { 1 }
|
|
207
|
-
let(:inputs) { { :add_scopes => ['repo'] } }
|
|
208
|
-
|
|
209
|
-
context "resouce deleted" do
|
|
210
|
-
|
|
211
|
-
it "should fail to get resource without basic authentication" do
|
|
212
|
-
reset_authentication_for github
|
|
213
|
-
expect { github.oauth.delete_authorization nil }.to raise_error(ArgumentError)
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
before do
|
|
217
|
-
stub_delete("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").
|
|
218
|
-
to_return(:body => '', :status => 204, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
it "should delete resource successfully" do
|
|
222
|
-
github.oauth.delete_authorization authorization_id
|
|
223
|
-
a_delete("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").should have_been_made
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
context "failed to create resource" do
|
|
228
|
-
before do
|
|
229
|
-
stub_delete("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").
|
|
230
|
-
to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
231
|
-
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
it "should fail to retrieve resource" do
|
|
235
|
-
expect {
|
|
236
|
-
github.oauth.delete_authorization authorization_id
|
|
237
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
238
|
-
end
|
|
239
|
-
end
|
|
240
|
-
end # delete_authorization
|
|
241
|
-
|
|
242
|
-
end # Github::Authorizations
|