github_api 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. metadata +4 -140
  2. data/LICENSE.txt +0 -20
  3. data/README.rdoc +0 -228
  4. data/Rakefile +0 -52
  5. data/features/github_api.feature +0 -50
  6. data/features/step_definitions/github_api_steps.rb +0 -11
  7. data/features/support/env.rb +0 -13
  8. data/lib/github_api.rb +0 -73
  9. data/lib/github_api/api.rb +0 -175
  10. data/lib/github_api/api/utils.rb +0 -9
  11. data/lib/github_api/authorization.rb +0 -73
  12. data/lib/github_api/authorizations.rb +0 -119
  13. data/lib/github_api/cache_control.rb +0 -19
  14. data/lib/github_api/client.rb +0 -55
  15. data/lib/github_api/compatibility.rb +0 -23
  16. data/lib/github_api/configuration.rb +0 -96
  17. data/lib/github_api/connection.rb +0 -81
  18. data/lib/github_api/core_ext/array.rb +0 -14
  19. data/lib/github_api/core_ext/hash.rb +0 -42
  20. data/lib/github_api/error.rb +0 -35
  21. data/lib/github_api/events.rb +0 -202
  22. data/lib/github_api/gists.rb +0 -200
  23. data/lib/github_api/gists/comments.rb +0 -86
  24. data/lib/github_api/git_data.rb +0 -26
  25. data/lib/github_api/git_data/blobs.rb +0 -51
  26. data/lib/github_api/git_data/commits.rb +0 -78
  27. data/lib/github_api/git_data/references.rb +0 -113
  28. data/lib/github_api/git_data/tags.rb +0 -78
  29. data/lib/github_api/git_data/trees.rb +0 -89
  30. data/lib/github_api/issues.rb +0 -215
  31. data/lib/github_api/issues/comments.rb +0 -110
  32. data/lib/github_api/issues/events.rb +0 -50
  33. data/lib/github_api/issues/labels.rb +0 -191
  34. data/lib/github_api/issues/milestones.rb +0 -119
  35. data/lib/github_api/mime_type.rb +0 -55
  36. data/lib/github_api/orgs.rb +0 -95
  37. data/lib/github_api/orgs/members.rb +0 -120
  38. data/lib/github_api/orgs/teams.rb +0 -245
  39. data/lib/github_api/pull_requests.rb +0 -224
  40. data/lib/github_api/pull_requests/comments.rb +0 -144
  41. data/lib/github_api/repos.rb +0 -286
  42. data/lib/github_api/repos/collaborators.rb +0 -81
  43. data/lib/github_api/repos/commits.rb +0 -180
  44. data/lib/github_api/repos/downloads.rb +0 -155
  45. data/lib/github_api/repos/forks.rb +0 -48
  46. data/lib/github_api/repos/hooks.rb +0 -173
  47. data/lib/github_api/repos/keys.rb +0 -104
  48. data/lib/github_api/repos/pub_sub_hubbub.rb +0 -102
  49. data/lib/github_api/repos/watching.rb +0 -94
  50. data/lib/github_api/request.rb +0 -84
  51. data/lib/github_api/request/basic_auth.rb +0 -31
  52. data/lib/github_api/request/caching.rb +0 -33
  53. data/lib/github_api/request/oauth2.rb +0 -33
  54. data/lib/github_api/response.rb +0 -28
  55. data/lib/github_api/response/helpers.rb +0 -14
  56. data/lib/github_api/response/jsonize.rb +0 -26
  57. data/lib/github_api/response/mashify.rb +0 -24
  58. data/lib/github_api/response/raise_error.rb +0 -33
  59. data/lib/github_api/result.rb +0 -42
  60. data/lib/github_api/users.rb +0 -84
  61. data/lib/github_api/users/emails.rb +0 -49
  62. data/lib/github_api/users/followers.rb +0 -98
  63. data/lib/github_api/users/keys.rb +0 -84
  64. data/lib/github_api/version.rb +0 -12
  65. data/spec/README.rdoc +0 -22
  66. data/spec/coverage_adapter.rb +0 -14
  67. data/spec/fixtures/auths/authorization.json +0 -14
  68. data/spec/fixtures/auths/authorizations.json +0 -16
  69. data/spec/fixtures/events/events.json +0 -29
  70. data/spec/fixtures/issues/issue.json +0 -56
  71. data/spec/fixtures/issues/issues.json +0 -58
  72. data/spec/fixtures/orgs/members.json +0 -9
  73. data/spec/fixtures/orgs/org.json +0 -18
  74. data/spec/fixtures/orgs/orgs.json +0 -8
  75. data/spec/fixtures/orgs/team.json +0 -8
  76. data/spec/fixtures/orgs/team_repos.json +0 -29
  77. data/spec/fixtures/orgs/teams.json +0 -7
  78. data/spec/fixtures/repos/branches.json +0 -9
  79. data/spec/fixtures/repos/collaborators.json +0 -8
  80. data/spec/fixtures/repos/commit.json +0 -53
  81. data/spec/fixtures/repos/commit_comment.json +0 -16
  82. data/spec/fixtures/repos/commit_comments.json +0 -18
  83. data/spec/fixtures/repos/commits.json +0 -27
  84. data/spec/fixtures/repos/contributors.json +0 -8
  85. data/spec/fixtures/repos/download.json +0 -10
  86. data/spec/fixtures/repos/download_s3.json +0 -21
  87. data/spec/fixtures/repos/downloads.json +0 -12
  88. data/spec/fixtures/repos/fork.json +0 -27
  89. data/spec/fixtures/repos/forks.json +0 -29
  90. data/spec/fixtures/repos/hook.json +0 -15
  91. data/spec/fixtures/repos/hooks.json +0 -10
  92. data/spec/fixtures/repos/key.json +0 -6
  93. data/spec/fixtures/repos/keys.json +0 -8
  94. data/spec/fixtures/repos/languages.json +0 -4
  95. data/spec/fixtures/repos/repo.json +0 -90
  96. data/spec/fixtures/repos/repo_comments.json +0 -18
  97. data/spec/fixtures/repos/repos.json +0 -29
  98. data/spec/fixtures/repos/tags.json +0 -11
  99. data/spec/fixtures/repos/teams.json +0 -7
  100. data/spec/fixtures/repos/watched.json +0 -29
  101. data/spec/fixtures/repos/watchers.json +0 -8
  102. data/spec/fixtures/users/user.json +0 -32
  103. data/spec/github/api_spec.rb +0 -25
  104. data/spec/github/authorization_spec.rb +0 -176
  105. data/spec/github/authorizations_spec.rb +0 -242
  106. data/spec/github/client_spec.rb +0 -50
  107. data/spec/github/core_ext/hash_spec.rb +0 -44
  108. data/spec/github/events_spec.rb +0 -491
  109. data/spec/github/gists/comments_spec.rb +0 -5
  110. data/spec/github/gists_spec.rb +0 -5
  111. data/spec/github/git_data/blobs_spec.rb +0 -5
  112. data/spec/github/git_data/commits_spec.rb +0 -5
  113. data/spec/github/git_data/references_spec.rb +0 -5
  114. data/spec/github/git_data/tags_spec.rb +0 -5
  115. data/spec/github/git_data/trees_spec.rb +0 -5
  116. data/spec/github/git_data_spec.rb +0 -5
  117. data/spec/github/issues/comments_spec.rb +0 -5
  118. data/spec/github/issues/events_spec.rb +0 -5
  119. data/spec/github/issues/labels_spec.rb +0 -5
  120. data/spec/github/issues/milestones_spec.rb +0 -5
  121. data/spec/github/issues_spec.rb +0 -287
  122. data/spec/github/mime_type_spec.rb +0 -70
  123. data/spec/github/orgs/members_spec.rb +0 -275
  124. data/spec/github/orgs/teams_spec.rb +0 -563
  125. data/spec/github/orgs_spec.rb +0 -160
  126. data/spec/github/repos/collaborators_spec.rb +0 -169
  127. data/spec/github/repos/commits_spec.rb +0 -424
  128. data/spec/github/repos/downloads_spec.rb +0 -236
  129. data/spec/github/repos/forks_spec.rb +0 -103
  130. data/spec/github/repos/hooks_spec.rb +0 -307
  131. data/spec/github/repos/keys_spec.rb +0 -216
  132. data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -83
  133. data/spec/github/repos/watching_spec.rb +0 -222
  134. data/spec/github/repos_spec.rb +0 -571
  135. data/spec/github/result_spec.rb +0 -43
  136. data/spec/github/users_spec.rb +0 -140
  137. data/spec/github_spec.rb +0 -109
  138. data/spec/spec_helper.rb +0 -86
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Github::Result do
4
-
5
- let(:github) { Github.new }
6
- let(:res) { github.events.public }
7
-
8
- before do
9
- stub_get("/events").
10
- to_return(:body => fixture('events/events.json'),
11
- :status => 200,
12
- :headers => {
13
- :content_type => "application/json; charset=utf-8",
14
- 'X-RateLimit-Remaining' => '4999',
15
- 'content-length' => '344'
16
- })
17
- end
18
-
19
- it "should read response content_type " do
20
- res.content_type.should match 'application/json'
21
- end
22
-
23
- it "should read response content_length " do
24
- res.content_length.should match '344'
25
- end
26
-
27
- it "should read response ratelimit" do
28
- res.ratelimit.should == '4999'
29
- end
30
-
31
- it "should read response statsu" do
32
- res.status.should be 200
33
- end
34
-
35
- it "should assess successful" do
36
- res.success?.should be_true
37
- end
38
-
39
- it "should read response body" do
40
- res.body.should_not be_empty
41
- end
42
-
43
- end # Github::Result
@@ -1,140 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Github::Users do
4
-
5
- let(:github) { Github.new }
6
- let(:user) { 'peter-murach' }
7
-
8
- before do
9
- reset_authentication_for github
10
- end
11
-
12
- after do
13
- reset_authentication_for github
14
- end
15
-
16
- describe "get_user" do
17
- context "resource found for a user" do
18
- before do
19
- stub_get("/users/#{user}").
20
- to_return(:body => fixture('users/user.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
21
- end
22
-
23
- it "should get the resources" do
24
- github.users.get_user user
25
- a_get("/users/#{user}").should have_been_made
26
- end
27
-
28
- it "should return resource" do
29
- user_resource = github.users.get_user user
30
- user_resource.should be_a Hash
31
- end
32
-
33
- it "should be a mash type" do
34
- user_resource = github.users.get_user user
35
- user_resource.should be_a Hashie::Mash
36
- end
37
-
38
- it "should get org information" do
39
- user_resource = github.users.get_user user
40
- user_resource.login.should == 'octocat'
41
- end
42
-
43
- it "should yield to a block" do
44
- github.users.should_receive(:get_user).with(user).and_yield('web')
45
- github.users.get_user(user) { |param| 'web' }
46
- end
47
- end
48
-
49
- context "resource found for an authenticated user" do
50
- before do
51
- reset_authentication_for github
52
- github.oauth_token = OAUTH_TOKEN
53
- stub_get("/user?access_token=#{OAUTH_TOKEN}").
54
- to_return(:body => fixture('users/user.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
55
- end
56
-
57
- after do
58
- reset_authentication_for github
59
- end
60
-
61
- it "should get the resources" do
62
- github.users.get_user
63
- a_get("/user?access_token=#{OAUTH_TOKEN}").should have_been_made
64
- end
65
- end
66
-
67
- context "resource not found for a user" do
68
- before do
69
- stub_get("/users/#{user}").
70
- to_return(:body => "", :status => [404, "Not Found"])
71
- end
72
-
73
- it "should return 404 with a message 'Not Found'" do
74
- expect {
75
- github.users.get_user user
76
- }.to raise_error(Github::ResourceNotFound)
77
- end
78
- end
79
- end # get_user
80
-
81
- describe "update_user" do
82
- let(:user_params) {
83
- {
84
- "name" => "monalisa octocat",
85
- "email" => "octocat@github.com",
86
- "blog" => "https://github.com/blog",
87
- "company" => "GitHub",
88
- "location" => "San Francisco",
89
- "hireable" => true,
90
- "bio" => "There once..."
91
- }
92
- }
93
-
94
- context "resouce updated" do
95
- before do
96
- reset_authentication_for github
97
- github.oauth_token = OAUTH_TOKEN
98
- stub_patch("/user?access_token=#{OAUTH_TOKEN}").with(user_params).
99
- to_return(:body => fixture('users/user.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
100
-
101
- end
102
-
103
- after do
104
- reset_authentication_for github
105
- end
106
-
107
- it "should create resource successfully" do
108
- github.users.update_user
109
- a_patch("/user?access_token=#{OAUTH_TOKEN}").with(user_params).should have_been_made
110
- end
111
-
112
- it "should return the resource" do
113
- user_resource = github.users.update_user
114
- user_resource.should be_a Hashie::Mash
115
- end
116
-
117
- it "should get the resource information" do
118
- user_resource = github.users.update_user
119
- user_resource.login.should == 'octocat'
120
- end
121
- end
122
-
123
- context "failed to update resource" do
124
- before do
125
- reset_authentication_for github
126
- github.oauth_token = OAUTH_TOKEN
127
- stub_patch("/user?access_token=#{OAUTH_TOKEN}").with(user_params).
128
- to_return(:body => fixture('users/user.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
129
-
130
- end
131
-
132
- it "should fail to retrieve resource" do
133
- expect {
134
- github.users.update_user
135
- }.to raise_error(Github::ResourceNotFound)
136
- end
137
- end
138
- end # update_comment
139
-
140
- end # Github::Users
data/spec/github_spec.rb DELETED
@@ -1,109 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Github do
4
-
5
- before do
6
- Github.user = nil
7
- Github.repo = nil
8
- end
9
-
10
- it "should respond to 'new' message" do
11
- Github.should respond_to :new
12
- end
13
-
14
- it "should receive 'new' and initialize Github::Client instance" do
15
- Github.new.should be_a Github::Client
16
- end
17
-
18
- it "should respond to 'configure' message" do
19
- Github.should respond_to :configure
20
- end
21
-
22
- describe "setting configuration options" do
23
-
24
- it "should return default adapter" do
25
- Github.adapter.should == Github::Configuration::DEFAULT_ADAPTER
26
- end
27
-
28
- it "should allow to set adapter" do
29
- Github.adapter = :typhoeus
30
- Github.adapter.should == :typhoeus
31
- end
32
-
33
- it "should return the default end point" do
34
- Github.endpoint.should == Github::Configuration::DEFAULT_ENDPOINT
35
- end
36
-
37
- it "should allow to set endpoint" do
38
- Github.endpoint = 'http://linkedin.com'
39
- Github.endpoint.should == 'http://linkedin.com'
40
- end
41
-
42
- it "should return the default user agent" do
43
- Github.user_agent.should == Github::Configuration::DEFAULT_USER_AGENT
44
- end
45
-
46
- it "should allow to set new user agent" do
47
- Github.user_agent = 'New User Agent'
48
- Github.user_agent.should == 'New User Agent'
49
- end
50
-
51
- it "should have not set oauth token" do
52
- Github.oauth_token.should be_nil
53
- end
54
-
55
- it "should allow to set oauth token" do
56
- Github.oauth_token = ''
57
- end
58
-
59
- it "should have not set default user" do
60
- Github.user.should be_nil
61
- end
62
-
63
- it "should allow to set new user" do
64
- Github.user = 'github'
65
- Github.user.should == 'github'
66
- end
67
-
68
- it "should have not set default repository" do
69
- Github.repo.should be_nil
70
- end
71
-
72
- it "should allow to set new repository" do
73
- Github.repo = 'github'
74
- Github.repo.should == 'github'
75
- end
76
-
77
- it "should have connection options as hash" do
78
- Github.connection_options.should be_a Hash
79
- end
80
-
81
- it "should initialize connection options to empty hash" do
82
- Github.connection_options.should be_empty
83
- end
84
-
85
- it "shoulve have not set user's login" do
86
- Github.login.should be_nil
87
- end
88
-
89
- it "should have not set user's password" do
90
- Github.password.should be_nil
91
- end
92
-
93
- it "should have set mime type to json" do
94
- Github.mime_type.should == :json
95
- end
96
- end
97
-
98
- describe ".configure" do
99
- Github::Configuration::VALID_OPTIONS_KEYS.each do |key|
100
- it "should set the #{key}" do
101
- Github.configure do |config|
102
- config.send("#{key}=", key)
103
- Github.send(key).should == key
104
- end
105
- end
106
- end
107
- end
108
-
109
- end
data/spec/spec_helper.rb DELETED
@@ -1,86 +0,0 @@
1
- require 'rubygems'
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- $LOAD_PATH.unshift(File.dirname(__FILE__))
5
-
6
- require 'rspec'
7
- require 'json'
8
- require 'webmock/rspec'
9
- require 'github_api'
10
-
11
- if RUBY_VERSION > '1.9' and ENV['COVERAGE']
12
- require 'coverage_adapter'
13
- SimpleCov.start 'github_api'
14
- end
15
-
16
- # Requires supporting files with custom matchers and macros, etc,
17
- # in ./support/ and its subdirectories.
18
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
19
-
20
- RSpec.configure do |config|
21
- config.include WebMock::API
22
- end
23
-
24
- def stub_get(path, endpoint = Github.endpoint.to_s)
25
- stub_request(:get, endpoint + path)
26
- end
27
-
28
- def stub_post(path, endpoint = Github.endpoint.to_s)
29
- stub_request(:post, endpoint + path)
30
- end
31
-
32
- def stub_patch(path, endpoint = Github.endpoint.to_s)
33
- stub_request(:patch, endpoint + path)
34
- end
35
-
36
- def stub_put(path, endpoint = Github.endpoint.to_s)
37
- stub_request(:put, endpoint + path)
38
- end
39
-
40
- def stub_delete(path, endpoint = Github.endpoint.to_s)
41
- stub_request(:delete, endpoint + path)
42
- end
43
-
44
- def a_get(path, endpoint = Github.endpoint.to_s)
45
- a_request(:get, endpoint + path)
46
- end
47
-
48
- def a_post(path, endpoint = Github.endpoint.to_s)
49
- a_request(:post, endpoint + path)
50
- end
51
-
52
- def a_patch(path, endpoint = Github.endpoint.to_s)
53
- a_request(:patch, endpoint + path)
54
- end
55
-
56
- def a_put(path, endpoint = Github.endpoint)
57
- a_request(:put, endpoint + path)
58
- end
59
-
60
- def a_delete(path, endpoint = Github.endpoint)
61
- a_request(:delete, endpoint + path)
62
- end
63
-
64
- def fixture_path
65
- File.expand_path("../fixtures", __FILE__)
66
- end
67
-
68
- def fixture(file)
69
- File.new(File.join(fixture_path, '/', file))
70
- end
71
-
72
- OAUTH_TOKEN = 'bafec72922f31fe86aacc8aca4261117f3bd62cf'
73
-
74
- def reset_authentication_for(object)
75
- ['basic_auth', 'oauth_token', 'login', 'password' ].each do |item|
76
- object.send("#{item}=", nil)
77
- end
78
- end
79
-
80
- class Hash
81
- def except(*keys)
82
- cpy = self.dup
83
- keys.each { |key| cpy.delete(key) }
84
- cpy
85
- end
86
- end