github_api 0.8.11 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +21 -14
- data/features/activity/notifications.feature +15 -0
- data/features/cassettes/activity/notifications/list_user.yml +54 -0
- data/features/step_definitions/common_steps.rb +8 -9
- data/lib/github_api.rb +3 -4
- data/lib/github_api/activity.rb +8 -13
- data/lib/github_api/activity/events.rb +0 -5
- data/lib/github_api/activity/notifications.rb +0 -5
- data/lib/github_api/api.rb +27 -22
- data/lib/github_api/api_factory.rb +13 -12
- data/lib/github_api/authorizations.rb +0 -5
- data/lib/github_api/client.rb +33 -33
- data/lib/github_api/configuration.rb +10 -2
- data/lib/github_api/connection.rb +2 -3
- data/lib/github_api/constants.rb +0 -3
- data/lib/github_api/gists.rb +2 -7
- data/lib/github_api/git_data.rb +10 -15
- data/lib/github_api/git_data/blobs.rb +0 -5
- data/lib/github_api/git_data/commits.rb +0 -5
- data/lib/github_api/git_data/references.rb +3 -7
- data/lib/github_api/git_data/tags.rb +0 -5
- data/lib/github_api/git_data/trees.rb +0 -5
- data/lib/github_api/gitignore.rb +0 -5
- data/lib/github_api/issues.rb +10 -15
- data/lib/github_api/issues/comments.rb +0 -5
- data/lib/github_api/issues/events.rb +0 -5
- data/lib/github_api/issues/labels.rb +0 -5
- data/lib/github_api/issues/milestones.rb +0 -5
- data/lib/github_api/markdown.rb +0 -5
- data/lib/github_api/meta.rb +0 -5
- data/lib/github_api/orgs.rb +4 -9
- data/lib/github_api/page_iterator.rb +44 -29
- data/lib/github_api/paged_request.rb +12 -12
- data/lib/github_api/{result.rb → pagination.rb} +19 -86
- data/lib/github_api/params_hash.rb +1 -1
- data/lib/github_api/pull_requests.rb +2 -7
- data/lib/github_api/repos.rb +22 -27
- data/lib/github_api/request.rb +7 -4
- data/lib/github_api/response/header.rb +76 -0
- data/lib/github_api/response_wrapper.rb +126 -0
- data/lib/github_api/scopes.rb +1 -1
- data/lib/github_api/search.rb +0 -5
- data/lib/github_api/users.rb +6 -11
- data/lib/github_api/version.rb +2 -2
- data/spec/github/activity/notifications/get_spec.rb +1 -1
- data/spec/github/activity/starring/starred_spec.rb +1 -1
- data/spec/github/activity/watching/watched_spec.rb +1 -1
- data/spec/github/api_factory_spec.rb +7 -8
- data/spec/github/api_spec.rb +0 -7
- data/spec/github/authorization_spec.rb +22 -32
- data/spec/github/authorizations/create_spec.rb +49 -0
- data/spec/github/authorizations/delete_spec.rb +39 -0
- data/spec/github/authorizations/get_spec.rb +49 -0
- data/spec/github/authorizations/list_spec.rb +55 -0
- data/spec/github/authorizations/update_spec.rb +50 -0
- data/spec/github/authorizations_spec.rb +2 -236
- data/spec/github/gists/comments/create_spec.rb +1 -1
- data/spec/github/gists/comments/edit_spec.rb +1 -1
- data/spec/github/gists/comments/get_spec.rb +1 -1
- data/spec/github/gists/create_spec.rb +1 -1
- data/spec/github/gists/edit_spec.rb +1 -1
- data/spec/github/gists/fork_spec.rb +1 -1
- data/spec/github/gists/get_spec.rb +1 -1
- data/spec/github/git_data/blobs/create_spec.rb +1 -1
- data/spec/github/git_data/blobs/get_spec.rb +1 -1
- data/spec/github/git_data/commits/create_spec.rb +1 -1
- data/spec/github/git_data/commits/get_spec.rb +1 -1
- data/spec/github/git_data/references/create_spec.rb +2 -2
- data/spec/github/git_data/references/get_spec.rb +1 -1
- data/spec/github/git_data/references/list_spec.rb +16 -6
- data/spec/github/git_data/tags/create_spec.rb +1 -1
- data/spec/github/git_data/tags/get_spec.rb +1 -1
- data/spec/github/git_data/trees/create_spec.rb +1 -1
- data/spec/github/git_data/trees/get_spec.rb +4 -4
- data/spec/github/issues/comments/create_spec.rb +1 -1
- data/spec/github/issues/comments/edit_spec.rb +1 -1
- data/spec/github/issues/comments/get_spec.rb +1 -1
- data/spec/github/issues/create_spec.rb +1 -1
- data/spec/github/issues/edit_spec.rb +1 -1
- data/spec/github/issues/events/get_spec.rb +1 -1
- data/spec/github/issues/get_spec.rb +1 -1
- data/spec/github/issues/labels/create_spec.rb +1 -1
- data/spec/github/issues/labels/get_spec.rb +1 -1
- data/spec/github/issues/labels/update_spec.rb +1 -1
- data/spec/github/issues/milestones/create_spec.rb +1 -1
- data/spec/github/issues/milestones/delete_spec.rb +1 -1
- data/spec/github/issues/milestones/get_spec.rb +1 -1
- data/spec/github/issues/milestones/update_spec.rb +1 -1
- data/spec/github/orgs/edit_spec.rb +1 -1
- data/spec/github/orgs/get_spec.rb +1 -1
- data/spec/github/orgs/teams/create_spec.rb +1 -1
- data/spec/github/orgs/teams/edit_spec.rb +1 -1
- data/spec/github/orgs/teams/get_spec.rb +1 -1
- data/spec/github/paged_request_spec.rb +34 -29
- data/spec/github/pagination/iterator/number_spec.rb +118 -0
- data/spec/github/pagination/iterator/sha_spec.rb +67 -0
- data/spec/github/pull_requests/comments/create_spec.rb +1 -1
- data/spec/github/pull_requests/comments/edit_spec.rb +1 -1
- data/spec/github/pull_requests/comments/get_spec.rb +1 -1
- data/spec/github/pull_requests/create_spec.rb +1 -1
- data/spec/github/pull_requests/get_spec.rb +1 -1
- data/spec/github/pull_requests/update_spec.rb +1 -1
- data/spec/github/repos/branch_spec.rb +1 -1
- data/spec/github/repos/comments/create_spec.rb +1 -1
- data/spec/github/repos/comments/get_spec.rb +1 -1
- data/spec/github/repos/comments/update_spec.rb +1 -1
- data/spec/github/repos/commits/get_spec.rb +1 -1
- data/spec/github/repos/create_spec.rb +1 -1
- data/spec/github/repos/downloads/create_spec.rb +1 -1
- data/spec/github/repos/downloads/get_spec.rb +1 -1
- data/spec/github/repos/edit_spec.rb +1 -1
- data/spec/github/repos/forks/create_spec.rb +1 -1
- data/spec/github/repos/get_spec.rb +1 -1
- data/spec/github/repos/hooks/create_spec.rb +1 -1
- data/spec/github/repos/hooks/edit_spec.rb +1 -1
- data/spec/github/repos/hooks/get_spec.rb +1 -1
- data/spec/github/repos/languages_spec.rb +1 -1
- data/spec/github/repos/merging/merge_spec.rb +1 -1
- data/spec/github/repos/statuses/create_spec.rb +1 -1
- data/spec/github/repos/tags_spec.rb +1 -1
- data/spec/github/repos/teams_spec.rb +1 -1
- data/spec/github/request/endpoint_spec.rb +24 -0
- data/spec/github/request/request_spec.rb +38 -0
- data/spec/github/{result_spec.rb → response_wrapper_spec.rb} +14 -13
- data/spec/github/users/emails/list_spec.rb +1 -1
- data/spec/github/users/get_spec.rb +2 -7
- data/spec/github/users/keys/create_spec.rb +1 -1
- data/spec/github/users/keys/get_spec.rb +1 -1
- data/spec/github/users/keys/update_spec.rb +1 -1
- data/spec/github/users/update_spec.rb +1 -1
- data/spec/github_spec.rb +1 -6
- data/spec/{github/activity → integration}/activity_spec.rb +0 -0
- data/spec/{github/gists → integration}/gists_spec.rb +2 -0
- data/spec/{github/git_data → integration}/git_data_spec.rb +0 -0
- data/spec/{github/issues → integration}/issues_spec.rb +2 -0
- data/spec/integration/options_spec.rb +103 -23
- data/spec/{github/orgs → integration}/orgs_spec.rb +0 -0
- data/spec/{github/pull_requests → integration}/pull_requests_spec.rb +0 -0
- data/spec/{github → integration}/repos_spec.rb +2 -0
- data/spec/{github/users → integration}/users_spec.rb +0 -0
- data/spec/shared/array_of_resources_behaviour.rb +1 -1
- metadata +55 -46
- data/lib/github_api/page_uri_processor.rb +0 -25
- data/lib/github_api/response/helpers.rb +0 -21
- data/spec/github/page_iterator_spec.rb +0 -260
- data/spec/github/response/helpers_spec.rb +0 -16
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Authorizations, '#update' do
|
6
|
+
let(:basic_auth) { 'login:password' }
|
7
|
+
let(:request_path) { "/authorizations/#{authorization_id}" }
|
8
|
+
let(:host) { "https://#{basic_auth}@api.github.com" }
|
9
|
+
let(:authorization_id) { 1 }
|
10
|
+
let(:inputs) { { :add_scopes => ['repo'] } }
|
11
|
+
|
12
|
+
before {
|
13
|
+
stub_patch(request_path, host).to_return(:body => body, :status => status,
|
14
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
15
|
+
}
|
16
|
+
|
17
|
+
before { subject.basic_auth = basic_auth }
|
18
|
+
|
19
|
+
after { reset_authentication_for(subject) }
|
20
|
+
|
21
|
+
context "resouce updated" do
|
22
|
+
let(:body) { fixture('auths/authorization.json') }
|
23
|
+
let(:status) { 201 }
|
24
|
+
|
25
|
+
it "should fail to get resource without basic authentication" do
|
26
|
+
reset_authentication_for subject
|
27
|
+
expect { subject.update }.to raise_error(ArgumentError)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should update resource successfully" do
|
31
|
+
subject.update authorization_id, inputs
|
32
|
+
a_patch(request_path, host).with(inputs).should have_been_made
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return the resource" do
|
36
|
+
authorization = subject.update authorization_id, inputs
|
37
|
+
authorization.should be_a Github::ResponseWrapper
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should get the authorization information" do
|
41
|
+
authorization = subject.update authorization_id, inputs
|
42
|
+
authorization.token.should == 'abc123'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it_should_behave_like 'request failure' do
|
47
|
+
let(:requestable) { subject.update authorization_id, inputs }
|
48
|
+
end
|
49
|
+
|
50
|
+
end # update
|
@@ -3,243 +3,9 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Github::Authorizations do
|
6
|
-
let(:github) { Github.new }
|
7
|
-
let(:basic_auth) { 'login:password' }
|
8
6
|
|
9
|
-
|
10
|
-
github.basic_auth = basic_auth
|
11
|
-
end
|
7
|
+
after { reset_authentication_for subject }
|
12
8
|
|
13
|
-
|
14
|
-
reset_authentication_for github
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "authorizations" do
|
18
|
-
it { github.authorizations.should respond_to :all }
|
19
|
-
|
20
|
-
context "resource found" do
|
21
|
-
before do
|
22
|
-
stub_get("/authorizations", "https://#{basic_auth}@api.github.com").
|
23
|
-
to_return(:body => fixture('auths/authorizations.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
it "should fail to get resource without basic authentication" do
|
28
|
-
reset_authentication_for github
|
29
|
-
expect { github.oauth.list }.to raise_error(ArgumentError)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should get the resources" do
|
33
|
-
github.oauth.list
|
34
|
-
a_get("/authorizations", "https://#{basic_auth}@api.github.com").should have_been_made
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should return array of resources" do
|
38
|
-
authorizations = github.oauth.list
|
39
|
-
authorizations.should be_an Array
|
40
|
-
authorizations.should have(1).items
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should be a mash type" do
|
44
|
-
authorizations = github.oauth.list
|
45
|
-
authorizations.first.should be_a Hashie::Mash
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should get authorization information" do
|
49
|
-
authorizations = github.oauth.list
|
50
|
-
authorizations.first.token.should == 'abc123'
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should yield to a block" do
|
54
|
-
github.oauth.should_receive(:list).and_yield('web')
|
55
|
-
github.oauth.list { |param| 'web' }
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "resource not found" do
|
60
|
-
before do
|
61
|
-
stub_get("/authorizations", "https://#{basic_auth}@api.github.com").
|
62
|
-
to_return(:body => "", :status => [404, "Not Found"])
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should return 404 with a message 'Not Found'" do
|
66
|
-
expect { github.oauth.list }.to raise_error(Github::Error::NotFound)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end # authorizations
|
70
|
-
|
71
|
-
describe "#get" do
|
72
|
-
let(:authorization_id) { 1 }
|
73
|
-
|
74
|
-
context "resource found" do
|
75
|
-
before do
|
76
|
-
stub_get("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").
|
77
|
-
to_return(:body => fixture('auths/authorization.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should fail to get resource without authorization id" do
|
81
|
-
expect { github.oauth.get nil }.to raise_error(ArgumentError)
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should get the resource" do
|
85
|
-
github.oauth.get authorization_id
|
86
|
-
a_get("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").should have_been_made
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should get authorization information" do
|
90
|
-
authorization = github.oauth.get authorization_id
|
91
|
-
authorization.id.should == authorization_id
|
92
|
-
authorization.token.should == 'abc123'
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should return mash" do
|
96
|
-
authorization = github.oauth.get authorization_id
|
97
|
-
authorization.should be_a Hashie::Mash
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context "resource not found" do
|
102
|
-
before do
|
103
|
-
stub_get("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").
|
104
|
-
to_return(:body => fixture('auths/authorization.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should fail to retrive resource" do
|
108
|
-
expect {
|
109
|
-
github.oauth.get authorization_id
|
110
|
-
}.to raise_error(Github::Error::NotFound)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end # list
|
114
|
-
|
115
|
-
describe "#create" do
|
116
|
-
let(:inputs) { { :scopes => ['repo'] } }
|
117
|
-
|
118
|
-
context "resouce created" do
|
119
|
-
|
120
|
-
it "should fail to get resource without basic authentication" do
|
121
|
-
reset_authentication_for github
|
122
|
-
expect { github.oauth.create }.to raise_error(ArgumentError)
|
123
|
-
end
|
124
|
-
|
125
|
-
before do
|
126
|
-
stub_post("/authorizations", "https://#{basic_auth}@api.github.com").with(inputs).
|
127
|
-
to_return(:body => fixture('auths/authorization.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should create resource successfully" do
|
131
|
-
github.oauth.create inputs
|
132
|
-
a_post("/authorizations", "https://#{basic_auth}@api.github.com").with(inputs).should have_been_made
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should return the resource" do
|
136
|
-
authorization = github.oauth.create inputs
|
137
|
-
authorization.should be_a Hashie::Mash
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should get the authorization information" do
|
141
|
-
authorization = github.oauth.create inputs
|
142
|
-
authorization.token.should == 'abc123'
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
context "failed to create resource" do
|
147
|
-
before do
|
148
|
-
stub_post("/authorizations", "https://#{basic_auth}@api.github.com").with(inputs).
|
149
|
-
to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
150
|
-
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should fail to retrieve resource" do
|
154
|
-
expect {
|
155
|
-
github.oauth.create inputs
|
156
|
-
}.to raise_error(Github::Error::NotFound)
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end # create
|
160
|
-
|
161
|
-
describe "#update" do
|
162
|
-
let(:authorization_id) { 1 }
|
163
|
-
let(:inputs) { { :add_scopes => ['repo'] } }
|
164
|
-
|
165
|
-
context "resouce updated" do
|
166
|
-
|
167
|
-
it "should fail to get resource without basic authentication" do
|
168
|
-
reset_authentication_for github
|
169
|
-
expect { github.oauth.update }.to raise_error(ArgumentError)
|
170
|
-
end
|
171
|
-
|
172
|
-
before do
|
173
|
-
stub_patch("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").with(inputs).
|
174
|
-
to_return(:body => fixture('auths/authorization.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
175
|
-
end
|
176
|
-
|
177
|
-
it "should update resource successfully" do
|
178
|
-
github.oauth.update authorization_id, inputs
|
179
|
-
a_patch("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").with(inputs).should have_been_made
|
180
|
-
end
|
181
|
-
|
182
|
-
it "should return the resource" do
|
183
|
-
authorization = github.oauth.update authorization_id, inputs
|
184
|
-
authorization.should be_a Hashie::Mash
|
185
|
-
end
|
186
|
-
|
187
|
-
it "should get the authorization information" do
|
188
|
-
authorization = github.oauth.update authorization_id, inputs
|
189
|
-
authorization.token.should == 'abc123'
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
context "failed to update resource" do
|
194
|
-
before do
|
195
|
-
stub_patch("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").with(inputs).
|
196
|
-
to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
197
|
-
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should fail to retrieve resource" do
|
201
|
-
expect {
|
202
|
-
github.oauth.update authorization_id, inputs
|
203
|
-
}.to raise_error(Github::Error::NotFound)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end # update
|
207
|
-
|
208
|
-
describe "#delete" do
|
209
|
-
let(:authorization_id) { 1 }
|
210
|
-
let(:inputs) { { :add_scopes => ['repo'] } }
|
211
|
-
|
212
|
-
context "resouce deleted" do
|
213
|
-
|
214
|
-
it "should fail to get resource without basic authentication" do
|
215
|
-
reset_authentication_for github
|
216
|
-
expect { github.oauth.delete nil }.to raise_error(ArgumentError)
|
217
|
-
end
|
218
|
-
|
219
|
-
before do
|
220
|
-
stub_delete("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").
|
221
|
-
to_return(:body => '', :status => 204, :headers => {:content_type => "application/json; charset=utf-8"})
|
222
|
-
end
|
223
|
-
|
224
|
-
it "should delete resource successfully" do
|
225
|
-
github.oauth.delete authorization_id
|
226
|
-
a_delete("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").should have_been_made
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
context "failed to create resource" do
|
231
|
-
before do
|
232
|
-
stub_delete("/authorizations/#{authorization_id}", "https://#{basic_auth}@api.github.com").
|
233
|
-
to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
234
|
-
|
235
|
-
end
|
236
|
-
|
237
|
-
it "should fail to retrieve resource" do
|
238
|
-
expect {
|
239
|
-
github.oauth.delete authorization_id
|
240
|
-
}.to raise_error(Github::Error::NotFound)
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end # delete
|
9
|
+
it_should_behave_like 'api interface'
|
244
10
|
|
245
11
|
end # Github::Authorizations
|
@@ -35,7 +35,7 @@ describe Github::Gists::Comments, '#create' do
|
|
35
35
|
|
36
36
|
it "should return the resource" do
|
37
37
|
comment = subject.create gist_id, inputs
|
38
|
-
comment.should be_a
|
38
|
+
comment.should be_a Github::ResponseWrapper
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should get the comment information" do
|
@@ -36,7 +36,7 @@ describe Github::Gists::Comments, '#create' do
|
|
36
36
|
|
37
37
|
it "should return the resource" do
|
38
38
|
comment = subject.edit gist_id, comment_id, inputs
|
39
|
-
comment.should be_a
|
39
|
+
comment.should be_a Github::ResponseWrapper
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should get the comment information" do
|
@@ -46,7 +46,7 @@ describe Github::GitData::Blobs, '#create' do
|
|
46
46
|
|
47
47
|
it "should return the resource" do
|
48
48
|
blob_sha = subject.create user, repo, inputs
|
49
|
-
blob_sha.should be_a
|
49
|
+
blob_sha.should be_a Github::ResponseWrapper
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should get the blob information" do
|
@@ -59,7 +59,7 @@ describe Github::GitData::Commits, '#get' do
|
|
59
59
|
|
60
60
|
it "should return the resource" do
|
61
61
|
commit = subject.create user, repo, inputs
|
62
|
-
commit.should be_a
|
62
|
+
commit.should be_a Github::ResponseWrapper
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should get the commit information" do
|
@@ -38,10 +38,10 @@ describe Github::GitData::References, '#create' do
|
|
38
38
|
}.to raise_error(Github::Error::RequiredParams)
|
39
39
|
end
|
40
40
|
|
41
|
-
it "should fail to create resource if 'ref' is
|
41
|
+
it "should fail to create resource if 'ref' is correct" do
|
42
42
|
expect {
|
43
43
|
subject.create user, repo, :ref => '/heads/master', :sha => '13t2a1r3'
|
44
|
-
}.
|
44
|
+
}.not_to raise_error(ArgumentError)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should create resource successfully" do
|
@@ -28,7 +28,7 @@ describe Github::GitData::References, '#get' do
|
|
28
28
|
it "should fail to get resource with wrong ref" do
|
29
29
|
expect {
|
30
30
|
subject.get user, repo, '/branch'
|
31
|
-
}.
|
31
|
+
}.not_to raise_error(ArgumentError)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should get the resource" do
|
@@ -6,7 +6,7 @@ describe Github::GitData::References, '#list' do
|
|
6
6
|
let(:user) { 'peter-murach' }
|
7
7
|
let(:repo) { 'github' }
|
8
8
|
let(:ref) { "heads/master" }
|
9
|
-
let(:request_path) { "/repos/#{user}/#{repo}/git/refs/#{ref}" }
|
9
|
+
let(:request_path) { "/repos/#{user}/#{repo}/git/refs/#{ref}".gsub(/(\/)+/, '/') }
|
10
10
|
|
11
11
|
before {
|
12
12
|
stub_get(request_path).to_return(:body => body, :status => status,
|
@@ -31,7 +31,7 @@ describe Github::GitData::References, '#list' do
|
|
31
31
|
it "should fail to call" do
|
32
32
|
expect {
|
33
33
|
subject.list user, repo, :ref => ref
|
34
|
-
}.
|
34
|
+
}.to_not raise_error(ArgumentError, /reference/)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -41,7 +41,7 @@ describe Github::GitData::References, '#list' do
|
|
41
41
|
it "should pass with valid reference" do
|
42
42
|
expect {
|
43
43
|
subject.list user, repo, :ref => ref
|
44
|
-
}.to_not raise_error(ArgumentError)
|
44
|
+
}.to_not raise_error(ArgumentError, /reference/)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -51,7 +51,7 @@ describe Github::GitData::References, '#list' do
|
|
51
51
|
it "should pass with valid reference" do
|
52
52
|
expect {
|
53
53
|
subject.list user, repo, :ref => ref
|
54
|
-
}.to_not raise_error(ArgumentError)
|
54
|
+
}.to_not raise_error(ArgumentError, /reference/)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -61,7 +61,17 @@ describe Github::GitData::References, '#list' do
|
|
61
61
|
it "should pass with valid reference" do
|
62
62
|
expect {
|
63
63
|
subject.list user, repo, :ref => ref
|
64
|
-
}.to_not raise_error(ArgumentError)
|
64
|
+
}.to_not raise_error(ArgumentError, /reference/)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'with valid renference and refs with leading slash' do
|
69
|
+
let(:ref) { '/refs/heads/lleger-refactor' }
|
70
|
+
|
71
|
+
it "should pass with valid reference" do
|
72
|
+
expect {
|
73
|
+
subject.list user, repo, :ref => ref
|
74
|
+
}.to_not raise_error(ArgumentError, /reference/)
|
65
75
|
end
|
66
76
|
end
|
67
77
|
|
@@ -72,7 +82,7 @@ describe Github::GitData::References, '#list' do
|
|
72
82
|
|
73
83
|
it "should return array of resources" do
|
74
84
|
references = subject.list user, repo, :ref => ref
|
75
|
-
references.should be_an
|
85
|
+
references.should be_an Enumerable
|
76
86
|
references.should have(3).items
|
77
87
|
end
|
78
88
|
|