github_api 0.4.11 → 0.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +76 -72
- data/features/cassettes/gists/starred.yml +48 -0
- data/features/cassettes/pagination/repos/commits/list.yml +193 -0
- data/features/cassettes/pagination/repos/commits/next.yml +183 -0
- data/features/cassettes/pagination/repos/diff/next.yml +45 -0
- data/features/cassettes/pagination/repos/list.yml +176 -0
- data/features/cassettes/pagination/repos/list/next.yml +222 -0
- data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
- data/features/cassettes/repos/list.yml +92 -0
- data/features/error_codes.feature +1 -1
- data/features/gists.feature +12 -3
- data/features/gists/comments.feature +3 -3
- data/features/github_api.feature +13 -2
- data/features/pagination.feature +40 -39
- data/features/repos.feature +2 -2
- data/features/step_definitions/common_steps.rb +12 -0
- data/features/step_definitions/github_api_steps.rb +12 -1
- data/lib/github_api.rb +1 -1
- data/lib/github_api/api.rb +4 -2
- data/lib/github_api/api_factory.rb +11 -5
- data/lib/github_api/authorizations.rb +23 -32
- data/lib/github_api/client.rb +1 -0
- data/lib/github_api/events.rb +38 -38
- data/lib/github_api/filter.rb +1 -1
- data/lib/github_api/gists.rb +47 -42
- data/lib/github_api/gists/comments.rb +77 -84
- data/lib/github_api/git_data.rb +25 -6
- data/lib/github_api/git_data/blobs.rb +48 -45
- data/lib/github_api/git_data/commits.rb +76 -73
- data/lib/github_api/git_data/references.rb +137 -118
- data/lib/github_api/git_data/tags.rb +74 -70
- data/lib/github_api/git_data/trees.rb +88 -85
- data/lib/github_api/issues.rb +43 -31
- data/lib/github_api/issues/comments.rb +116 -119
- data/lib/github_api/issues/events.rb +20 -19
- data/lib/github_api/issues/labels.rb +200 -197
- data/lib/github_api/issues/milestones.rb +137 -134
- data/lib/github_api/orgs.rb +27 -23
- data/lib/github_api/orgs/members.rb +105 -108
- data/lib/github_api/orgs/teams.rb +236 -237
- data/lib/github_api/paged_request.rb +1 -1
- data/lib/github_api/pull_requests.rb +40 -42
- data/lib/github_api/pull_requests/comments.rb +140 -143
- data/lib/github_api/repos.rb +101 -67
- data/lib/github_api/repos/collaborators.rb +64 -68
- data/lib/github_api/repos/commits.rb +50 -39
- data/lib/github_api/repos/downloads.rb +107 -110
- data/lib/github_api/repos/forks.rb +38 -39
- data/lib/github_api/repos/hooks.rb +161 -167
- data/lib/github_api/repos/keys.rb +86 -86
- data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
- data/lib/github_api/repos/watching.rb +80 -82
- data/lib/github_api/request.rb +5 -9
- data/lib/github_api/users.rb +26 -16
- data/lib/github_api/users/emails.rb +47 -47
- data/lib/github_api/users/followers.rb +85 -86
- data/lib/github_api/users/keys.rb +73 -75
- data/lib/github_api/validations.rb +25 -0
- data/lib/github_api/validations/format.rb +23 -0
- data/lib/github_api/validations/presence.rb +25 -0
- data/lib/github_api/validations/required.rb +21 -0
- data/lib/github_api/validations/token.rb +41 -0
- data/lib/github_api/version.rb +3 -3
- data/spec/fixtures/repos/commit_comparison.json +112 -0
- data/spec/github/api_factory_spec.rb +17 -1
- data/spec/github/authorizations_spec.rb +36 -34
- data/spec/github/gists/comments_spec.rb +39 -45
- data/spec/github/gists_spec.rb +50 -53
- data/spec/github/git_data/blobs_spec.rb +27 -20
- data/spec/github/git_data/commits_spec.rb +20 -19
- data/spec/github/git_data/references_spec.rb +83 -46
- data/spec/github/git_data/tags_spec.rb +16 -15
- data/spec/github/git_data/trees_spec.rb +20 -19
- data/spec/github/git_data_spec.rb +10 -1
- data/spec/github/issues/comments_spec.rb +78 -68
- data/spec/github/issues/events_spec.rb +42 -34
- data/spec/github/issues/labels_spec.rb +89 -101
- data/spec/github/issues/milestones_spec.rb +76 -54
- data/spec/github/issues_spec.rb +53 -57
- data/spec/github/orgs/members_spec.rb +64 -49
- data/spec/github/orgs/teams_spec.rb +112 -101
- data/spec/github/orgs_spec.rb +41 -31
- data/spec/github/paged_request_spec.rb +6 -5
- data/spec/github/pull_requests/comments_spec.rb +39 -44
- data/spec/github/pull_requests_spec.rb +32 -48
- data/spec/github/repos/collaborators_spec.rb +40 -29
- data/spec/github/repos/commits_spec.rb +108 -64
- data/spec/github/repos/downloads_spec.rb +46 -45
- data/spec/github/repos/forks_spec.rb +23 -24
- data/spec/github/repos/hooks_spec.rb +69 -71
- data/spec/github/repos/keys_spec.rb +39 -34
- data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
- data/spec/github/repos/watching_spec.rb +31 -33
- data/spec/github/repos_spec.rb +74 -83
- data/spec/github/request_spec.rb +31 -2
- data/spec/github/users/emails_spec.rb +19 -17
- data/spec/github/users/followers_spec.rb +30 -28
- data/spec/github/users/keys_spec.rb +37 -33
- data/spec/github/users_spec.rb +124 -125
- data/spec/github/validations/format_spec.rb +42 -0
- data/spec/github/validations/presence_spec.rb +18 -0
- data/spec/github/validations/required_spec.rb +28 -0
- data/spec/github/validations/token_spec.rb +19 -0
- data/spec/github/validations_spec.rb +23 -0
- metadata +33 -10
- data/features/cassettes/pagination/repos.yml +0 -177
- data/features/cassettes/pagination/repos/next.yml +0 -177
- data/lib/github_api/validation.rb +0 -53
- data/spec/github/validation_spec.rb +0 -62
data/spec/github/request_spec.rb
CHANGED
@@ -2,6 +2,35 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
+
|
5
6
|
describe Github::Request do
|
6
|
-
|
7
|
-
|
7
|
+
let(:github) { Github::API.new }
|
8
|
+
let(:path) { 'github.api/repos/users' }
|
9
|
+
let(:params) { {} }
|
10
|
+
let(:options) { {} }
|
11
|
+
|
12
|
+
it "knows how to make get request" do
|
13
|
+
github.should_receive(:request).with(:get, path, params, options)
|
14
|
+
github.get_request path, params, options
|
15
|
+
end
|
16
|
+
|
17
|
+
it "knows how to make patch request" do
|
18
|
+
github.should_receive(:request).with(:patch, path, params, options)
|
19
|
+
github.patch_request path, params, options
|
20
|
+
end
|
21
|
+
|
22
|
+
it "knows how to make post request" do
|
23
|
+
github.should_receive(:request).with(:post, path, params, options)
|
24
|
+
github.post_request path, params, options
|
25
|
+
end
|
26
|
+
|
27
|
+
it "knows how to make put request" do
|
28
|
+
github.should_receive(:request).with(:put, path, params, options)
|
29
|
+
github.put_request path, params, options
|
30
|
+
end
|
31
|
+
|
32
|
+
it "knows how to make delete request" do
|
33
|
+
github.should_receive(:request).with(:delete, path, params, options)
|
34
|
+
github.delete_request path, params, options
|
35
|
+
end
|
36
|
+
end # Github::Request
|
@@ -7,7 +7,9 @@ describe Github::Users::Emails do
|
|
7
7
|
before { github.oauth_token = OAUTH_TOKEN }
|
8
8
|
after { reset_authentication_for github }
|
9
9
|
|
10
|
-
describe "#
|
10
|
+
describe "#list" do
|
11
|
+
it { github.users.emails.should respond_to :all }
|
12
|
+
|
11
13
|
context "resource found for an authenticated user" do
|
12
14
|
before do
|
13
15
|
stub_get("/user/emails").
|
@@ -18,26 +20,26 @@ describe Github::Users::Emails do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
it "should get the resources" do
|
21
|
-
github.users.emails
|
23
|
+
github.users.emails.list
|
22
24
|
a_get("/user/emails").
|
23
25
|
with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
24
26
|
should have_been_made
|
25
27
|
end
|
26
28
|
|
27
29
|
it "should return resource" do
|
28
|
-
emails = github.users.emails
|
30
|
+
emails = github.users.emails.list
|
29
31
|
emails.should be_an Array
|
30
32
|
emails.should have(2).items
|
31
33
|
end
|
32
34
|
|
33
35
|
it "should get emails information" do
|
34
|
-
emails = github.users.emails
|
36
|
+
emails = github.users.emails.list
|
35
37
|
emails.first.should == email
|
36
38
|
end
|
37
39
|
|
38
40
|
it "should yield to a block" do
|
39
|
-
github.users.should_receive(:
|
40
|
-
github.users.emails { |param| 'web' }
|
41
|
+
github.users.emails.should_receive(:list).and_yield('web')
|
42
|
+
github.users.emails.list { |param| 'web' }
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -50,13 +52,13 @@ describe Github::Users::Emails do
|
|
50
52
|
|
51
53
|
it "should return 404 with a message 'Not Found'" do
|
52
54
|
expect {
|
53
|
-
github.users.emails
|
55
|
+
github.users.emails.list
|
54
56
|
}.to raise_error(Github::Error::NotFound)
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end # emails
|
58
60
|
|
59
|
-
context '#
|
61
|
+
context '#add' do
|
60
62
|
let(:params) { { :per_page => 21, :page => 1 }}
|
61
63
|
|
62
64
|
before do
|
@@ -68,20 +70,20 @@ describe Github::Users::Emails do
|
|
68
70
|
end
|
69
71
|
|
70
72
|
it 'extracts request parameters and email data' do
|
71
|
-
github.users.should_receive(:
|
73
|
+
github.users.emails.should_receive(:post_request).
|
72
74
|
with("/user/emails", { "per_page" => 21, "page" => 1, "data" => [email] })
|
73
|
-
github.users.
|
75
|
+
github.users.emails.add email, params
|
74
76
|
end
|
75
77
|
|
76
78
|
it 'submits request successfully' do
|
77
|
-
github.users.
|
79
|
+
github.users.emails.add email
|
78
80
|
a_post("/user/emails").
|
79
81
|
with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
80
82
|
should have_been_made
|
81
83
|
end
|
82
|
-
end #
|
84
|
+
end # add
|
83
85
|
|
84
|
-
context '#
|
86
|
+
context '#delete' do
|
85
87
|
let(:params) { { :per_page => 21, :page => 1 }}
|
86
88
|
|
87
89
|
before do
|
@@ -93,17 +95,17 @@ describe Github::Users::Emails do
|
|
93
95
|
end
|
94
96
|
|
95
97
|
it 'extracts request parameters and email data' do
|
96
|
-
github.users.should_receive(:
|
98
|
+
github.users.emails.should_receive(:delete_request).
|
97
99
|
with("/user/emails", { "per_page" => 21, "page" => 1, "data" => [email] })
|
98
|
-
github.users.
|
100
|
+
github.users.emails.delete email, params
|
99
101
|
end
|
100
102
|
|
101
103
|
it 'submits request successfully' do
|
102
|
-
github.users.
|
104
|
+
github.users.emails.delete email
|
103
105
|
a_delete("/user/emails").
|
104
106
|
with(:query => { :access_token => "#{OAUTH_TOKEN}", :data => email } ).
|
105
107
|
should have_been_made
|
106
108
|
end
|
107
|
-
end #
|
109
|
+
end # delete
|
108
110
|
|
109
111
|
end # Github::Users::Emails
|
@@ -8,7 +8,9 @@ describe Github::Users::Followers do
|
|
8
8
|
|
9
9
|
after { reset_authentication_for github }
|
10
10
|
|
11
|
-
describe "#
|
11
|
+
describe "#list" do
|
12
|
+
it { github.users.followers.should respond_to :all }
|
13
|
+
|
12
14
|
context "resource found for a user" do
|
13
15
|
before do
|
14
16
|
stub_get("/users/#{user}/followers").
|
@@ -18,29 +20,29 @@ describe Github::Users::Followers do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
it "should get the resources" do
|
21
|
-
github.users.followers user
|
23
|
+
github.users.followers.list user
|
22
24
|
a_get("/users/#{user}/followers").should have_been_made
|
23
25
|
end
|
24
26
|
|
25
27
|
it "should return resource" do
|
26
|
-
followers = github.users.followers user
|
28
|
+
followers = github.users.followers.list user
|
27
29
|
followers.should be_an Array
|
28
30
|
followers.should have(1).items
|
29
31
|
end
|
30
32
|
|
31
33
|
it "should be a mash type" do
|
32
|
-
followers = github.users.followers user
|
34
|
+
followers = github.users.followers.list user
|
33
35
|
followers.first.should be_a Hashie::Mash
|
34
36
|
end
|
35
37
|
|
36
38
|
it "should get followers information" do
|
37
|
-
followers = github.users.followers user
|
39
|
+
followers = github.users.followers.list user
|
38
40
|
followers.first.login.should == 'octocat'
|
39
41
|
end
|
40
42
|
|
41
43
|
it "should yield to a block" do
|
42
|
-
github.users.should_receive(:
|
43
|
-
github.users.followers(user) { |param| 'web' }
|
44
|
+
github.users.followers.should_receive(:list).with(user).and_yield('web')
|
45
|
+
github.users.followers.list(user) { |param| 'web' }
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
@@ -55,7 +57,7 @@ describe Github::Users::Followers do
|
|
55
57
|
end
|
56
58
|
|
57
59
|
it "should get the resources" do
|
58
|
-
github.users.followers
|
60
|
+
github.users.followers.list
|
59
61
|
a_get("/user/followers").
|
60
62
|
with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
61
63
|
should have_been_made
|
@@ -70,11 +72,11 @@ describe Github::Users::Followers do
|
|
70
72
|
|
71
73
|
it "should return 404 with a message 'Not Found'" do
|
72
74
|
expect {
|
73
|
-
github.users.followers user
|
75
|
+
github.users.followers.list user
|
74
76
|
}.to raise_error(Github::Error::NotFound)
|
75
77
|
end
|
76
78
|
end
|
77
|
-
end #
|
79
|
+
end # list
|
78
80
|
|
79
81
|
describe "#following" do
|
80
82
|
context "resource found for a user" do
|
@@ -86,29 +88,29 @@ describe Github::Users::Followers do
|
|
86
88
|
end
|
87
89
|
|
88
90
|
it "should get the resources" do
|
89
|
-
github.users.following user
|
91
|
+
github.users.followers.following user
|
90
92
|
a_get("/users/#{user}/following").should have_been_made
|
91
93
|
end
|
92
94
|
|
93
95
|
it "should return resource" do
|
94
|
-
followings = github.users.following user
|
96
|
+
followings = github.users.followers.following user
|
95
97
|
followings.should be_an Array
|
96
98
|
followings.should have(1).items
|
97
99
|
end
|
98
100
|
|
99
101
|
it "should be a mash type" do
|
100
|
-
followings = github.users.following user
|
102
|
+
followings = github.users.followers.following user
|
101
103
|
followings.first.should be_a Hashie::Mash
|
102
104
|
end
|
103
105
|
|
104
106
|
it "should get following users information" do
|
105
|
-
followings = github.users.following user
|
107
|
+
followings = github.users.followers.following user
|
106
108
|
followings.first.login.should == 'octocat'
|
107
109
|
end
|
108
110
|
|
109
111
|
it "should yield to a block" do
|
110
|
-
github.users.should_receive(:following).with(user).and_yield('web')
|
111
|
-
github.users.following(user) { |param| 'web' }
|
112
|
+
github.users.followers.should_receive(:following).with(user).and_yield('web')
|
113
|
+
github.users.followers.following(user) { |param| 'web' }
|
112
114
|
end
|
113
115
|
end
|
114
116
|
|
@@ -123,7 +125,7 @@ describe Github::Users::Followers do
|
|
123
125
|
end
|
124
126
|
|
125
127
|
it "should get the resources" do
|
126
|
-
github.users.following
|
128
|
+
github.users.followers.following
|
127
129
|
a_get("/user/following").
|
128
130
|
with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
129
131
|
should have_been_made
|
@@ -138,7 +140,7 @@ describe Github::Users::Followers do
|
|
138
140
|
|
139
141
|
it "should return 404 with a message 'Not Found'" do
|
140
142
|
expect {
|
141
|
-
github.users.following user
|
143
|
+
github.users.followers.following user
|
142
144
|
}.to raise_error(Github::Error::NotFound)
|
143
145
|
end
|
144
146
|
end
|
@@ -156,19 +158,19 @@ describe Github::Users::Followers do
|
|
156
158
|
|
157
159
|
it 'should raise error if username not present' do
|
158
160
|
expect {
|
159
|
-
github.users.following? nil
|
161
|
+
github.users.followers.following? nil
|
160
162
|
}.to raise_error(ArgumentError)
|
161
163
|
end
|
162
164
|
|
163
165
|
it 'should perform request' do
|
164
|
-
github.users.following?(user)
|
166
|
+
github.users.followers.following?(user)
|
165
167
|
a_get("/user/following/#{user}").
|
166
168
|
with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
167
169
|
should have_been_made
|
168
170
|
end
|
169
171
|
|
170
172
|
it 'should return true if user is being followed' do
|
171
|
-
github.users.following?(user).should be_true
|
173
|
+
github.users.followers.following?(user).should be_true
|
172
174
|
end
|
173
175
|
|
174
176
|
it 'should return false if user is not being followed' do
|
@@ -177,7 +179,7 @@ describe Github::Users::Followers do
|
|
177
179
|
to_return(:body => '',
|
178
180
|
:status => 404,
|
179
181
|
:headers => {:content_type => "application/json; charset=utf-8"})
|
180
|
-
github.users.following?(user).should be_false
|
182
|
+
github.users.followers.following?(user).should be_false
|
181
183
|
end
|
182
184
|
end # following?
|
183
185
|
|
@@ -193,19 +195,19 @@ describe Github::Users::Followers do
|
|
193
195
|
|
194
196
|
it "should raise error if gist id not present" do
|
195
197
|
expect {
|
196
|
-
github.users.follow nil
|
198
|
+
github.users.followers.follow nil
|
197
199
|
}.to raise_error(ArgumentError)
|
198
200
|
end
|
199
201
|
|
200
202
|
it 'successfully unfollows a user' do
|
201
|
-
github.users.follow(user)
|
203
|
+
github.users.followers.follow(user)
|
202
204
|
a_put("/user/following/#{user}").
|
203
205
|
with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
204
206
|
should have_been_made
|
205
207
|
end
|
206
208
|
|
207
209
|
it "should return 204 with a message 'Not Found'" do
|
208
|
-
github.users.follow(user).status.should be 204
|
210
|
+
github.users.followers.follow(user).status.should be 204
|
209
211
|
end
|
210
212
|
end # follow
|
211
213
|
|
@@ -221,19 +223,19 @@ describe Github::Users::Followers do
|
|
221
223
|
|
222
224
|
it "should raise error if gist id not present" do
|
223
225
|
expect {
|
224
|
-
github.users.unfollow nil
|
226
|
+
github.users.followers.unfollow nil
|
225
227
|
}.to raise_error(ArgumentError)
|
226
228
|
end
|
227
229
|
|
228
230
|
it 'successfully unfollows a user' do
|
229
|
-
github.users.unfollow(user)
|
231
|
+
github.users.followers.unfollow(user)
|
230
232
|
a_delete("/user/following/#{user}").
|
231
233
|
with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
232
234
|
should have_been_made
|
233
235
|
end
|
234
236
|
|
235
237
|
it "should return 204 with a message 'Not Found'" do
|
236
|
-
github.users.unfollow(user).status.should be 204
|
238
|
+
github.users.followers.unfollow(user).status.should be 204
|
237
239
|
end
|
238
240
|
end # unfollow
|
239
241
|
|
@@ -7,7 +7,9 @@ describe Github::Users::Keys do
|
|
7
7
|
before { github.oauth_token = OAUTH_TOKEN }
|
8
8
|
after { reset_authentication_for github }
|
9
9
|
|
10
|
-
describe "#
|
10
|
+
describe "#list" do
|
11
|
+
it { github.users.keys.should respond_to :all }
|
12
|
+
|
11
13
|
context "resource found for an authenticated user" do
|
12
14
|
before do
|
13
15
|
stub_get("/user/keys").
|
@@ -18,26 +20,26 @@ describe Github::Users::Keys do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
it "should get the resources" do
|
21
|
-
github.users.keys
|
23
|
+
github.users.keys.list
|
22
24
|
a_get("/user/keys").
|
23
25
|
with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
24
26
|
should have_been_made
|
25
27
|
end
|
26
28
|
|
27
29
|
it "should return resource" do
|
28
|
-
keys = github.users.keys
|
30
|
+
keys = github.users.keys.list
|
29
31
|
keys.should be_an Array
|
30
32
|
keys.should have(1).item
|
31
33
|
end
|
32
34
|
|
33
35
|
it "should get keys information" do
|
34
|
-
keys = github.users.keys
|
36
|
+
keys = github.users.keys.list
|
35
37
|
keys.first.id.should == key_id
|
36
38
|
end
|
37
39
|
|
38
40
|
it "should yield to a block" do
|
39
|
-
github.users.should_receive(:
|
40
|
-
github.users.keys { |param| 'web' }
|
41
|
+
github.users.keys.should_receive(:list).and_yield('web')
|
42
|
+
github.users.keys.list { |param| 'web' }
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -50,13 +52,15 @@ describe Github::Users::Keys do
|
|
50
52
|
|
51
53
|
it "should return 404 with a message 'Not Found'" do
|
52
54
|
expect {
|
53
|
-
github.users.keys
|
55
|
+
github.users.keys.list
|
54
56
|
}.to raise_error(Github::Error::NotFound)
|
55
57
|
end
|
56
58
|
end
|
57
|
-
end #
|
59
|
+
end # list
|
60
|
+
|
61
|
+
describe "#get" do
|
62
|
+
it { github.users.keys.should respond_to :find }
|
58
63
|
|
59
|
-
describe "#key" do
|
60
64
|
context "resource found for an authenticated user" do
|
61
65
|
before do
|
62
66
|
stub_get("/user/keys/#{key_id}").
|
@@ -67,24 +71,24 @@ describe Github::Users::Keys do
|
|
67
71
|
end
|
68
72
|
|
69
73
|
it "should fail to get resource without key id" do
|
70
|
-
expect { github.users.
|
74
|
+
expect { github.users.keys.get nil }.to raise_error(ArgumentError)
|
71
75
|
end
|
72
76
|
|
73
77
|
it "should get the resource" do
|
74
|
-
github.users.
|
78
|
+
github.users.keys.get key_id
|
75
79
|
a_get("/user/keys/#{key_id}").
|
76
80
|
with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
77
81
|
should have_been_made
|
78
82
|
end
|
79
83
|
|
80
84
|
it "should get public key information" do
|
81
|
-
key = github.users.
|
85
|
+
key = github.users.keys.get key_id
|
82
86
|
key.id.should == key_id
|
83
87
|
key.title.should == 'octocat@octomac'
|
84
88
|
end
|
85
89
|
|
86
90
|
it "should return mash" do
|
87
|
-
key = github.users.
|
91
|
+
key = github.users.keys.get key_id
|
88
92
|
key.should be_a Hashie::Mash
|
89
93
|
end
|
90
94
|
end
|
@@ -100,13 +104,13 @@ describe Github::Users::Keys do
|
|
100
104
|
|
101
105
|
it "should fail to retrive resource" do
|
102
106
|
expect {
|
103
|
-
github.users.
|
107
|
+
github.users.keys.get key_id
|
104
108
|
}.to raise_error(Github::Error::NotFound)
|
105
109
|
end
|
106
110
|
end
|
107
|
-
end #
|
111
|
+
end # get
|
108
112
|
|
109
|
-
describe "
|
113
|
+
describe "#create" do
|
110
114
|
let(:inputs) {
|
111
115
|
{
|
112
116
|
:title => "octocat@octomac",
|
@@ -125,18 +129,18 @@ describe Github::Users::Keys do
|
|
125
129
|
end
|
126
130
|
|
127
131
|
it "should create resource successfully" do
|
128
|
-
github.users.
|
132
|
+
github.users.keys.create inputs
|
129
133
|
a_post("/user/keys?access_token=#{OAUTH_TOKEN}").
|
130
134
|
with(inputs).should have_been_made
|
131
135
|
end
|
132
136
|
|
133
137
|
it "should return the resource" do
|
134
|
-
key = github.users.
|
138
|
+
key = github.users.keys.create inputs
|
135
139
|
key.should be_a Hashie::Mash
|
136
140
|
end
|
137
141
|
|
138
142
|
it "should get the key information" do
|
139
|
-
key = github.users.
|
143
|
+
key = github.users.keys.create inputs
|
140
144
|
key.title.should == 'octocat@octomac'
|
141
145
|
end
|
142
146
|
end
|
@@ -151,13 +155,13 @@ describe Github::Users::Keys do
|
|
151
155
|
|
152
156
|
it "should fail to retrieve resource" do
|
153
157
|
expect {
|
154
|
-
github.users.
|
158
|
+
github.users.keys.create inputs
|
155
159
|
}.to raise_error(Github::Error::NotFound)
|
156
160
|
end
|
157
161
|
end
|
158
|
-
end #
|
162
|
+
end # create
|
159
163
|
|
160
|
-
describe "#
|
164
|
+
describe "#update" do
|
161
165
|
let(:inputs) {
|
162
166
|
{
|
163
167
|
:title => "octocat@octomac",
|
@@ -176,22 +180,22 @@ describe Github::Users::Keys do
|
|
176
180
|
end
|
177
181
|
|
178
182
|
it "should fail to get resource without key id" do
|
179
|
-
expect { github.users.
|
183
|
+
expect { github.users.keys.update nil }.to raise_error(ArgumentError)
|
180
184
|
end
|
181
185
|
|
182
186
|
it "should create resource successfully" do
|
183
|
-
github.users.
|
187
|
+
github.users.keys.update key_id, inputs
|
184
188
|
a_patch("/user/keys/#{key_id}?access_token=#{OAUTH_TOKEN}").
|
185
189
|
with(inputs).should have_been_made
|
186
190
|
end
|
187
191
|
|
188
192
|
it "should return the resource" do
|
189
|
-
key = github.users.
|
193
|
+
key = github.users.keys.update key_id, inputs
|
190
194
|
key.should be_a Hashie::Mash
|
191
195
|
end
|
192
196
|
|
193
197
|
it "should get the key information" do
|
194
|
-
key = github.users.
|
198
|
+
key = github.users.keys.update key_id, inputs
|
195
199
|
key.title.should == 'octocat@octomac'
|
196
200
|
end
|
197
201
|
end
|
@@ -207,13 +211,13 @@ describe Github::Users::Keys do
|
|
207
211
|
|
208
212
|
it "should fail to retrieve resource" do
|
209
213
|
expect {
|
210
|
-
github.users.
|
214
|
+
github.users.keys.update key_id, inputs
|
211
215
|
}.to raise_error(Github::Error::NotFound)
|
212
216
|
end
|
213
217
|
end
|
214
|
-
end #
|
218
|
+
end # update
|
215
219
|
|
216
|
-
describe "#
|
220
|
+
describe "#delete" do
|
217
221
|
context "resouce deleted" do
|
218
222
|
before do
|
219
223
|
stub_delete("/user/keys/#{key_id}?access_token=#{OAUTH_TOKEN}").
|
@@ -223,11 +227,11 @@ describe Github::Users::Keys do
|
|
223
227
|
end
|
224
228
|
|
225
229
|
it "should fail to get resource without key id" do
|
226
|
-
expect { github.users.
|
230
|
+
expect { github.users.keys.delete nil }.to raise_error(ArgumentError)
|
227
231
|
end
|
228
232
|
|
229
233
|
it "should create resource successfully" do
|
230
|
-
github.users.
|
234
|
+
github.users.keys.delete key_id
|
231
235
|
a_delete("/user/keys/#{key_id}?access_token=#{OAUTH_TOKEN}").
|
232
236
|
should have_been_made
|
233
237
|
end
|
@@ -243,10 +247,10 @@ describe Github::Users::Keys do
|
|
243
247
|
|
244
248
|
it "should fail to delete resource" do
|
245
249
|
expect {
|
246
|
-
github.users.
|
250
|
+
github.users.keys.delete key_id
|
247
251
|
}.to raise_error(Github::Error::NotFound)
|
248
252
|
end
|
249
253
|
end
|
250
|
-
end #
|
254
|
+
end # delete
|
251
255
|
|
252
256
|
end # Github::Users::Keys
|