github_api 0.4.11 → 0.5.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +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
|
@@ -13,45 +13,45 @@ describe Github::Repos::Downloads do
|
|
|
13
13
|
it { described_class::VALID_DOWNLOAD_PARAM_NAMES.should_not be_nil }
|
|
14
14
|
it { described_class::REQUIRED_PARAMS.should_not be_nil }
|
|
15
15
|
|
|
16
|
-
describe "
|
|
17
|
-
it { github.repos.should respond_to :
|
|
18
|
-
it { github.repos.should respond_to :list_downloads }
|
|
19
|
-
it { github.repos.should respond_to :get_downloads }
|
|
16
|
+
describe "#list" do
|
|
17
|
+
it { github.repos.downloads.should respond_to :list }
|
|
20
18
|
|
|
21
19
|
context "resource found" do
|
|
22
20
|
before do
|
|
23
21
|
stub_get("/repos/#{user}/#{repo}/downloads").
|
|
24
|
-
to_return(:body => fixture('repos/downloads.json'), :status => 200,
|
|
22
|
+
to_return(:body => fixture('repos/downloads.json'), :status => 200,
|
|
23
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
25
24
|
end
|
|
26
25
|
|
|
27
26
|
it "should fail to get resource without username" do
|
|
28
|
-
expect { github.repos.downloads }.to raise_error(ArgumentError)
|
|
27
|
+
expect { github.repos.downloads.list }.to raise_error(ArgumentError)
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
it "should get the resources" do
|
|
32
|
-
github.repos.downloads user, repo
|
|
31
|
+
github.repos.downloads.list user, repo
|
|
33
32
|
a_get("/repos/#{user}/#{repo}/downloads").should have_been_made
|
|
34
33
|
end
|
|
35
34
|
|
|
36
35
|
it "should return array of resources" do
|
|
37
|
-
downloads = github.repos.downloads user, repo
|
|
36
|
+
downloads = github.repos.downloads.list user, repo
|
|
38
37
|
downloads.should be_an Array
|
|
39
38
|
downloads.should have(1).items
|
|
40
39
|
end
|
|
41
40
|
|
|
42
41
|
it "should be a mash type" do
|
|
43
|
-
downloads = github.repos.downloads user, repo
|
|
42
|
+
downloads = github.repos.downloads.list user, repo
|
|
44
43
|
downloads.first.should be_a Hashie::Mash
|
|
45
44
|
end
|
|
46
45
|
|
|
47
46
|
it "should get download information" do
|
|
48
|
-
downloads = github.repos.downloads user, repo
|
|
47
|
+
downloads = github.repos.downloads.list user, repo
|
|
49
48
|
downloads.first.name.should == 'new_file.jpg'
|
|
50
49
|
end
|
|
51
50
|
|
|
52
51
|
it "should yield to a block" do
|
|
53
|
-
github.repos.should_receive(:
|
|
54
|
-
|
|
52
|
+
github.repos.downloads.should_receive(:list).
|
|
53
|
+
with(user, repo).and_yield('web')
|
|
54
|
+
github.repos.downloads.list(user, repo) { |param| 'web' }
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
@@ -63,43 +63,43 @@ describe Github::Repos::Downloads do
|
|
|
63
63
|
|
|
64
64
|
it "should return 404 with a message 'Not Found'" do
|
|
65
65
|
expect {
|
|
66
|
-
github.repos.downloads user, repo
|
|
66
|
+
github.repos.downloads.list user, repo
|
|
67
67
|
}.to raise_error(Github::Error::NotFound)
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
|
-
end #
|
|
70
|
+
end # list
|
|
71
71
|
|
|
72
|
-
describe "
|
|
72
|
+
describe "#get" do
|
|
73
73
|
let(:download_id) { 1 }
|
|
74
74
|
|
|
75
|
-
it { github.repos.should respond_to :
|
|
76
|
-
it { github.repos.should respond_to :get_download }
|
|
75
|
+
it { github.repos.downloads.should respond_to :find }
|
|
77
76
|
|
|
78
77
|
context "resource found" do
|
|
79
78
|
before do
|
|
80
79
|
stub_get("/repos/#{user}/#{repo}/downloads/#{download_id}").
|
|
81
|
-
to_return(:body => fixture('repos/download.json'), :status => 200,
|
|
80
|
+
to_return(:body => fixture('repos/download.json'), :status => 200,
|
|
81
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
it "should fail to get resource without download id" do
|
|
85
85
|
expect {
|
|
86
|
-
github.repos.
|
|
86
|
+
github.repos.downloads.get user, repo, nil
|
|
87
87
|
}.to raise_error(ArgumentError)
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
it "should get the resource" do
|
|
91
|
-
github.repos.
|
|
91
|
+
github.repos.downloads.get user, repo, download_id
|
|
92
92
|
a_get("/repos/#{user}/#{repo}/downloads/#{download_id}").should have_been_made
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
it "should get download information" do
|
|
96
|
-
download = github.repos.
|
|
96
|
+
download = github.repos.downloads.get user, repo, download_id
|
|
97
97
|
download.id.should == download_id
|
|
98
98
|
download.name.should == 'new_file.jpg'
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
it "should return mash" do
|
|
102
|
-
download = github.repos.
|
|
102
|
+
download = github.repos.downloads.get user, repo, download_id
|
|
103
103
|
download.should be_a Hashie::Mash
|
|
104
104
|
end
|
|
105
105
|
end
|
|
@@ -112,34 +112,34 @@ describe Github::Repos::Downloads do
|
|
|
112
112
|
|
|
113
113
|
it "should fail to retrive resource" do
|
|
114
114
|
expect {
|
|
115
|
-
github.repos.
|
|
115
|
+
github.repos.downloads.get user, repo, download_id
|
|
116
116
|
}.to raise_error(Github::Error::NotFound)
|
|
117
117
|
end
|
|
118
118
|
end
|
|
119
|
-
end #
|
|
119
|
+
end # get
|
|
120
120
|
|
|
121
|
-
describe "
|
|
121
|
+
describe "#delete" do
|
|
122
122
|
let(:download_id) { 1 }
|
|
123
123
|
|
|
124
124
|
context "resource edited successfully" do
|
|
125
125
|
before do
|
|
126
126
|
stub_delete("/repos/#{user}/#{repo}/downloads/#{download_id}").
|
|
127
|
-
to_return(:body => '', :status => 204,
|
|
127
|
+
to_return(:body => '', :status => 204,
|
|
128
|
+
:headers => { :content_type => "application/json; charset=utf-8"})
|
|
128
129
|
end
|
|
129
130
|
|
|
130
131
|
it "should fail to delete without 'user/repo' parameters" do
|
|
131
|
-
github.
|
|
132
|
-
expect { github.repos.delete_download }.to raise_error(ArgumentError)
|
|
132
|
+
expect { github.repos.downloads.delete }.to raise_error(ArgumentError)
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
it "should fail to delete resource without 'download_id'" do
|
|
136
136
|
expect {
|
|
137
|
-
github.repos.
|
|
137
|
+
github.repos.downloads.delete user, repo
|
|
138
138
|
}.to raise_error(ArgumentError)
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
it "should delete the resource" do
|
|
142
|
-
github.repos.
|
|
142
|
+
github.repos.downloads.delete user, repo, download_id
|
|
143
143
|
a_delete("/repos/#{user}/#{repo}/downloads/#{download_id}").should have_been_made
|
|
144
144
|
end
|
|
145
145
|
end
|
|
@@ -147,19 +147,19 @@ describe Github::Repos::Downloads do
|
|
|
147
147
|
context "failed to edit resource" do
|
|
148
148
|
before do
|
|
149
149
|
stub_delete("/repos/#{user}/#{repo}/downloads/#{download_id}").
|
|
150
|
-
to_return(:body => fixture("repos/download.json"), :status => 404,
|
|
151
|
-
|
|
150
|
+
to_return(:body => fixture("repos/download.json"), :status => 404,
|
|
151
|
+
:headers => { :content_type => "application/json; charset=utf-8"})
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
it "should fail to find resource" do
|
|
155
155
|
expect {
|
|
156
|
-
github.repos.
|
|
156
|
+
github.repos.downloads.delete user, repo, download_id
|
|
157
157
|
}.to raise_error(Github::Error::NotFound)
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
|
-
end #
|
|
160
|
+
end # delete
|
|
161
161
|
|
|
162
|
-
describe "
|
|
162
|
+
describe "#create" do
|
|
163
163
|
let(:inputs) { {:name => 'new_file.jpg', :size => 114034, :description => "Latest release", :content_type => 'text/plain'} }
|
|
164
164
|
|
|
165
165
|
context "resouce created" do
|
|
@@ -171,28 +171,28 @@ describe Github::Repos::Downloads do
|
|
|
171
171
|
|
|
172
172
|
it "should fail to create resource if 'name' input is missing" do
|
|
173
173
|
expect {
|
|
174
|
-
github.repos.
|
|
174
|
+
github.repos.downloads.create user, repo, inputs.except(:name)
|
|
175
175
|
}.to raise_error(Github::Error::RequiredParams)
|
|
176
176
|
end
|
|
177
177
|
|
|
178
178
|
it "should failt to create resource if 'size' input is missing" do
|
|
179
179
|
expect {
|
|
180
|
-
github.repos.
|
|
180
|
+
github.repos.downloads.create user, repo, inputs.except(:size)
|
|
181
181
|
}.to raise_error(Github::Error::RequiredParams)
|
|
182
182
|
end
|
|
183
183
|
|
|
184
184
|
it "should create resource successfully" do
|
|
185
|
-
github.repos.
|
|
185
|
+
github.repos.downloads.create user, repo, inputs
|
|
186
186
|
a_post("/repos/#{user}/#{repo}/downloads").with(inputs).should have_been_made
|
|
187
187
|
end
|
|
188
188
|
|
|
189
189
|
it "should return the resource" do
|
|
190
|
-
download = github.repos.
|
|
190
|
+
download = github.repos.downloads.create user, repo, inputs
|
|
191
191
|
download.should be_a Hashie::Mash
|
|
192
192
|
end
|
|
193
193
|
|
|
194
194
|
it "should get the download information" do
|
|
195
|
-
download = github.repos.
|
|
195
|
+
download = github.repos.downloads.create user, repo, inputs
|
|
196
196
|
download.name.should == 'new_file.jpg'
|
|
197
197
|
end
|
|
198
198
|
end
|
|
@@ -200,16 +200,17 @@ describe Github::Repos::Downloads do
|
|
|
200
200
|
context "failed to create resource" do
|
|
201
201
|
before do
|
|
202
202
|
stub_post("/repos/#{user}/#{repo}/downloads").with(inputs).
|
|
203
|
-
to_return(:body => fixture('repos/download_s3.json'), :status => 404,
|
|
203
|
+
to_return(:body => fixture('repos/download_s3.json'), :status => 404,
|
|
204
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
204
205
|
end
|
|
205
206
|
|
|
206
207
|
it "should faile to retrieve resource" do
|
|
207
208
|
expect {
|
|
208
|
-
github.repos.
|
|
209
|
+
github.repos.downloads.create user, repo, inputs
|
|
209
210
|
}.to raise_error(Github::Error::NotFound)
|
|
210
211
|
end
|
|
211
212
|
end
|
|
212
|
-
end #
|
|
213
|
+
end # create
|
|
213
214
|
|
|
214
215
|
describe 'upload' do
|
|
215
216
|
let(:resource) { stub(:resource) }
|
|
@@ -223,14 +224,14 @@ describe Github::Repos::Downloads do
|
|
|
223
224
|
end
|
|
224
225
|
|
|
225
226
|
it "should fail if resource is of incorrect type" do
|
|
226
|
-
expect { github.repos.upload resource, nil }.to raise_error(ArgumentError)
|
|
227
|
+
expect { github.repos.downloads.upload resource, nil }.to raise_error(ArgumentError)
|
|
227
228
|
end
|
|
228
229
|
|
|
229
230
|
it "should upload resource successfully" do
|
|
230
231
|
res = stub(:response, :body => 'success')
|
|
231
232
|
uploader = stub(:uploader, :send => res)
|
|
232
233
|
Github::S3Uploader.should_receive(:new).with(resource, filename) { uploader }
|
|
233
|
-
github.repos.upload(resource, filename).should == 'success'
|
|
234
|
+
github.repos.downloads.upload(resource, filename).should == 'success'
|
|
234
235
|
end
|
|
235
236
|
end
|
|
236
237
|
end # upload
|
|
@@ -7,45 +7,44 @@ describe Github::Repos::Forks do
|
|
|
7
7
|
|
|
8
8
|
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
|
9
9
|
|
|
10
|
-
describe "
|
|
11
|
-
it { github.repos.should respond_to :
|
|
12
|
-
it { github.repos.should respond_to :repo_forks }
|
|
13
|
-
it { github.repos.should respond_to :repository_forks }
|
|
10
|
+
describe "#list" do
|
|
11
|
+
it { github.repos.forks.should respond_to :all }
|
|
14
12
|
|
|
15
13
|
context "resource found" do
|
|
16
14
|
before do
|
|
17
15
|
stub_get("/repos/#{user}/#{repo}/forks").
|
|
18
|
-
to_return(:body => fixture('repos/forks.json'), :status => 200,
|
|
16
|
+
to_return(:body => fixture('repos/forks.json'), :status => 200,
|
|
17
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
19
18
|
end
|
|
20
19
|
|
|
21
20
|
it "should fail to get resource without username" do
|
|
22
|
-
expect { github.repos.forks }.to raise_error(ArgumentError)
|
|
21
|
+
expect { github.repos.forks.list }.to raise_error(ArgumentError)
|
|
23
22
|
end
|
|
24
23
|
|
|
25
24
|
it "should get the resources" do
|
|
26
|
-
github.repos.forks user, repo
|
|
25
|
+
github.repos.forks.list user, repo
|
|
27
26
|
a_get("/repos/#{user}/#{repo}/forks").should have_been_made
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
it "should return array of resources" do
|
|
31
|
-
forks = github.repos.forks user, repo
|
|
30
|
+
forks = github.repos.forks.list user, repo
|
|
32
31
|
forks.should be_an Array
|
|
33
32
|
forks.should have(1).items
|
|
34
33
|
end
|
|
35
34
|
|
|
36
35
|
it "should be a mash type" do
|
|
37
|
-
forks = github.repos.forks user, repo
|
|
36
|
+
forks = github.repos.forks.list user, repo
|
|
38
37
|
forks.first.should be_a Hashie::Mash
|
|
39
38
|
end
|
|
40
39
|
|
|
41
40
|
it "should get fork information" do
|
|
42
|
-
forks = github.repos.forks user, repo
|
|
41
|
+
forks = github.repos.forks.list user, repo
|
|
43
42
|
forks.first.name.should == 'Hello-World'
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
it "should yield to a block" do
|
|
47
|
-
github.repos.should_receive(:
|
|
48
|
-
github.repos.forks(user, repo) { |param| 'web' }
|
|
46
|
+
github.repos.forks.should_receive(:list).with(user, repo).and_yield('web')
|
|
47
|
+
github.repos.forks.list(user, repo) { |param| 'web' }
|
|
49
48
|
end
|
|
50
49
|
end
|
|
51
50
|
|
|
@@ -57,34 +56,34 @@ describe Github::Repos::Forks do
|
|
|
57
56
|
|
|
58
57
|
it "should return 404 with a message 'Not Found'" do
|
|
59
58
|
expect {
|
|
60
|
-
github.repos.forks user, repo
|
|
59
|
+
github.repos.forks.list user, repo
|
|
61
60
|
}.to raise_error(Github::Error::NotFound)
|
|
62
61
|
end
|
|
63
62
|
end
|
|
64
|
-
end #
|
|
63
|
+
end # list
|
|
65
64
|
|
|
66
|
-
describe "
|
|
65
|
+
describe "#create" do
|
|
67
66
|
let(:inputs) { {:org => 'github'} }
|
|
68
67
|
|
|
69
68
|
context "resouce created" do
|
|
70
69
|
before do
|
|
71
70
|
stub_post("/repos/#{user}/#{repo}/forks").with(inputs).
|
|
72
|
-
to_return(:body => fixture('repos/fork.json'), :status => 201,
|
|
73
|
-
|
|
71
|
+
to_return(:body => fixture('repos/fork.json'), :status => 201,
|
|
72
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
74
73
|
end
|
|
75
74
|
|
|
76
75
|
it "should create resource successfully" do
|
|
77
|
-
github.repos.
|
|
76
|
+
github.repos.forks.create(user, repo, inputs)
|
|
78
77
|
a_post("/repos/#{user}/#{repo}/forks").with(inputs).should have_been_made
|
|
79
78
|
end
|
|
80
79
|
|
|
81
80
|
it "should return the resource" do
|
|
82
|
-
fork = github.repos.
|
|
81
|
+
fork = github.repos.forks.create user, repo, inputs
|
|
83
82
|
fork.should be_a Hashie::Mash
|
|
84
83
|
end
|
|
85
84
|
|
|
86
85
|
it "should get the fork information" do
|
|
87
|
-
fork = github.repos.
|
|
86
|
+
fork = github.repos.forks.create user, repo, inputs
|
|
88
87
|
fork.name.should == 'Hello-World'
|
|
89
88
|
end
|
|
90
89
|
end
|
|
@@ -92,16 +91,16 @@ describe Github::Repos::Forks do
|
|
|
92
91
|
context "failed to create resource" do
|
|
93
92
|
before do
|
|
94
93
|
stub_post("/repos/#{user}/#{repo}/forks").with(inputs).
|
|
95
|
-
to_return(:body => fixture('repos/fork.json'), :status => 404,
|
|
96
|
-
|
|
94
|
+
to_return(:body => fixture('repos/fork.json'), :status => 404,
|
|
95
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
97
96
|
end
|
|
98
97
|
|
|
99
98
|
it "should faile to retrieve resource" do
|
|
100
99
|
expect {
|
|
101
|
-
github.repos.
|
|
100
|
+
github.repos.forks.create user, repo, inputs
|
|
102
101
|
}.to raise_error(Github::Error::NotFound)
|
|
103
102
|
end
|
|
104
103
|
end
|
|
105
|
-
end #
|
|
104
|
+
end # create
|
|
106
105
|
|
|
107
106
|
end # Github::Repos::Forks
|
|
@@ -13,47 +13,44 @@ describe Github::Repos::Hooks do
|
|
|
13
13
|
it { described_class::VALID_HOOK_PARAM_VALUES.should_not be_nil }
|
|
14
14
|
it { described_class::REQUIRED_PARAMS.should_not be_nil }
|
|
15
15
|
|
|
16
|
-
describe "
|
|
17
|
-
|
|
18
|
-
it { github.repos.should respond_to :hooks }
|
|
19
|
-
it { github.repos.should respond_to :repo_hooks }
|
|
20
|
-
it { github.repos.should respond_to :repository_hooks }
|
|
21
|
-
end
|
|
16
|
+
describe "#list" do
|
|
17
|
+
it { github.repos.hooks.should respond_to :all }
|
|
22
18
|
|
|
23
19
|
context "resource found" do
|
|
24
20
|
before do
|
|
25
21
|
stub_get("/repos/#{user}/#{repo}/hooks").
|
|
26
|
-
to_return(:body => fixture('repos/hooks.json'), :status => 200,
|
|
22
|
+
to_return(:body => fixture('repos/hooks.json'), :status => 200,
|
|
23
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
27
24
|
end
|
|
28
25
|
|
|
29
26
|
it "should fail to get resource without username" do
|
|
30
|
-
expect { github.repos.hooks }.to raise_error(ArgumentError)
|
|
27
|
+
expect { github.repos.hooks.list }.to raise_error(ArgumentError)
|
|
31
28
|
end
|
|
32
29
|
|
|
33
30
|
it "should get the resources" do
|
|
34
|
-
github.repos.hooks user, repo
|
|
31
|
+
github.repos.hooks.list user, repo
|
|
35
32
|
a_get("/repos/#{user}/#{repo}/hooks").should have_been_made
|
|
36
33
|
end
|
|
37
34
|
|
|
38
35
|
it "should return array of resources" do
|
|
39
|
-
hooks = github.repos.hooks user, repo
|
|
36
|
+
hooks = github.repos.hooks.list user, repo
|
|
40
37
|
hooks.should be_an Array
|
|
41
38
|
hooks.should have(1).items
|
|
42
39
|
end
|
|
43
40
|
|
|
44
41
|
it "should be a mash type" do
|
|
45
|
-
hooks = github.repos.hooks user, repo
|
|
42
|
+
hooks = github.repos.hooks.list user, repo
|
|
46
43
|
hooks.first.should be_a Hashie::Mash
|
|
47
44
|
end
|
|
48
45
|
|
|
49
46
|
it "should get hook information" do
|
|
50
|
-
hooks = github.repos.hooks user, repo
|
|
47
|
+
hooks = github.repos.hooks.list user, repo
|
|
51
48
|
hooks.first.name.should == 'web'
|
|
52
49
|
end
|
|
53
50
|
|
|
54
51
|
it "should yield to a block" do
|
|
55
|
-
github.repos.should_receive(:
|
|
56
|
-
github.repos.hooks(user, repo) { |param| 'web' }
|
|
52
|
+
github.repos.hooks.should_receive(:list).with(user, repo).and_yield('web')
|
|
53
|
+
github.repos.hooks.list(user, repo) { |param| 'web' }
|
|
57
54
|
end
|
|
58
55
|
end
|
|
59
56
|
|
|
@@ -65,46 +62,43 @@ describe Github::Repos::Hooks do
|
|
|
65
62
|
|
|
66
63
|
it "should return 404 with a message 'Not Found'" do
|
|
67
64
|
expect {
|
|
68
|
-
github.repos.hooks user, repo
|
|
65
|
+
github.repos.hooks.list user, repo
|
|
69
66
|
}.to raise_error(Github::Error::NotFound)
|
|
70
67
|
end
|
|
71
68
|
end
|
|
72
|
-
end #
|
|
69
|
+
end # list
|
|
73
70
|
|
|
74
|
-
describe "
|
|
71
|
+
describe "#get" do
|
|
75
72
|
let(:hook_id) { 1 }
|
|
76
73
|
|
|
77
|
-
|
|
78
|
-
it { github.repos.should respond_to :hook }
|
|
79
|
-
it { github.repos.should respond_to :get_hook }
|
|
80
|
-
it { github.repos.should respond_to :repo_hook }
|
|
81
|
-
it { github.repos.should respond_to :get_repo_hook }
|
|
82
|
-
it { github.repos.should respond_to :repository_hook }
|
|
83
|
-
end
|
|
74
|
+
it { github.repos.hooks.should respond_to :find }
|
|
84
75
|
|
|
85
76
|
context "resource found" do
|
|
86
77
|
before do
|
|
87
78
|
stub_get("/repos/#{user}/#{repo}/hooks/#{hook_id}").
|
|
88
|
-
to_return(:body => fixture('repos/hook.json'), :status => 200,
|
|
79
|
+
to_return(:body => fixture('repos/hook.json'), :status => 200,
|
|
80
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
89
81
|
end
|
|
90
82
|
|
|
91
83
|
it "should fail to get resource without hook id" do
|
|
92
|
-
expect {
|
|
84
|
+
expect {
|
|
85
|
+
github.repos.hooks.get user, repo, nil
|
|
86
|
+
}.to raise_error(ArgumentError)
|
|
93
87
|
end
|
|
94
88
|
|
|
95
89
|
it "should get the resource" do
|
|
96
|
-
github.repos.
|
|
90
|
+
github.repos.hooks.get user, repo, hook_id
|
|
97
91
|
a_get("/repos/#{user}/#{repo}/hooks/#{hook_id}").should have_been_made
|
|
98
92
|
end
|
|
99
93
|
|
|
100
94
|
it "should get hook information" do
|
|
101
|
-
hook = github.repos.
|
|
95
|
+
hook = github.repos.hooks.get user, repo, hook_id
|
|
102
96
|
hook.id.should == hook_id
|
|
103
97
|
hook.name.should == 'web'
|
|
104
98
|
end
|
|
105
99
|
|
|
106
100
|
it "should return mash" do
|
|
107
|
-
hook = github.repos.
|
|
101
|
+
hook = github.repos.hooks.get user, repo, hook_id
|
|
108
102
|
hook.should be_a Hashie::Mash
|
|
109
103
|
end
|
|
110
104
|
end
|
|
@@ -117,13 +111,13 @@ describe Github::Repos::Hooks do
|
|
|
117
111
|
|
|
118
112
|
it "should fail to retrive resource" do
|
|
119
113
|
expect {
|
|
120
|
-
github.repos.
|
|
114
|
+
github.repos.hooks.get user, repo, hook_id
|
|
121
115
|
}.to raise_error(Github::Error::NotFound)
|
|
122
116
|
end
|
|
123
117
|
end
|
|
124
|
-
end #
|
|
118
|
+
end # get
|
|
125
119
|
|
|
126
|
-
describe "
|
|
120
|
+
describe "#create" do
|
|
127
121
|
let(:inputs) {
|
|
128
122
|
{
|
|
129
123
|
:name => 'web',
|
|
@@ -143,33 +137,34 @@ describe Github::Repos::Hooks do
|
|
|
143
137
|
before do
|
|
144
138
|
stub_post("/repos/#{user}/#{repo}/hooks").
|
|
145
139
|
with(:body => JSON.generate(inputs.except(:unrelated))).
|
|
146
|
-
to_return(:body => fixture('repos/hook.json'), :status => 201,
|
|
140
|
+
to_return(:body => fixture('repos/hook.json'), :status => 201,
|
|
141
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
147
142
|
end
|
|
148
143
|
|
|
149
144
|
it "should fail to create resource if 'name' input is missing" do
|
|
150
145
|
expect {
|
|
151
|
-
github.repos.
|
|
146
|
+
github.repos.hooks.create user, repo, inputs.except(:name)
|
|
152
147
|
}.to raise_error(Github::Error::RequiredParams)
|
|
153
148
|
end
|
|
154
149
|
|
|
155
150
|
it "should failt to create resource if 'config' input is missing" do
|
|
156
151
|
expect {
|
|
157
|
-
github.repos.
|
|
152
|
+
github.repos.hooks.create user, repo, inputs.except(:config)
|
|
158
153
|
}.to raise_error(Github::Error::RequiredParams)
|
|
159
154
|
end
|
|
160
155
|
|
|
161
156
|
it "should create resource successfully" do
|
|
162
|
-
github.repos.
|
|
157
|
+
github.repos.hooks.create user, repo, inputs
|
|
163
158
|
a_post("/repos/#{user}/#{repo}/hooks").with(inputs).should have_been_made
|
|
164
159
|
end
|
|
165
160
|
|
|
166
161
|
it "should return the resource" do
|
|
167
|
-
hook = github.repos.
|
|
162
|
+
hook = github.repos.hooks.create user, repo, inputs
|
|
168
163
|
hook.should be_a Hashie::Mash
|
|
169
164
|
end
|
|
170
165
|
|
|
171
166
|
it "should get the hook information" do
|
|
172
|
-
hook = github.repos.
|
|
167
|
+
hook = github.repos.hooks.create user, repo, inputs
|
|
173
168
|
hook.name.should == 'web'
|
|
174
169
|
end
|
|
175
170
|
end
|
|
@@ -177,18 +172,19 @@ describe Github::Repos::Hooks do
|
|
|
177
172
|
context "fail to create resource" do
|
|
178
173
|
before do
|
|
179
174
|
stub_post("/repos/#{user}/#{repo}/hooks").with(inputs).
|
|
180
|
-
to_return(:body => fixture('repos/hook.json'), :status => 404,
|
|
175
|
+
to_return(:body => fixture('repos/hook.json'), :status => 404,
|
|
176
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
181
177
|
end
|
|
182
178
|
|
|
183
179
|
it "should fail to retrieve resource" do
|
|
184
180
|
expect {
|
|
185
|
-
github.repos.
|
|
181
|
+
github.repos.hooks.create user, repo, inputs
|
|
186
182
|
}.to raise_error(Github::Error::NotFound)
|
|
187
183
|
end
|
|
188
184
|
end
|
|
189
|
-
end #
|
|
185
|
+
end # create
|
|
190
186
|
|
|
191
|
-
describe "
|
|
187
|
+
describe "#edit" do
|
|
192
188
|
let(:hook_id) { 1 }
|
|
193
189
|
let(:inputs) {
|
|
194
190
|
{
|
|
@@ -209,45 +205,45 @@ describe Github::Repos::Hooks do
|
|
|
209
205
|
before do
|
|
210
206
|
stub_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").
|
|
211
207
|
with(:body => JSON.generate(inputs.except(:unrelated))).
|
|
212
|
-
to_return(:body => fixture("repos/hook.json"), :status => 200,
|
|
208
|
+
to_return(:body => fixture("repos/hook.json"), :status => 200,
|
|
209
|
+
:headers => { :content_type => "application/json; charset=utf-8"})
|
|
213
210
|
end
|
|
214
211
|
|
|
215
212
|
it "should fail to edit without 'user/repo' parameters" do
|
|
216
|
-
github.
|
|
217
|
-
expect { github.repos.edit_hook }.to raise_error(ArgumentError)
|
|
213
|
+
expect { github.repos.hooks.edit }.to raise_error(ArgumentError)
|
|
218
214
|
end
|
|
219
215
|
|
|
220
216
|
it "should fail to edit resource without 'name' parameter" do
|
|
221
217
|
expect{
|
|
222
|
-
github.repos.
|
|
218
|
+
github.repos.hooks.edit user, repo, inputs.except(:name)
|
|
223
219
|
}.to raise_error(Github::Error::RequiredParams)
|
|
224
220
|
end
|
|
225
221
|
|
|
226
222
|
it "should fail to edit resource without 'hook_id'" do
|
|
227
223
|
expect {
|
|
228
|
-
github.repos.
|
|
224
|
+
github.repos.hooks.edit user, repo
|
|
229
225
|
}.to raise_error(ArgumentError)
|
|
230
226
|
end
|
|
231
227
|
|
|
232
228
|
it "should fail to edit resource without 'config' parameter" do
|
|
233
229
|
expect {
|
|
234
|
-
github.repos.
|
|
230
|
+
github.repos.hooks.edit user, repo, hook_id, inputs.except(:config)
|
|
235
231
|
}.to raise_error(Github::Error::RequiredParams)
|
|
236
232
|
end
|
|
237
233
|
|
|
238
234
|
it "should edit the resource" do
|
|
239
|
-
github.repos.
|
|
235
|
+
github.repos.hooks.edit user, repo, hook_id, inputs
|
|
240
236
|
a_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").
|
|
241
237
|
with(inputs).should have_been_made
|
|
242
238
|
end
|
|
243
239
|
|
|
244
240
|
it "should return resource" do
|
|
245
|
-
hook = github.repos.
|
|
241
|
+
hook = github.repos.hooks.edit user, repo, hook_id, inputs
|
|
246
242
|
hook.should be_a Hashie::Mash
|
|
247
243
|
end
|
|
248
244
|
|
|
249
245
|
it "should be able to retrieve information" do
|
|
250
|
-
hook = github.repos.
|
|
246
|
+
hook = github.repos.hooks.edit user, repo, hook_id, inputs
|
|
251
247
|
hook.name.should == 'web'
|
|
252
248
|
end
|
|
253
249
|
end
|
|
@@ -255,39 +251,40 @@ describe Github::Repos::Hooks do
|
|
|
255
251
|
context "failed to edit resource" do
|
|
256
252
|
before do
|
|
257
253
|
stub_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").with(inputs).
|
|
258
|
-
to_return(:body => fixture("repos/hook.json"), :status => 404,
|
|
254
|
+
to_return(:body => fixture("repos/hook.json"), :status => 404,
|
|
255
|
+
:headers => { :content_type => "application/json; charset=utf-8"})
|
|
259
256
|
end
|
|
260
257
|
|
|
261
258
|
it "should fail to find resource" do
|
|
262
259
|
expect {
|
|
263
|
-
github.repos.
|
|
260
|
+
github.repos.hooks.edit user, repo, hook_id, inputs
|
|
264
261
|
}.to raise_error(Github::Error::NotFound)
|
|
265
262
|
end
|
|
266
263
|
end
|
|
267
|
-
end #
|
|
264
|
+
end # edit
|
|
268
265
|
|
|
269
|
-
describe "
|
|
266
|
+
describe "#delete" do
|
|
270
267
|
let(:hook_id) { 1 }
|
|
271
268
|
|
|
272
269
|
context "resource removed successfully" do
|
|
273
270
|
before do
|
|
274
271
|
stub_delete("/repos/#{user}/#{repo}/hooks/#{hook_id}").
|
|
275
|
-
to_return(:body => '', :status => 204,
|
|
272
|
+
to_return(:body => '', :status => 204,
|
|
273
|
+
:headers => { :content_type => "application/json; charset=utf-8"})
|
|
276
274
|
end
|
|
277
275
|
|
|
278
276
|
it "should fail to delete without 'user/repo' parameters" do
|
|
279
|
-
github.
|
|
280
|
-
expect { github.repos.delete_hook }.to raise_error(ArgumentError)
|
|
277
|
+
expect { github.repos.hooks.delete }.to raise_error(ArgumentError)
|
|
281
278
|
end
|
|
282
279
|
|
|
283
280
|
it "should fail to delete resource without 'hook_id'" do
|
|
284
281
|
expect {
|
|
285
|
-
github.repos.
|
|
282
|
+
github.repos.hooks.delete user, repo
|
|
286
283
|
}.to raise_error(ArgumentError)
|
|
287
284
|
end
|
|
288
285
|
|
|
289
286
|
it "should delete the resource" do
|
|
290
|
-
github.repos.
|
|
287
|
+
github.repos.hooks.delete user, repo, hook_id
|
|
291
288
|
a_delete("/repos/#{user}/#{repo}/hooks/#{hook_id}").should have_been_made
|
|
292
289
|
end
|
|
293
290
|
end
|
|
@@ -300,34 +297,34 @@ describe Github::Repos::Hooks do
|
|
|
300
297
|
|
|
301
298
|
it "should fail to find resource" do
|
|
302
299
|
expect {
|
|
303
|
-
github.repos.
|
|
300
|
+
github.repos.hooks.delete user, repo, hook_id
|
|
304
301
|
}.to raise_error(Github::Error::NotFound)
|
|
305
302
|
end
|
|
306
303
|
end
|
|
307
|
-
end #
|
|
304
|
+
end # delete
|
|
308
305
|
|
|
309
|
-
describe "
|
|
306
|
+
describe "#test" do
|
|
310
307
|
let(:hook_id) { 1 }
|
|
311
308
|
|
|
312
309
|
context "resource tested successfully" do
|
|
313
310
|
before do
|
|
314
311
|
stub_post("/repos/#{user}/#{repo}/hooks/#{hook_id}/test").
|
|
315
|
-
to_return(:body => '', :status => 204,
|
|
312
|
+
to_return(:body => '', :status => 204,
|
|
313
|
+
:headers => { :content_type => "application/json; charset=utf-8"})
|
|
316
314
|
end
|
|
317
315
|
|
|
318
316
|
it "should fail to test without 'user/repo' parameters" do
|
|
319
|
-
github.
|
|
320
|
-
expect { github.repos.test_hook }.to raise_error(ArgumentError)
|
|
317
|
+
expect { github.repos.hooks.test }.to raise_error(ArgumentError)
|
|
321
318
|
end
|
|
322
319
|
|
|
323
320
|
it "should fail to test resource without 'hook_id'" do
|
|
324
321
|
expect {
|
|
325
|
-
github.repos.
|
|
322
|
+
github.repos.hooks.test user, repo
|
|
326
323
|
}.to raise_error(ArgumentError)
|
|
327
324
|
end
|
|
328
325
|
|
|
329
326
|
it "should trigger test for the resource" do
|
|
330
|
-
github.repos.
|
|
327
|
+
github.repos.hooks.test user, repo, hook_id
|
|
331
328
|
a_post("/repos/#{user}/#{repo}/hooks/#{hook_id}/test").should have_been_made
|
|
332
329
|
end
|
|
333
330
|
end
|
|
@@ -335,15 +332,16 @@ describe Github::Repos::Hooks do
|
|
|
335
332
|
context "failed to test resource" do
|
|
336
333
|
before do
|
|
337
334
|
stub_post("/repos/#{user}/#{repo}/hooks/#{hook_id}/test").
|
|
338
|
-
to_return(:body => '', :status => 404,
|
|
335
|
+
to_return(:body => '', :status => 404,
|
|
336
|
+
:headers => { :content_type => "application/json; charset=utf-8"})
|
|
339
337
|
end
|
|
340
338
|
|
|
341
339
|
it "should fail to find resource" do
|
|
342
340
|
expect {
|
|
343
|
-
github.repos.
|
|
341
|
+
github.repos.hooks.test user, repo, hook_id
|
|
344
342
|
}.to raise_error(Github::Error::NotFound)
|
|
345
343
|
end
|
|
346
344
|
end
|
|
347
|
-
end #
|
|
345
|
+
end # test
|
|
348
346
|
|
|
349
347
|
end # Github::Repos::Hooks
|