github_api 0.4.3 → 0.4.4

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.
@@ -121,14 +121,22 @@ describe Github::Repos::Hooks, :type => :base do
121
121
  let(:inputs) {
122
122
  {
123
123
  :name => 'web',
124
- :config => { :url => "http://something.com/webhook" },
125
- :active => true
124
+ :config => {
125
+ :url => "http://something.com/webhook",
126
+ :address => "test@example.com",
127
+ :subdomain => "github",
128
+ :room => "Commits",
129
+ :token => "abc123"
130
+ },
131
+ :active => true,
132
+ :unrelated => true
126
133
  }
127
134
  }
128
135
 
129
136
  context "resouce created" do
130
137
  before do
131
- stub_post("/repos/#{user}/#{repo}/hooks").with(inputs).
138
+ stub_post("/repos/#{user}/#{repo}/hooks").
139
+ with(:body => JSON.generate(inputs.except(:unrelated))).
132
140
  to_return(:body => fixture('repos/hook.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
133
141
  end
134
142
 
@@ -179,14 +187,22 @@ describe Github::Repos::Hooks, :type => :base do
179
187
  let(:inputs) {
180
188
  {
181
189
  :name => 'web',
182
- :config => { :url => "http://something.com/webhook" },
183
- :active => true
190
+ :config => {
191
+ :url => "http://something.com/webhook",
192
+ :address => "test@example.com",
193
+ :subdomain => "github",
194
+ :room => "Commits",
195
+ :token => "abc123"
196
+ },
197
+ :active => true,
198
+ :unrelated => true
184
199
  }
185
200
  }
186
201
 
187
202
  context "resource edited successfully" do
188
203
  before do
189
- stub_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").with(inputs).
204
+ stub_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").
205
+ with(:body => JSON.generate(inputs.except(:unrelated))).
190
206
  to_return(:body => fixture("repos/hook.json"), :status => 200, :headers => { :content_type => "application/json; charset=utf-8"})
191
207
  end
192
208
 
@@ -22,6 +22,7 @@ describe Github::Result do
22
22
  'content-length' => '344',
23
23
  'etag' => "\"d9a88f20567726e29d35c6fae87cef2f\"",
24
24
  'server' => "nginx/1.0.4",
25
+ 'Date' => "Sun, 05 Feb 2012 15:02:34 GMT",
25
26
  'Link' => link
26
27
  })
27
28
 
@@ -36,6 +37,7 @@ describe Github::Result do
36
37
  'X-RateLimit-Remaining' => '4999',
37
38
  'X-RateLimit-Limit' => '5000',
38
39
  'content-length' => '344',
40
+ 'Date' => "Sun, 05 Feb 2012 15:02:34 GMT",
39
41
  'Link' => link
40
42
  })
41
43
  end
@@ -65,6 +67,10 @@ describe Github::Result do
65
67
  res.etag.should eql "\"d9a88f20567726e29d35c6fae87cef2f\""
66
68
  end
67
69
 
70
+ it 'should read response date' do
71
+ res.date.should eql "Sun, 05 Feb 2012 15:02:34 GMT"
72
+ end
73
+
68
74
  it 'should read response server' do
69
75
  res.server.should eql "nginx/1.0.4"
70
76
  end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe Github::Validation, :type => :base do
4
+
5
+ context '#_validate_inputs' do
6
+ before do
7
+ @required = ['param_a', 'param_c']
8
+ @provided = { 'param_a' => true, 'param_c' => true }
9
+ end
10
+
11
+ it 'detect missing parameter' do
12
+ github._validate_inputs(@required, @provided.except('param_c')).should be_false
13
+ end
14
+
15
+ it 'asserts correct required parameters' do
16
+ github._validate_inputs(@required, @provided).should be_true
17
+ end
18
+ end
19
+
20
+ context '#_validate_presence_of' do
21
+ it 'throws error if passed param is nil' do
22
+ gist_id = nil
23
+ expect {
24
+ github._validate_presence_of gist_id
25
+ }.to raise_error(ArgumentError)
26
+ end
27
+ end
28
+
29
+ context '#_validate_params_values' do
30
+ let(:permitted) {
31
+ {
32
+ 'param_a' => ['a', 'b'],
33
+ 'param_b' => /^github$/
34
+ }
35
+ }
36
+
37
+ it 'fails to accept unkown value for a given parameter key' do
38
+ actual = { 'param_a' => 'x' }
39
+ expect {
40
+ github._validate_params_values(permitted, actual)
41
+ }.to raise_error(ArgumentError)
42
+ end
43
+
44
+ it 'accepts known value for a given parameter key' do
45
+ actual = { 'param_a' => 'a'}
46
+ github._validate_params_values(permitted, actual)
47
+ end
48
+
49
+ it 'fails to match regex value for a given parameter key' do
50
+ actual = { 'param_b' => 'xgithub' }
51
+ expect {
52
+ github._validate_params_values(permitted, actual)
53
+ }.to raise_error(ArgumentError)
54
+ end
55
+
56
+ it 'matches regex value for a given parameter key' do
57
+ actual = { 'param_b' => 'github'}
58
+ github._validate_params_values(permitted, actual)
59
+ end
60
+ end
61
+ end # Github::Validation
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: github_api
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.3
5
+ version: 0.4.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Piotr Murach
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-02-04 00:00:00 +00:00
13
+ date: 2012-02-09 00:00:00 +00:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -179,6 +179,8 @@ files:
179
179
  - Rakefile
180
180
  - features/authentication.feature
181
181
  - features/cassettes/errors/repos/create.yml
182
+ - features/cassettes/gists/comments/all.yml
183
+ - features/cassettes/gists/comments/first.yml
182
184
  - features/cassettes/gists/gist/first.yml
183
185
  - features/cassettes/gists/gist.yml
184
186
  - features/cassettes/gists/gists/public_all.yml
@@ -199,6 +201,7 @@ files:
199
201
  - features/cassettes/repos/tags.yml
200
202
  - features/cassettes/repos/teams.yml
201
203
  - features/error_codes.feature
204
+ - features/gists/comments.feature
202
205
  - features/gists.feature
203
206
  - features/github_api.feature
204
207
  - features/options.feature
@@ -212,6 +215,7 @@ files:
212
215
  - features/support/vcr.rb
213
216
  - lib/github_api/api/actions.rb
214
217
  - lib/github_api/api.rb
218
+ - lib/github_api/api_factory.rb
215
219
  - lib/github_api/authorization.rb
216
220
  - lib/github_api/authorizations.rb
217
221
  - lib/github_api/cache_control.rb
@@ -225,6 +229,7 @@ files:
225
229
  - lib/github_api/deprecation.rb
226
230
  - lib/github_api/error.rb
227
231
  - lib/github_api/events.rb
232
+ - lib/github_api/filter.rb
228
233
  - lib/github_api/gists/comments.rb
229
234
  - lib/github_api/gists.rb
230
235
  - lib/github_api/git_data/blobs.rb
@@ -248,6 +253,7 @@ files:
248
253
  - lib/github_api/paged_request.rb
249
254
  - lib/github_api/pull_requests/comments.rb
250
255
  - lib/github_api/pull_requests.rb
256
+ - lib/github_api/ratelimit_status.rb
251
257
  - lib/github_api/repos/collaborators.rb
252
258
  - lib/github_api/repos/commits.rb
253
259
  - lib/github_api/repos/downloads.rb
@@ -272,12 +278,15 @@ files:
272
278
  - lib/github_api/users/keys.rb
273
279
  - lib/github_api/users.rb
274
280
  - lib/github_api/utils/url.rb
281
+ - lib/github_api/validation.rb
275
282
  - lib/github_api/version.rb
276
283
  - lib/github_api.rb
277
284
  - spec/coverage_adapter.rb
278
285
  - spec/fixtures/auths/authorization.json
279
286
  - spec/fixtures/auths/authorizations.json
280
287
  - spec/fixtures/events/events.json
288
+ - spec/fixtures/gists/comment.json
289
+ - spec/fixtures/gists/comments.json
281
290
  - spec/fixtures/gists/gist.json
282
291
  - spec/fixtures/gists/gists.json
283
292
  - spec/fixtures/git_data/blob.json
@@ -328,6 +337,7 @@ files:
328
337
  - spec/fixtures/repos/watched.json
329
338
  - spec/fixtures/repos/watchers.json
330
339
  - spec/fixtures/users/user.json
340
+ - spec/github/api_factory_spec.rb
331
341
  - spec/github/api_spec.rb
332
342
  - spec/github/authorization_spec.rb
333
343
  - spec/github/authorizations_spec.rb
@@ -335,6 +345,7 @@ files:
335
345
  - spec/github/core_ext/hash_spec.rb
336
346
  - spec/github/deprecation_spec.rb
337
347
  - spec/github/events_spec.rb
348
+ - spec/github/filter_spec.rb
338
349
  - spec/github/gists/comments_spec.rb
339
350
  - spec/github/gists_spec.rb
340
351
  - spec/github/git_data/blobs_spec.rb
@@ -369,6 +380,7 @@ files:
369
380
  - spec/github/result_spec.rb
370
381
  - spec/github/users_spec.rb
371
382
  - spec/github/utils/url_spec.rb
383
+ - spec/github/validation_spec.rb
372
384
  - spec/github_spec.rb
373
385
  - spec/README.rdoc
374
386
  - spec/spec_helper.rb