github_api 0.4.8 → 0.4.9
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/lib/github_api/version.rb +1 -1
- data/spec/github/mime_type_spec.rb +64 -64
- data/spec/github/request_spec.rb +1 -1
- metadata +5 -9
- data/features/authentication.feature +0 -8
- data/lib/github_api/cache_control.rb +0 -19
- data/lib/github_api/request/caching.rb +0 -33
- data/spec/support/github_api_shared_examples.rb +0 -40
data/lib/github_api/version.rb
CHANGED
@@ -2,69 +2,69 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Github::MimeType do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
5
|
+
let(:github) { Github.new }
|
6
|
+
|
7
|
+
it "should lookup mime type for :full" do
|
8
|
+
github.lookup_mime(:full).should == 'full+json'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should lookup mime type for :html" do
|
12
|
+
github.lookup_mime(:html).should == 'html+json'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should lookup mime type for :html" do
|
16
|
+
github.lookup_mime(:text).should == 'text+json'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should lookup mime type for :raw" do
|
20
|
+
github.lookup_mime(:raw).should == 'raw+json'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should default to json if no parameters given" do
|
24
|
+
Github.should_receive(:parse).and_return 'application/json'
|
25
|
+
Github.parse.should == 'application/json'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should accept header for 'issue' request" do
|
29
|
+
Github.should_receive(:parse).with(:issue, :full).
|
30
|
+
and_return 'application/vnd.github-issue.full+json'
|
31
|
+
Github.parse(:issue, :full).should == 'application/vnd.github-issue.full+json'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should accept header for 'isssue comment' request" do
|
35
|
+
Github.should_receive(:parse).with(:issue_comment, :full).
|
36
|
+
and_return 'application/vnd.github-issuecomment.full+json'
|
37
|
+
Github.parse(:issue_comment, :full).should == 'application/vnd.github-issuecomment.full+json'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should accept header for 'commit comment' request" do
|
41
|
+
Github.should_receive(:parse).with(:commit_comment, :full).
|
42
|
+
and_return 'application/vnd.github-commitcomment.full+json'
|
43
|
+
Github.parse(:commit_comment, :full).should == 'application/vnd.github-commitcomment.full+json'
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should accept header for 'pull requst' request" do
|
47
|
+
Github.should_receive(:parse).with(:pull_request, :full).
|
48
|
+
and_return 'application/vnd.github-pull.full+json'
|
49
|
+
Github.parse(:pull_request, :full).should == 'application/vnd.github-pull.full+json'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should accept header for 'pull comment' request" do
|
53
|
+
Github.should_receive(:parse).with(:pull_comment, :full).
|
54
|
+
and_return 'application/vnd.github-pullcomment.full+json'
|
55
|
+
Github.parse(:pull_comment, :full).should == 'application/vnd.github-pullcomment.full+json'
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should accept header for 'gist comment' request" do
|
59
|
+
Github.should_receive(:parse).with(:gist_comment, :full).
|
60
|
+
and_return 'application/vnd.github-gistcomment.full+json'
|
61
|
+
Github.parse(:gist_comment, :full).should == 'application/vnd.github-gistcomment.full+json'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should accept header for 'blog' request" do
|
65
|
+
Github.should_receive(:parse).with(:blob, :blob).
|
66
|
+
and_return 'application/vnd.github-blob.raw'
|
67
|
+
Github.parse(:blob, :blob).should == 'application/vnd.github-blob.raw'
|
68
|
+
end
|
69
69
|
|
70
70
|
end # Github::MimeType
|
data/spec/github/request_spec.rb
CHANGED
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.
|
5
|
+
version: 0.4.9
|
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-
|
13
|
+
date: 2012-04-09 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.
|
46
|
+
version: "1.0"
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id003
|
49
49
|
- !ruby/object:Gem::Dependency
|
@@ -63,9 +63,9 @@ dependencies:
|
|
63
63
|
requirement: &id005 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: "0"
|
69
69
|
type: :development
|
70
70
|
version_requirements: *id005
|
71
71
|
- !ruby/object:Gem::Dependency
|
@@ -188,7 +188,6 @@ extra_rdoc_files: []
|
|
188
188
|
|
189
189
|
files:
|
190
190
|
- Rakefile
|
191
|
-
- features/authentication.feature
|
192
191
|
- features/cassettes/errors/repos/create.yml
|
193
192
|
- features/cassettes/gists/comments/all.yml
|
194
193
|
- features/cassettes/gists/comments/first.yml
|
@@ -226,7 +225,6 @@ files:
|
|
226
225
|
- lib/github_api/api_factory.rb
|
227
226
|
- lib/github_api/authorization.rb
|
228
227
|
- lib/github_api/authorizations.rb
|
229
|
-
- lib/github_api/cache_control.rb
|
230
228
|
- lib/github_api/client.rb
|
231
229
|
- lib/github_api/compatibility.rb
|
232
230
|
- lib/github_api/configuration.rb
|
@@ -284,7 +282,6 @@ files:
|
|
284
282
|
- lib/github_api/repos/watching.rb
|
285
283
|
- lib/github_api/repos.rb
|
286
284
|
- lib/github_api/request/basic_auth.rb
|
287
|
-
- lib/github_api/request/caching.rb
|
288
285
|
- lib/github_api/request/oauth2.rb
|
289
286
|
- lib/github_api/request.rb
|
290
287
|
- lib/github_api/response/helpers.rb
|
@@ -427,7 +424,6 @@ files:
|
|
427
424
|
- spec/support/authentication.rb
|
428
425
|
- spec/support/base.rb
|
429
426
|
- spec/support/file_ops.rb
|
430
|
-
- spec/support/github_api_shared_examples.rb
|
431
427
|
- README.md
|
432
428
|
- LICENSE.txt
|
433
429
|
has_rdoc: true
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Github
|
2
|
-
module CacheOptions
|
3
|
-
extend self
|
4
|
-
|
5
|
-
def self.option_accessor(key)
|
6
|
-
defined_method("#{key}=") { |value| }
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def initialize_options(options={})
|
12
|
-
@default_options = {
|
13
|
-
'type' => :memoization,
|
14
|
-
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'faraday'
|
4
|
-
|
5
|
-
module Github
|
6
|
-
module Request
|
7
|
-
class Caching < Faraday::Middleware
|
8
|
-
attr_reader :cache
|
9
|
-
|
10
|
-
def initialize(app, cache = nil, options={})
|
11
|
-
super(app)
|
12
|
-
@cache = cache || Proc.new{}.call
|
13
|
-
end
|
14
|
-
|
15
|
-
def call(env)
|
16
|
-
if env[:method] == :get
|
17
|
-
# TODO choose cache method
|
18
|
-
# file_store
|
19
|
-
# mem_cache_store
|
20
|
-
# memory_store
|
21
|
-
else
|
22
|
-
@app.call(env)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def cache_key
|
27
|
-
url = env[:url].dup
|
28
|
-
if url.query
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end # Request
|
33
|
-
end # Github
|
@@ -1,40 +0,0 @@
|
|
1
|
-
shared_examples_for "collection of resources" do
|
2
|
-
|
3
|
-
context "resource found" do
|
4
|
-
before do
|
5
|
-
stub_get(resource_path).
|
6
|
-
to_return(:body => fixture(fixture_dir), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should fail to get resource without username" do
|
10
|
-
github.user, github.repo = nil, nil
|
11
|
-
expect { github.issues.milestones nil, repo }.to raise_error(ArgumentError)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should get the resources" do
|
15
|
-
github.send *method_chain, user, repo
|
16
|
-
a_get(resource_path).should have_been_made
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should return array of resources" do
|
20
|
-
milestones = github.issues.milestones user, repo
|
21
|
-
milestones.should be_an Array
|
22
|
-
milestones.should have(1).items
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should be a mash type" do
|
26
|
-
milestones = github.issues.milestones user, repo
|
27
|
-
milestones.first.should be_a Hashie::Mash
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should get issue information" do
|
31
|
-
milestones = github.issues.milestones user, repo
|
32
|
-
milestones.first.title.should == 'v1.0'
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should yield to a block" do
|
36
|
-
github.issues.should_receive(:milestones).with(user, repo).and_yield('web')
|
37
|
-
github.issues.milestones(user, repo) { |param| 'web' }.should == 'web'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|