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
|
@@ -7,13 +7,10 @@ describe Github::Gists::Comments do
|
|
|
7
7
|
let(:gist_id) { '1' }
|
|
8
8
|
let(:comment_id) { 1 }
|
|
9
9
|
|
|
10
|
-
after { github
|
|
10
|
+
after { reset_authentication_for(github) }
|
|
11
11
|
|
|
12
|
-
describe "#
|
|
13
|
-
|
|
14
|
-
it { github.gists.should respond_to :comments }
|
|
15
|
-
it { github.gists.should respond_to :list_comments }
|
|
16
|
-
end
|
|
12
|
+
describe "#list" do
|
|
13
|
+
it { github.gists.comments.should respond_to :all }
|
|
17
14
|
|
|
18
15
|
context 'resource found' do
|
|
19
16
|
before do
|
|
@@ -24,33 +21,33 @@ describe Github::Gists::Comments do
|
|
|
24
21
|
end
|
|
25
22
|
|
|
26
23
|
it "throws error if gist id not provided" do
|
|
27
|
-
expect { github.gists.comments nil}.to raise_error(ArgumentError)
|
|
24
|
+
expect { github.gists.comments.list nil}.to raise_error(ArgumentError)
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
it "should get the resources" do
|
|
31
|
-
github.gists.comments gist_id
|
|
28
|
+
github.gists.comments.list gist_id
|
|
32
29
|
a_get("/gists/#{gist_id}/comments").should have_been_made
|
|
33
30
|
end
|
|
34
31
|
|
|
35
32
|
it "should return array of resources" do
|
|
36
|
-
comments = github.gists.comments gist_id
|
|
33
|
+
comments = github.gists.comments.list gist_id
|
|
37
34
|
comments.should be_an Array
|
|
38
35
|
comments.should have(1).items
|
|
39
36
|
end
|
|
40
37
|
|
|
41
38
|
it "should be a mash type" do
|
|
42
|
-
comments = github.gists.comments gist_id
|
|
39
|
+
comments = github.gists.comments.list gist_id
|
|
43
40
|
comments.first.should be_a Hashie::Mash
|
|
44
41
|
end
|
|
45
42
|
|
|
46
43
|
it "should get gist information" do
|
|
47
|
-
comments = github.gists.comments gist_id
|
|
44
|
+
comments = github.gists.comments.list gist_id
|
|
48
45
|
comments.first.user.login.should == 'octocat'
|
|
49
46
|
end
|
|
50
47
|
|
|
51
48
|
it "should yield to a block" do
|
|
52
|
-
github.gists.should_receive(:
|
|
53
|
-
github.gists.comments(gist_id) { |param| 'web' }
|
|
49
|
+
github.gists.comments.should_receive(:list).with(gist_id).and_yield('web')
|
|
50
|
+
github.gists.comments.list(gist_id) { |param| 'web' }
|
|
54
51
|
end
|
|
55
52
|
end
|
|
56
53
|
|
|
@@ -62,17 +59,14 @@ describe Github::Gists::Comments do
|
|
|
62
59
|
|
|
63
60
|
it "should return 404 with a message 'Not Found'" do
|
|
64
61
|
expect {
|
|
65
|
-
github.gists.comments gist_id
|
|
62
|
+
github.gists.comments.list gist_id
|
|
66
63
|
}.to raise_error(Github::Error::NotFound)
|
|
67
64
|
end
|
|
68
65
|
end
|
|
69
|
-
end #
|
|
66
|
+
end # list
|
|
70
67
|
|
|
71
|
-
describe "#
|
|
72
|
-
|
|
73
|
-
it { github.gists.should respond_to :comment }
|
|
74
|
-
it { github.gists.should respond_to :get_comment }
|
|
75
|
-
end
|
|
68
|
+
describe "#get" do
|
|
69
|
+
it { github.gists.should respond_to :find }
|
|
76
70
|
|
|
77
71
|
context 'resource found' do
|
|
78
72
|
before do
|
|
@@ -83,22 +77,22 @@ describe Github::Gists::Comments do
|
|
|
83
77
|
end
|
|
84
78
|
|
|
85
79
|
it "should fail to get resource without comment id" do
|
|
86
|
-
expect { github.gists.
|
|
80
|
+
expect { github.gists.comments.get nil }.to raise_error(ArgumentError)
|
|
87
81
|
end
|
|
88
82
|
|
|
89
83
|
it "should get the resource" do
|
|
90
|
-
github.gists.
|
|
84
|
+
github.gists.comments.get comment_id
|
|
91
85
|
a_get("/gists/comments/#{comment_id}").should have_been_made
|
|
92
86
|
end
|
|
93
87
|
|
|
94
88
|
it "should get comment information" do
|
|
95
|
-
comment = github.gists.
|
|
89
|
+
comment = github.gists.comments.get comment_id
|
|
96
90
|
comment.id.should eq comment_id
|
|
97
91
|
comment.user.login.should == 'octocat'
|
|
98
92
|
end
|
|
99
93
|
|
|
100
94
|
it "should return mash" do
|
|
101
|
-
comment = github.gists.
|
|
95
|
+
comment = github.gists.comments.get comment_id
|
|
102
96
|
comment.should be_a Hashie::Mash
|
|
103
97
|
end
|
|
104
98
|
end
|
|
@@ -113,13 +107,13 @@ describe Github::Gists::Comments do
|
|
|
113
107
|
|
|
114
108
|
it "should fail to retrive resource" do
|
|
115
109
|
expect {
|
|
116
|
-
github.gists.
|
|
110
|
+
github.gists.comments.get comment_id
|
|
117
111
|
}.to raise_error(Github::Error::NotFound)
|
|
118
112
|
end
|
|
119
113
|
end
|
|
120
|
-
end #
|
|
114
|
+
end # get
|
|
121
115
|
|
|
122
|
-
describe "#
|
|
116
|
+
describe "#create" do
|
|
123
117
|
let(:inputs) {
|
|
124
118
|
{ "body" =>"Just commenting for the sake of commenting", "unrelated" => true }
|
|
125
119
|
}
|
|
@@ -135,22 +129,22 @@ describe Github::Gists::Comments do
|
|
|
135
129
|
|
|
136
130
|
it "should fail to create resource if 'content' input is missing" do
|
|
137
131
|
expect {
|
|
138
|
-
github.gists.
|
|
132
|
+
github.gists.comments.create gist_id, inputs.except('body')
|
|
139
133
|
}.to raise_error(Github::Error::RequiredParams)
|
|
140
134
|
end
|
|
141
135
|
|
|
142
136
|
it "should create resource successfully" do
|
|
143
|
-
github.gists.
|
|
137
|
+
github.gists.comments.create gist_id, inputs
|
|
144
138
|
a_post("/gists/#{gist_id}/comments").with(inputs).should have_been_made
|
|
145
139
|
end
|
|
146
140
|
|
|
147
141
|
it "should return the resource" do
|
|
148
|
-
comment = github.gists.
|
|
142
|
+
comment = github.gists.comments.create gist_id, inputs
|
|
149
143
|
comment.should be_a Hashie::Mash
|
|
150
144
|
end
|
|
151
145
|
|
|
152
146
|
it "should get the comment information" do
|
|
153
|
-
comment = github.gists.
|
|
147
|
+
comment = github.gists.comments.create gist_id, inputs
|
|
154
148
|
comment.user.login.should == 'octocat'
|
|
155
149
|
end
|
|
156
150
|
end
|
|
@@ -165,13 +159,13 @@ describe Github::Gists::Comments do
|
|
|
165
159
|
|
|
166
160
|
it "should faile to retrieve resource" do
|
|
167
161
|
expect {
|
|
168
|
-
github.gists.
|
|
162
|
+
github.gists.comments.create gist_id, inputs
|
|
169
163
|
}.to raise_error(Github::Error::NotFound)
|
|
170
164
|
end
|
|
171
165
|
end
|
|
172
|
-
end #
|
|
166
|
+
end # create
|
|
173
167
|
|
|
174
|
-
describe "#
|
|
168
|
+
describe "#edit" do
|
|
175
169
|
let(:inputs) {
|
|
176
170
|
{ "body" =>"Just commenting for the sake of commenting", "unrelated" => true }
|
|
177
171
|
}
|
|
@@ -187,22 +181,22 @@ describe Github::Gists::Comments do
|
|
|
187
181
|
|
|
188
182
|
it "should fail to create resource if 'content' input is missing" do
|
|
189
183
|
expect {
|
|
190
|
-
github.gists.
|
|
184
|
+
github.gists.comments.edit comment_id, inputs.except('body')
|
|
191
185
|
}.to raise_error(Github::Error::RequiredParams)
|
|
192
186
|
end
|
|
193
187
|
|
|
194
188
|
it "should create resource successfully" do
|
|
195
|
-
github.gists.
|
|
189
|
+
github.gists.comments.edit comment_id, inputs
|
|
196
190
|
a_patch("/gists/comments/#{comment_id}").with(inputs).should have_been_made
|
|
197
191
|
end
|
|
198
192
|
|
|
199
193
|
it "should return the resource" do
|
|
200
|
-
comment = github.gists.
|
|
194
|
+
comment = github.gists.comments.edit comment_id, inputs
|
|
201
195
|
comment.should be_a Hashie::Mash
|
|
202
196
|
end
|
|
203
197
|
|
|
204
198
|
it "should get the comment information" do
|
|
205
|
-
comment = github.gists.
|
|
199
|
+
comment = github.gists.comments.edit comment_id, inputs
|
|
206
200
|
comment.user.login.should == 'octocat'
|
|
207
201
|
end
|
|
208
202
|
end
|
|
@@ -217,13 +211,13 @@ describe Github::Gists::Comments do
|
|
|
217
211
|
|
|
218
212
|
it "should faile to retrieve resource" do
|
|
219
213
|
expect {
|
|
220
|
-
github.gists.
|
|
214
|
+
github.gists.comments.edit comment_id, inputs
|
|
221
215
|
}.to raise_error(Github::Error::NotFound)
|
|
222
216
|
end
|
|
223
217
|
end
|
|
224
|
-
end #
|
|
218
|
+
end # edit
|
|
225
219
|
|
|
226
|
-
describe "#
|
|
220
|
+
describe "#delete" do
|
|
227
221
|
context "resouce deleted" do
|
|
228
222
|
before do
|
|
229
223
|
stub_delete("/gists/comments/#{comment_id}").
|
|
@@ -233,11 +227,11 @@ describe Github::Gists::Comments do
|
|
|
233
227
|
end
|
|
234
228
|
|
|
235
229
|
it "should fail to create resource if 'content' input is missing" do
|
|
236
|
-
expect { github.gists.
|
|
230
|
+
expect { github.gists.comments.delete nil }.to raise_error(ArgumentError)
|
|
237
231
|
end
|
|
238
232
|
|
|
239
233
|
it "should create resource successfully" do
|
|
240
|
-
github.gists.
|
|
234
|
+
github.gists.comments.delete comment_id
|
|
241
235
|
a_delete("/gists/comments/#{comment_id}").should have_been_made
|
|
242
236
|
end
|
|
243
237
|
end
|
|
@@ -252,10 +246,10 @@ describe Github::Gists::Comments do
|
|
|
252
246
|
|
|
253
247
|
it "should faile to retrieve resource" do
|
|
254
248
|
expect {
|
|
255
|
-
github.gists.
|
|
249
|
+
github.gists.comments.delete comment_id
|
|
256
250
|
}.to raise_error(Github::Error::NotFound)
|
|
257
251
|
end
|
|
258
252
|
end
|
|
259
|
-
end #
|
|
253
|
+
end # delete
|
|
260
254
|
|
|
261
255
|
end # Github::Gists::Comments
|
data/spec/github/gists_spec.rb
CHANGED
|
@@ -7,45 +7,43 @@ describe Github::Gists do
|
|
|
7
7
|
let(:user) { 'peter-murach' }
|
|
8
8
|
let(:gist_id) { '1' }
|
|
9
9
|
|
|
10
|
-
after { github
|
|
10
|
+
after { reset_authentication_for(github) }
|
|
11
11
|
|
|
12
|
-
describe "#
|
|
13
|
-
|
|
14
|
-
it { github.gists.should respond_to :gists }
|
|
15
|
-
it { github.gists.should respond_to :list_gists }
|
|
16
|
-
end
|
|
12
|
+
describe "#list" do
|
|
13
|
+
it { github.gists.should respond_to :all }
|
|
17
14
|
|
|
18
15
|
context "- unauthenticated user" do
|
|
19
16
|
context "resource found" do
|
|
20
17
|
before do
|
|
21
18
|
stub_get("/users/#{user}/gists").
|
|
22
|
-
to_return(:body => fixture('gists/gists.json'), :status => 200,
|
|
19
|
+
to_return(:body => fixture('gists/gists.json'), :status => 200,
|
|
20
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
23
21
|
end
|
|
24
22
|
|
|
25
23
|
it "should get the resources" do
|
|
26
|
-
github.gists.
|
|
24
|
+
github.gists.list user
|
|
27
25
|
a_get("/users/#{user}/gists").should have_been_made
|
|
28
26
|
end
|
|
29
27
|
|
|
30
28
|
it "should return array of resources" do
|
|
31
|
-
gists = github.gists.
|
|
29
|
+
gists = github.gists.list user
|
|
32
30
|
gists.should be_an Array
|
|
33
31
|
gists.should have(1).items
|
|
34
32
|
end
|
|
35
33
|
|
|
36
34
|
it "should be a mash type" do
|
|
37
|
-
gists = github.gists.
|
|
35
|
+
gists = github.gists.list user
|
|
38
36
|
gists.first.should be_a Hashie::Mash
|
|
39
37
|
end
|
|
40
38
|
|
|
41
39
|
it "should get gist information" do
|
|
42
|
-
gists = github.gists.
|
|
40
|
+
gists = github.gists.list user
|
|
43
41
|
gists.first.user.login.should == 'octocat'
|
|
44
42
|
end
|
|
45
43
|
|
|
46
44
|
it "should yield to a block" do
|
|
47
|
-
github.gists.should_receive(:
|
|
48
|
-
github.gists.
|
|
45
|
+
github.gists.should_receive(:list).with(user).and_yield('web')
|
|
46
|
+
github.gists.list(user) { |param| 'web' }
|
|
49
47
|
end
|
|
50
48
|
end
|
|
51
49
|
|
|
@@ -57,7 +55,7 @@ describe Github::Gists do
|
|
|
57
55
|
|
|
58
56
|
it "should return 404 with a message 'Not Found'" do
|
|
59
57
|
expect {
|
|
60
|
-
github.gists.
|
|
58
|
+
github.gists.list user
|
|
61
59
|
}.to raise_error(Github::Error::NotFound)
|
|
62
60
|
end
|
|
63
61
|
end
|
|
@@ -66,11 +64,12 @@ describe Github::Gists do
|
|
|
66
64
|
context '- public' do
|
|
67
65
|
before do
|
|
68
66
|
stub_get("/gists/public").
|
|
69
|
-
to_return(:body => fixture('gists/gists.json'), :status => 200,
|
|
67
|
+
to_return(:body => fixture('gists/gists.json'), :status => 200,
|
|
68
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
70
69
|
end
|
|
71
70
|
|
|
72
71
|
it "should get the resources" do
|
|
73
|
-
github.gists.
|
|
72
|
+
github.gists.list
|
|
74
73
|
a_get("/gists/public").should have_been_made
|
|
75
74
|
end
|
|
76
75
|
end
|
|
@@ -82,15 +81,15 @@ describe Github::Gists do
|
|
|
82
81
|
with(:query => {:access_token => OAUTH_TOKEN}).
|
|
83
82
|
to_return(:body => fixture('gists/gists.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
84
83
|
end
|
|
85
|
-
after { github.oauth_token = nil }
|
|
84
|
+
# after { github.oauth_token = nil }
|
|
86
85
|
|
|
87
86
|
it "should get the resources" do
|
|
88
|
-
github.gists.
|
|
87
|
+
github.gists.list
|
|
89
88
|
a_get("/gists").with(:query => {:access_token => OAUTH_TOKEN}).
|
|
90
89
|
should have_been_made
|
|
91
90
|
end
|
|
92
91
|
end
|
|
93
|
-
end #
|
|
92
|
+
end # list
|
|
94
93
|
|
|
95
94
|
describe "#starred" do
|
|
96
95
|
context "resource found" do
|
|
@@ -140,35 +139,33 @@ describe Github::Gists do
|
|
|
140
139
|
end
|
|
141
140
|
end # starred
|
|
142
141
|
|
|
143
|
-
describe "#
|
|
144
|
-
|
|
145
|
-
it { github.gists.should respond_to :gist }
|
|
146
|
-
it { github.gists.should respond_to :get_gist }
|
|
147
|
-
end
|
|
142
|
+
describe "#get" do
|
|
143
|
+
it { github.gists.should respond_to :find }
|
|
148
144
|
|
|
149
145
|
context "resource found" do
|
|
150
146
|
before do
|
|
151
147
|
stub_get("/gists/#{gist_id}").
|
|
152
|
-
to_return(:body => fixture('gists/gist.json'), :status => 200,
|
|
148
|
+
to_return(:body => fixture('gists/gist.json'), :status => 200,
|
|
149
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
153
150
|
end
|
|
154
151
|
|
|
155
152
|
it "should fail to get resource without gist id" do
|
|
156
|
-
expect { github.gists.
|
|
153
|
+
expect { github.gists.get nil }.to raise_error(ArgumentError)
|
|
157
154
|
end
|
|
158
155
|
|
|
159
156
|
it "should get the resource" do
|
|
160
|
-
github.gists.
|
|
157
|
+
github.gists.get gist_id
|
|
161
158
|
a_get("/gists/#{gist_id}").should have_been_made
|
|
162
159
|
end
|
|
163
160
|
|
|
164
161
|
it "should get gist information" do
|
|
165
|
-
gist = github.gists.
|
|
162
|
+
gist = github.gists.get gist_id
|
|
166
163
|
gist.id.should eq gist_id
|
|
167
164
|
gist.user.login.should == 'octocat'
|
|
168
165
|
end
|
|
169
166
|
|
|
170
167
|
it "should return mash" do
|
|
171
|
-
gist = github.gists.
|
|
168
|
+
gist = github.gists.get gist_id
|
|
172
169
|
gist.should be_a Hashie::Mash
|
|
173
170
|
end
|
|
174
171
|
end
|
|
@@ -181,13 +178,13 @@ describe Github::Gists do
|
|
|
181
178
|
|
|
182
179
|
it "should fail to retrive resource" do
|
|
183
180
|
expect {
|
|
184
|
-
github.gists.
|
|
181
|
+
github.gists.get gist_id
|
|
185
182
|
}.to raise_error(Github::Error::NotFound)
|
|
186
183
|
end
|
|
187
184
|
end
|
|
188
|
-
end #
|
|
185
|
+
end # get
|
|
189
186
|
|
|
190
|
-
describe "#
|
|
187
|
+
describe "#create" do
|
|
191
188
|
let(:inputs) {
|
|
192
189
|
{
|
|
193
190
|
"description" => "the description for this gist",
|
|
@@ -211,35 +208,35 @@ describe Github::Gists do
|
|
|
211
208
|
|
|
212
209
|
it "should fail to create resource if 'files' input is missing" do
|
|
213
210
|
expect {
|
|
214
|
-
github.gists.
|
|
211
|
+
github.gists.create inputs.except('files')
|
|
215
212
|
}.to raise_error(Github::Error::RequiredParams)
|
|
216
213
|
end
|
|
217
214
|
|
|
218
215
|
it "should fail to create resource if 'content' input is missing" do
|
|
219
216
|
pending 'add validation for nested attributes'
|
|
220
217
|
expect {
|
|
221
|
-
github.gists.
|
|
218
|
+
github.gists.create inputs.except('content')
|
|
222
219
|
}.to raise_error(Github::Error::RequiredParams)
|
|
223
220
|
end
|
|
224
221
|
|
|
225
222
|
it "should fail to create resource if 'public' input is missing" do
|
|
226
223
|
expect {
|
|
227
|
-
github.gists.
|
|
224
|
+
github.gists.create inputs.except('public')
|
|
228
225
|
}.to raise_error(Github::Error::RequiredParams)
|
|
229
226
|
end
|
|
230
227
|
|
|
231
228
|
it "should create resource successfully" do
|
|
232
|
-
github.gists.
|
|
229
|
+
github.gists.create inputs
|
|
233
230
|
a_post("/gists").with(inputs).should have_been_made
|
|
234
231
|
end
|
|
235
232
|
|
|
236
233
|
it "should return the resource" do
|
|
237
|
-
gist = github.gists.
|
|
234
|
+
gist = github.gists.create inputs
|
|
238
235
|
gist.should be_a Hashie::Mash
|
|
239
236
|
end
|
|
240
237
|
|
|
241
238
|
it "should get the gist information" do
|
|
242
|
-
gist = github.gists.
|
|
239
|
+
gist = github.gists.create inputs
|
|
243
240
|
gist.user.login.should == 'octocat'
|
|
244
241
|
end
|
|
245
242
|
end
|
|
@@ -254,13 +251,13 @@ describe Github::Gists do
|
|
|
254
251
|
|
|
255
252
|
it "should faile to retrieve resource" do
|
|
256
253
|
expect {
|
|
257
|
-
github.gists.
|
|
254
|
+
github.gists.create inputs
|
|
258
255
|
}.to raise_error(Github::Error::NotFound)
|
|
259
256
|
end
|
|
260
257
|
end
|
|
261
|
-
end #
|
|
258
|
+
end # create
|
|
262
259
|
|
|
263
|
-
describe "#
|
|
260
|
+
describe "#edit" do
|
|
264
261
|
let(:inputs) {
|
|
265
262
|
{
|
|
266
263
|
"description" => "the description for this gist",
|
|
@@ -290,17 +287,17 @@ describe Github::Gists do
|
|
|
290
287
|
end
|
|
291
288
|
|
|
292
289
|
it "should edit resource successfully" do
|
|
293
|
-
github.gists.
|
|
290
|
+
github.gists.edit gist_id, inputs
|
|
294
291
|
a_patch("/gists/#{gist_id}").with(inputs).should have_been_made
|
|
295
292
|
end
|
|
296
293
|
|
|
297
294
|
it "should return the resource" do
|
|
298
|
-
gist = github.gists.
|
|
295
|
+
gist = github.gists.edit gist_id, inputs
|
|
299
296
|
gist.should be_a Hashie::Mash
|
|
300
297
|
end
|
|
301
298
|
|
|
302
299
|
it "should get the gist information" do
|
|
303
|
-
gist = github.gists.
|
|
300
|
+
gist = github.gists.edit gist_id, inputs
|
|
304
301
|
gist.user.login.should == 'octocat'
|
|
305
302
|
end
|
|
306
303
|
end
|
|
@@ -315,11 +312,11 @@ describe Github::Gists do
|
|
|
315
312
|
|
|
316
313
|
it "should fail to retrieve resource" do
|
|
317
314
|
expect {
|
|
318
|
-
github.gists.
|
|
315
|
+
github.gists.edit gist_id, inputs
|
|
319
316
|
}.to raise_error(Github::Error::NotFound)
|
|
320
317
|
end
|
|
321
318
|
end
|
|
322
|
-
end #
|
|
319
|
+
end # edit
|
|
323
320
|
|
|
324
321
|
context '#star' do
|
|
325
322
|
before do
|
|
@@ -336,7 +333,7 @@ describe Github::Gists do
|
|
|
336
333
|
end
|
|
337
334
|
|
|
338
335
|
it 'successfully stars a gist' do
|
|
339
|
-
github.gists.star
|
|
336
|
+
github.gists.star gist_id
|
|
340
337
|
a_put("/gists/#{gist_id}/star").should have_been_made
|
|
341
338
|
end
|
|
342
339
|
|
|
@@ -360,7 +357,7 @@ describe Github::Gists do
|
|
|
360
357
|
end
|
|
361
358
|
|
|
362
359
|
it 'successfully stars a gist' do
|
|
363
|
-
github.gists.unstar
|
|
360
|
+
github.gists.unstar gist_id
|
|
364
361
|
a_delete("/gists/#{gist_id}/star").should have_been_made
|
|
365
362
|
end
|
|
366
363
|
|
|
@@ -440,7 +437,7 @@ describe Github::Gists do
|
|
|
440
437
|
end
|
|
441
438
|
end # fork
|
|
442
439
|
|
|
443
|
-
context "#
|
|
440
|
+
context "#delete" do
|
|
444
441
|
before do
|
|
445
442
|
stub_delete("/gists/#{gist_id}").
|
|
446
443
|
to_return(:body => fixture('gists/gist.json'),
|
|
@@ -450,12 +447,12 @@ describe Github::Gists do
|
|
|
450
447
|
|
|
451
448
|
it 'should raise error if gist id not present' do
|
|
452
449
|
expect {
|
|
453
|
-
github.gists.
|
|
450
|
+
github.gists.delete nil
|
|
454
451
|
}.to raise_error(ArgumentError)
|
|
455
452
|
end
|
|
456
453
|
|
|
457
454
|
it "should remove resource successfully" do
|
|
458
|
-
github.gists.
|
|
455
|
+
github.gists.delete gist_id
|
|
459
456
|
a_delete("/gists/#{gist_id}").should have_been_made
|
|
460
457
|
end
|
|
461
458
|
|
|
@@ -465,9 +462,9 @@ describe Github::Gists do
|
|
|
465
462
|
:status => 404,
|
|
466
463
|
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
467
464
|
expect {
|
|
468
|
-
github.gists.
|
|
465
|
+
github.gists.delete gist_id
|
|
469
466
|
}.to raise_error(Github::Error::NotFound)
|
|
470
467
|
end
|
|
471
|
-
end #
|
|
468
|
+
end # delete
|
|
472
469
|
|
|
473
470
|
end # Github::Gists
|