github_api 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.rdoc +228 -0
- data/Rakefile +52 -0
- data/features/github_api.feature +50 -0
- data/features/options.feature +4 -0
- data/features/pagination.feature +4 -0
- data/features/step_definitions/github_api_steps.rb +11 -0
- data/features/support/env.rb +13 -0
- data/lib/github_api.rb +73 -0
- data/lib/github_api/api.rb +175 -0
- data/lib/github_api/api/utils.rb +9 -0
- data/lib/github_api/authorization.rb +73 -0
- data/lib/github_api/authorizations.rb +119 -0
- data/lib/github_api/cache_control.rb +19 -0
- data/lib/github_api/client.rb +55 -0
- data/lib/github_api/compatibility.rb +23 -0
- data/lib/github_api/configuration.rb +96 -0
- data/lib/github_api/connection.rb +75 -0
- data/lib/github_api/core_ext/array.rb +14 -0
- data/lib/github_api/core_ext/hash.rb +42 -0
- data/lib/github_api/error.rb +35 -0
- data/lib/github_api/events.rb +202 -0
- data/lib/github_api/gists.rb +200 -0
- data/lib/github_api/gists/comments.rb +86 -0
- data/lib/github_api/git_data.rb +26 -0
- data/lib/github_api/git_data/blobs.rb +51 -0
- data/lib/github_api/git_data/commits.rb +78 -0
- data/lib/github_api/git_data/references.rb +113 -0
- data/lib/github_api/git_data/tags.rb +78 -0
- data/lib/github_api/git_data/trees.rb +89 -0
- data/lib/github_api/issues.rb +215 -0
- data/lib/github_api/issues/comments.rb +123 -0
- data/lib/github_api/issues/events.rb +54 -0
- data/lib/github_api/issues/labels.rb +191 -0
- data/lib/github_api/issues/milestones.rb +140 -0
- data/lib/github_api/mime_type.rb +55 -0
- data/lib/github_api/orgs.rb +95 -0
- data/lib/github_api/orgs/members.rb +120 -0
- data/lib/github_api/orgs/teams.rb +245 -0
- data/lib/github_api/pull_requests.rb +224 -0
- data/lib/github_api/pull_requests/comments.rb +144 -0
- data/lib/github_api/repos.rb +286 -0
- data/lib/github_api/repos/collaborators.rb +81 -0
- data/lib/github_api/repos/commits.rb +180 -0
- data/lib/github_api/repos/downloads.rb +155 -0
- data/lib/github_api/repos/forks.rb +48 -0
- data/lib/github_api/repos/hooks.rb +174 -0
- data/lib/github_api/repos/keys.rb +104 -0
- data/lib/github_api/repos/pub_sub_hubbub.rb +102 -0
- data/lib/github_api/repos/watching.rb +94 -0
- data/lib/github_api/request.rb +84 -0
- data/lib/github_api/request/basic_auth.rb +31 -0
- data/lib/github_api/request/caching.rb +33 -0
- data/lib/github_api/request/oauth2.rb +33 -0
- data/lib/github_api/response.rb +28 -0
- data/lib/github_api/response/helpers.rb +14 -0
- data/lib/github_api/response/jsonize.rb +26 -0
- data/lib/github_api/response/mashify.rb +24 -0
- data/lib/github_api/response/raise_error.rb +33 -0
- data/lib/github_api/result.rb +42 -0
- data/lib/github_api/users.rb +84 -0
- data/lib/github_api/users/emails.rb +49 -0
- data/lib/github_api/users/followers.rb +98 -0
- data/lib/github_api/users/keys.rb +84 -0
- data/lib/github_api/version.rb +12 -0
- data/spec/README.rdoc +22 -0
- data/spec/coverage_adapter.rb +15 -0
- data/spec/fixtures/auths/authorization.json +14 -0
- data/spec/fixtures/auths/authorizations.json +16 -0
- data/spec/fixtures/events/events.json +29 -0
- data/spec/fixtures/issues/comment.json +13 -0
- data/spec/fixtures/issues/comments.json +15 -0
- data/spec/fixtures/issues/event.json +13 -0
- data/spec/fixtures/issues/events.json +15 -0
- data/spec/fixtures/issues/issue.json +56 -0
- data/spec/fixtures/issues/issues.json +58 -0
- data/spec/fixtures/issues/milestone.json +18 -0
- data/spec/fixtures/issues/milestones.json +20 -0
- data/spec/fixtures/orgs/members.json +9 -0
- data/spec/fixtures/orgs/org.json +18 -0
- data/spec/fixtures/orgs/orgs.json +8 -0
- data/spec/fixtures/orgs/team.json +8 -0
- data/spec/fixtures/orgs/team_repos.json +29 -0
- data/spec/fixtures/orgs/teams.json +7 -0
- data/spec/fixtures/repos/branches.json +9 -0
- data/spec/fixtures/repos/collaborators.json +8 -0
- data/spec/fixtures/repos/commit.json +53 -0
- data/spec/fixtures/repos/commit_comment.json +16 -0
- data/spec/fixtures/repos/commit_comments.json +18 -0
- data/spec/fixtures/repos/commits.json +27 -0
- data/spec/fixtures/repos/contributors.json +8 -0
- data/spec/fixtures/repos/download.json +10 -0
- data/spec/fixtures/repos/download_s3.json +21 -0
- data/spec/fixtures/repos/downloads.json +12 -0
- data/spec/fixtures/repos/fork.json +27 -0
- data/spec/fixtures/repos/forks.json +29 -0
- data/spec/fixtures/repos/hook.json +15 -0
- data/spec/fixtures/repos/hooks.json +10 -0
- data/spec/fixtures/repos/key.json +6 -0
- data/spec/fixtures/repos/keys.json +8 -0
- data/spec/fixtures/repos/languages.json +4 -0
- data/spec/fixtures/repos/repo.json +90 -0
- data/spec/fixtures/repos/repo_comments.json +18 -0
- data/spec/fixtures/repos/repos.json +29 -0
- data/spec/fixtures/repos/tags.json +11 -0
- data/spec/fixtures/repos/teams.json +7 -0
- data/spec/fixtures/repos/watched.json +29 -0
- data/spec/fixtures/repos/watchers.json +8 -0
- data/spec/fixtures/users/user.json +32 -0
- data/spec/github/api_spec.rb +25 -0
- data/spec/github/authorization_spec.rb +176 -0
- data/spec/github/authorizations_spec.rb +242 -0
- data/spec/github/client_spec.rb +50 -0
- data/spec/github/core_ext/hash_spec.rb +44 -0
- data/spec/github/events_spec.rb +491 -0
- data/spec/github/gists/comments_spec.rb +5 -0
- data/spec/github/gists_spec.rb +5 -0
- data/spec/github/git_data/blobs_spec.rb +5 -0
- data/spec/github/git_data/commits_spec.rb +5 -0
- data/spec/github/git_data/references_spec.rb +5 -0
- data/spec/github/git_data/tags_spec.rb +5 -0
- data/spec/github/git_data/trees_spec.rb +5 -0
- data/spec/github/git_data_spec.rb +5 -0
- data/spec/github/issues/comments_spec.rb +254 -0
- data/spec/github/issues/events_spec.rb +153 -0
- data/spec/github/issues/labels_spec.rb +5 -0
- data/spec/github/issues/milestones_spec.rb +260 -0
- data/spec/github/issues_spec.rb +287 -0
- data/spec/github/mime_type_spec.rb +70 -0
- data/spec/github/orgs/members_spec.rb +275 -0
- data/spec/github/orgs/teams_spec.rb +563 -0
- data/spec/github/orgs_spec.rb +160 -0
- data/spec/github/repos/collaborators_spec.rb +169 -0
- data/spec/github/repos/commits_spec.rb +424 -0
- data/spec/github/repos/downloads_spec.rb +247 -0
- data/spec/github/repos/forks_spec.rb +108 -0
- data/spec/github/repos/hooks_spec.rb +333 -0
- data/spec/github/repos/keys_spec.rb +217 -0
- data/spec/github/repos/pub_sub_hubbub_spec.rb +83 -0
- data/spec/github/repos/watching_spec.rb +222 -0
- data/spec/github/repos_spec.rb +571 -0
- data/spec/github/result_spec.rb +43 -0
- data/spec/github/users_spec.rb +140 -0
- data/spec/github_spec.rb +109 -0
- data/spec/spec_helper.rb +86 -0
- data/spec/support/base.rb +13 -0
- metadata +149 -4
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Github::Client do
|
4
|
+
|
5
|
+
let(:github) { Github.new }
|
6
|
+
|
7
|
+
it "should return Github::Gists instance" do
|
8
|
+
github.gists.should be_a Github::Gists
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return Github::GitData instance" do
|
12
|
+
github.git_data.should be_a Github::GitData
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return Github::Issues instance" do
|
16
|
+
github.issues.should be_a Github::Issues
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return Github::Orgs instance" do
|
20
|
+
github.orgs.should be_a Github::Orgs
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return Github::PullRequests instance" do
|
24
|
+
github.pull_requests.should be_a Github::PullRequests
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return Github::Repos instance" do
|
28
|
+
github.repos.should be_a Github::Repos
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return Github::Users instance" do
|
32
|
+
github.users.should be_a Github::Users
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should respond to repos" do
|
36
|
+
github.should respond_to :repos
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should respond to repositories" do
|
40
|
+
github.should respond_to :repositories
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should respond to git_data" do
|
44
|
+
github.should respond_to :git_data
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should respond to git" do
|
48
|
+
github.should respond_to :git
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hash do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Github.new
|
7
|
+
@hash = { :a => 1, :b => 2, :c => 'e'}
|
8
|
+
@serialized = "a=1&b=2&c=e"
|
9
|
+
@nested_hash = { 'a' => { 'b' => {'c' => 1 } } }
|
10
|
+
@symbols = { :a => { :b => { :c => 1 } } }
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should respond to except" do
|
14
|
+
@nested_hash.should respond_to :except
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should respond to except!" do
|
18
|
+
@nested_hash.should respond_to :except!
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should respond to symbolize_keys!" do
|
22
|
+
@nested_hash.should respond_to :symbolize_keys!
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should respond to symbolize_keys" do
|
26
|
+
@nested_hash.should respond_to :symbolize_keys
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should respond to serialize" do
|
30
|
+
@nested_hash.should respond_to :serialize
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should remove key from the hash" do
|
34
|
+
@nested_hash.except('a').should be_empty
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should convert nested keys to symbols" do
|
38
|
+
@nested_hash.symbolize_keys!.should == @symbols
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should serialize hash" do
|
42
|
+
@hash.serialize.should == @serialized
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,491 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Github::Events do
|
4
|
+
|
5
|
+
let(:github) { Github.new }
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
|
9
|
+
describe "public" do
|
10
|
+
context "resource found" do
|
11
|
+
before do
|
12
|
+
stub_get("/events").
|
13
|
+
to_return(:body => fixture('events/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should get the resources" do
|
17
|
+
github.events.public
|
18
|
+
a_get("/events").should have_been_made
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return array of resources" do
|
22
|
+
events = github.events.public
|
23
|
+
events.should be_an Array
|
24
|
+
events.should have(1).items
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should be a mash type" do
|
28
|
+
events = github.events.public
|
29
|
+
events.first.should be_a Hashie::Mash
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should get event information" do
|
33
|
+
events = github.events.public
|
34
|
+
events.first.type.should == 'Event'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should yield to a block" do
|
38
|
+
github.events.should_receive(:public).and_yield('web')
|
39
|
+
github.events.public { |param| 'web' }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "resource not found" do
|
44
|
+
before do
|
45
|
+
stub_get("/events").to_return(:body => "", :status => [404, "Not Found"])
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return 404 with a message 'Not Found'" do
|
49
|
+
expect {
|
50
|
+
github.events.public
|
51
|
+
}.to raise_error(Github::ResourceNotFound)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end # public_events
|
55
|
+
|
56
|
+
describe "repository" do
|
57
|
+
context "resource found" do
|
58
|
+
before do
|
59
|
+
stub_get("/repos/#{user}/#{repo}/events").
|
60
|
+
to_return(:body => fixture('events/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should fail to get resource without username" do
|
64
|
+
github.user, github.repo = nil, nil
|
65
|
+
expect { github.events.repository nil, repo }.to raise_error(ArgumentError)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should get the resources" do
|
69
|
+
github.events.repository user, repo
|
70
|
+
a_get("/repos/#{user}/#{repo}/events").should have_been_made
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should return array of resources" do
|
74
|
+
events = github.events.repository user, repo
|
75
|
+
events.should be_an Array
|
76
|
+
events.should have(1).items
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should be a mash type" do
|
80
|
+
events = github.events.repository user, repo
|
81
|
+
events.first.should be_a Hashie::Mash
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should get event information" do
|
85
|
+
events = github.events.repository user, repo
|
86
|
+
events.first.type.should == 'Event'
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should yield to a block" do
|
90
|
+
github.events.should_receive(:repository).with(user, repo).and_yield('web')
|
91
|
+
github.events.repository(user, repo) { |param| 'web' }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "resource not found" do
|
96
|
+
before do
|
97
|
+
stub_get("/repos/#{user}/#{repo}/events").
|
98
|
+
to_return(:body => "", :status => [404, "Not Found"])
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should return 404 with a message 'Not Found'" do
|
102
|
+
expect {
|
103
|
+
github.events.repository user, repo
|
104
|
+
}.to raise_error(Github::ResourceNotFound)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end # repository
|
108
|
+
|
109
|
+
describe "issue" do
|
110
|
+
context "resource found" do
|
111
|
+
before do
|
112
|
+
stub_get("/repos/#{user}/#{repo}/issues/events").
|
113
|
+
to_return(:body => fixture('events/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should fail to get resource without username" do
|
117
|
+
github.user, github.repo = nil, nil
|
118
|
+
expect { github.events.issue nil, repo }.to raise_error(ArgumentError)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should get the resources" do
|
122
|
+
github.events.issue user, repo
|
123
|
+
a_get("/repos/#{user}/#{repo}/issues/events").should have_been_made
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should return array of resources" do
|
127
|
+
events = github.events.issue user, repo
|
128
|
+
events.should be_an Array
|
129
|
+
events.should have(1).items
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should be a mash type" do
|
133
|
+
events = github.events.issue user, repo
|
134
|
+
events.first.should be_a Hashie::Mash
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should get event information" do
|
138
|
+
events = github.events.issue user, repo
|
139
|
+
events.first.type.should == 'Event'
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should yield to a block" do
|
143
|
+
github.events.should_receive(:issue).with(user, repo).and_yield('web')
|
144
|
+
github.events.issue(user, repo) { |param| 'web' }
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context "resource not found" do
|
149
|
+
before do
|
150
|
+
stub_get("/repos/#{user}/#{repo}/issues/events").
|
151
|
+
to_return(:body => "", :status => [404, "Not Found"])
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should return 404 with a message 'Not Found'" do
|
155
|
+
expect {
|
156
|
+
github.events.issue user, repo
|
157
|
+
}.to raise_error(Github::ResourceNotFound)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end # repository
|
161
|
+
|
162
|
+
describe "network" do
|
163
|
+
context "resource found" do
|
164
|
+
before do
|
165
|
+
stub_get("/networks/#{user}/#{repo}/events").
|
166
|
+
to_return(:body => fixture('events/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should fail to get resource without username" do
|
170
|
+
github.user, github.repo = nil, nil
|
171
|
+
expect { github.events.network nil, repo }.to raise_error(ArgumentError)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should get the resources" do
|
175
|
+
github.events.network user, repo
|
176
|
+
a_get("/networks/#{user}/#{repo}/events").should have_been_made
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should return array of resources" do
|
180
|
+
events = github.events.network user, repo
|
181
|
+
events.should be_an Array
|
182
|
+
events.should have(1).items
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should be a mash type" do
|
186
|
+
events = github.events.network user, repo
|
187
|
+
events.first.should be_a Hashie::Mash
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should get event information" do
|
191
|
+
events = github.events.network user, repo
|
192
|
+
events.first.type.should == 'Event'
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should yield to a block" do
|
196
|
+
github.events.should_receive(:network).with(user, repo).and_yield('web')
|
197
|
+
github.events.network(user, repo) { |param| 'web' }
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
context "resource not found" do
|
202
|
+
before do
|
203
|
+
stub_get("/networks/#{user}/#{repo}/events").
|
204
|
+
to_return(:body => "", :status => [404, "Not Found"])
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should return 404 with a message 'Not Found'" do
|
208
|
+
expect {
|
209
|
+
github.events.network user, repo
|
210
|
+
}.to raise_error(Github::ResourceNotFound)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end # network
|
214
|
+
|
215
|
+
describe "org" do
|
216
|
+
let(:org) { 'github' }
|
217
|
+
context "resource found" do
|
218
|
+
before do
|
219
|
+
stub_get("/orgs/#{org}/events").
|
220
|
+
to_return(:body => fixture('events/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should fail to get resource without orgname" do
|
224
|
+
expect { github.events.org nil }.to raise_error(ArgumentError)
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should get the resources" do
|
228
|
+
github.events.org org
|
229
|
+
a_get("/orgs/#{org}/events").should have_been_made
|
230
|
+
end
|
231
|
+
|
232
|
+
it "should return array of resources" do
|
233
|
+
events = github.events.org org
|
234
|
+
events.should be_an Array
|
235
|
+
events.should have(1).items
|
236
|
+
end
|
237
|
+
|
238
|
+
it "should be a mash type" do
|
239
|
+
events = github.events.org org
|
240
|
+
events.first.should be_a Hashie::Mash
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should get event information" do
|
244
|
+
events = github.events.org org
|
245
|
+
events.first.type.should == 'Event'
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should yield to a block" do
|
249
|
+
github.events.should_receive(:org).with(org).and_yield('web')
|
250
|
+
github.events.org(org) { |param| 'web' }
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
context "resource not found" do
|
255
|
+
before do
|
256
|
+
stub_get("/orgs/#{org}/events").
|
257
|
+
to_return(:body => "", :status => [404, "Not Found"])
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should return 404 with a message 'Not Found'" do
|
261
|
+
expect {
|
262
|
+
github.events.org org
|
263
|
+
}.to raise_error(Github::ResourceNotFound)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end # org
|
267
|
+
|
268
|
+
describe "received" do
|
269
|
+
context "resource found" do
|
270
|
+
before do
|
271
|
+
stub_get("/users/#{user}/received_events").
|
272
|
+
to_return(:body => fixture('events/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
273
|
+
end
|
274
|
+
|
275
|
+
it "should fail to get resource without username" do
|
276
|
+
expect { github.events.received nil }.to raise_error(ArgumentError)
|
277
|
+
end
|
278
|
+
|
279
|
+
it "should get the resources" do
|
280
|
+
github.events.received user
|
281
|
+
a_get("/users/#{user}/received_events").should have_been_made
|
282
|
+
end
|
283
|
+
|
284
|
+
it "should return array of resources" do
|
285
|
+
events = github.events.received user
|
286
|
+
events.should be_an Array
|
287
|
+
events.should have(1).items
|
288
|
+
end
|
289
|
+
|
290
|
+
it "should be a mash type" do
|
291
|
+
events = github.events.received user
|
292
|
+
events.first.should be_a Hashie::Mash
|
293
|
+
end
|
294
|
+
|
295
|
+
it "should get event information" do
|
296
|
+
events = github.events.received user
|
297
|
+
events.first.type.should == 'Event'
|
298
|
+
end
|
299
|
+
|
300
|
+
it "should yield to a block" do
|
301
|
+
github.events.should_receive(:received).with(user).and_yield('web')
|
302
|
+
github.events.received(user) { |param| 'web' }
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
context "all public resources found" do
|
307
|
+
before do
|
308
|
+
stub_get("/users/#{user}/received_events/public").
|
309
|
+
to_return(:body => fixture('events/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
310
|
+
end
|
311
|
+
|
312
|
+
it "should get the resources" do
|
313
|
+
github.events.received user, :public => true
|
314
|
+
a_get("/users/#{user}/received_events/public").should have_been_made
|
315
|
+
end
|
316
|
+
|
317
|
+
it "should return array of resources" do
|
318
|
+
events = github.events.received user, :public => true
|
319
|
+
events.should be_an Array
|
320
|
+
events.should have(1).items
|
321
|
+
end
|
322
|
+
|
323
|
+
it "should be a mash type" do
|
324
|
+
events = github.events.received user, :public => true
|
325
|
+
events.first.should be_a Hashie::Mash
|
326
|
+
end
|
327
|
+
|
328
|
+
it "should get event information" do
|
329
|
+
events = github.events.received user, :public => true
|
330
|
+
events.first.type.should == 'Event'
|
331
|
+
end
|
332
|
+
|
333
|
+
it "should yield to a block" do
|
334
|
+
github.events.should_receive(:received).with(user).and_yield('web')
|
335
|
+
github.events.received(user) { |param| 'web' }
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
context "resource not found" do
|
340
|
+
before do
|
341
|
+
stub_get("/users/#{user}/received_events").
|
342
|
+
to_return(:body => "", :status => [404, "Not Found"])
|
343
|
+
end
|
344
|
+
|
345
|
+
it "should return 404 with a message 'Not Found'" do
|
346
|
+
expect {
|
347
|
+
github.events.received user
|
348
|
+
}.to raise_error(Github::ResourceNotFound)
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end # received
|
352
|
+
|
353
|
+
describe "performed" do
|
354
|
+
context "resource found" do
|
355
|
+
before do
|
356
|
+
stub_get("/users/#{user}/events").
|
357
|
+
to_return(:body => fixture('events/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
358
|
+
end
|
359
|
+
|
360
|
+
it "should fail to get resource without username" do
|
361
|
+
expect { github.events.performed nil }.to raise_error(ArgumentError)
|
362
|
+
end
|
363
|
+
|
364
|
+
it "should get the resources" do
|
365
|
+
github.events.performed user
|
366
|
+
a_get("/users/#{user}/events").should have_been_made
|
367
|
+
end
|
368
|
+
|
369
|
+
it "should return array of resources" do
|
370
|
+
events = github.events.performed user
|
371
|
+
events.should be_an Array
|
372
|
+
events.should have(1).items
|
373
|
+
end
|
374
|
+
|
375
|
+
it "should be a mash type" do
|
376
|
+
events = github.events.performed user
|
377
|
+
events.first.should be_a Hashie::Mash
|
378
|
+
end
|
379
|
+
|
380
|
+
it "should get event information" do
|
381
|
+
events = github.events.performed user
|
382
|
+
events.first.type.should == 'Event'
|
383
|
+
end
|
384
|
+
|
385
|
+
it "should yield to a block" do
|
386
|
+
github.events.should_receive(:performed).with(user).and_yield('web')
|
387
|
+
github.events.performed(user) { |param| 'web' }
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
context "all public resources found" do
|
392
|
+
before do
|
393
|
+
stub_get("/users/#{user}/events/public").
|
394
|
+
to_return(:body => fixture('events/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
395
|
+
end
|
396
|
+
|
397
|
+
it "should get the resources" do
|
398
|
+
github.events.performed user, :public => true
|
399
|
+
a_get("/users/#{user}/events/public").should have_been_made
|
400
|
+
end
|
401
|
+
|
402
|
+
it "should return array of resources" do
|
403
|
+
events = github.events.performed user, :public => true
|
404
|
+
events.should be_an Array
|
405
|
+
events.should have(1).items
|
406
|
+
end
|
407
|
+
|
408
|
+
it "should be a mash type" do
|
409
|
+
events = github.events.performed user, :public => true
|
410
|
+
events.first.should be_a Hashie::Mash
|
411
|
+
end
|
412
|
+
|
413
|
+
it "should get event information" do
|
414
|
+
events = github.events.performed user, :public => true
|
415
|
+
events.first.type.should == 'Event'
|
416
|
+
end
|
417
|
+
|
418
|
+
it "should yield to a block" do
|
419
|
+
github.events.should_receive(:performed).with(user).and_yield('web')
|
420
|
+
github.events.performed(user) { |param| 'web' }
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
context "resource not found" do
|
425
|
+
before do
|
426
|
+
stub_get("/users/#{user}/events").
|
427
|
+
to_return(:body => "", :status => [404, "Not Found"])
|
428
|
+
end
|
429
|
+
|
430
|
+
it "should return 404 with a message 'Not Found'" do
|
431
|
+
expect {
|
432
|
+
github.events.performed user
|
433
|
+
}.to raise_error(Github::ResourceNotFound)
|
434
|
+
end
|
435
|
+
end
|
436
|
+
end # performed
|
437
|
+
|
438
|
+
describe "user_org" do
|
439
|
+
let(:org) { 'github' }
|
440
|
+
context "resource found" do
|
441
|
+
before do
|
442
|
+
stub_get("/users/#{user}/events/orgs/#{org}").
|
443
|
+
to_return(:body => fixture('events/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
444
|
+
end
|
445
|
+
|
446
|
+
it "should fail to get resource without orgname" do
|
447
|
+
expect { github.events.user_org user, nil }.to raise_error(ArgumentError)
|
448
|
+
end
|
449
|
+
|
450
|
+
it "should get the resources" do
|
451
|
+
github.events.user_org user, org
|
452
|
+
a_get("/users/#{user}/events/orgs/#{org}").should have_been_made
|
453
|
+
end
|
454
|
+
|
455
|
+
it "should return array of resources" do
|
456
|
+
events = github.events.user_org user, org
|
457
|
+
events.should be_an Array
|
458
|
+
events.should have(1).items
|
459
|
+
end
|
460
|
+
|
461
|
+
it "should be a mash type" do
|
462
|
+
events = github.events.user_org user, org
|
463
|
+
events.first.should be_a Hashie::Mash
|
464
|
+
end
|
465
|
+
|
466
|
+
it "should get event information" do
|
467
|
+
events = github.events.user_org user, org
|
468
|
+
events.first.type.should == 'Event'
|
469
|
+
end
|
470
|
+
|
471
|
+
it "should yield to a block" do
|
472
|
+
github.events.should_receive(:user_org).with(user, org).and_yield('web')
|
473
|
+
github.events.user_org(user, org) { |param| 'web' }
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
context "resource not found" do
|
478
|
+
before do
|
479
|
+
stub_get("/users/#{user}/events/orgs/#{org}").
|
480
|
+
to_return(:body => "", :status => [404, "Not Found"])
|
481
|
+
end
|
482
|
+
|
483
|
+
it "should return 404 with a message 'Not Found'" do
|
484
|
+
expect {
|
485
|
+
github.events.user_org user, org
|
486
|
+
}.to raise_error(Github::ResourceNotFound)
|
487
|
+
end
|
488
|
+
end
|
489
|
+
end # user_org
|
490
|
+
|
491
|
+
end # Github::Events
|