github_api 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/features/README.rdoc +4 -4
- data/features/cassettes/gitignore/get.yml +60 -0
- data/features/cassettes/gitignore/get_raw.yml +224 -0
- data/features/cassettes/gitignore/list.yml +67 -0
- data/features/cassettes/issues/comments/get.yml +71 -0
- data/features/cassettes/issues/comments/list_issue.yml +82 -0
- data/features/cassettes/issues/comments/list_repo.yml +266 -0
- data/features/cassettes/pull_requests/comments/get.yml +159 -0
- data/features/cassettes/pull_requests/comments/list_pull.yml +54 -0
- data/features/cassettes/pull_requests/comments/list_repo.yml +54 -0
- data/features/cassettes/repos/list_repos.yml +129 -0
- data/features/cassettes/users/all.yml +256 -0
- data/features/gitignore.feature +37 -0
- data/features/issues/comments.feature +37 -0
- data/features/pull_requests/comments.feature +27 -0
- data/features/repos.feature +8 -0
- data/features/step_definitions/common_steps.rb +2 -0
- data/features/users.feature +8 -0
- data/lib/github_api.rb +1 -0
- data/lib/github_api/client.rb +5 -0
- data/lib/github_api/git_data/tags.rb +4 -4
- data/lib/github_api/gitignore.rb +56 -0
- data/lib/github_api/issues/comments.rb +23 -9
- data/lib/github_api/pull_requests/comments.rb +24 -6
- data/lib/github_api/repos.rb +14 -1
- data/lib/github_api/repos/keys.rb +4 -4
- data/lib/github_api/users.rb +21 -0
- data/lib/github_api/users/keys.rb +6 -6
- data/lib/github_api/version.rb +1 -1
- data/spec/fixtures/gitignore/template.json +4 -0
- data/spec/fixtures/gitignore/template_raw +1 -0
- data/spec/fixtures/gitignore/templates.json +9 -0
- data/spec/fixtures/users/users.json +9 -0
- data/spec/github/activity/notifications/mark_spec.rb +1 -1
- data/spec/github/activity/starring/starring_spec.rb +2 -2
- data/spec/github/activity/watching/watching_spec.rb +2 -2
- data/spec/github/git_data/commits/create_spec.rb +75 -0
- data/spec/github/git_data/commits/get_spec.rb +50 -0
- data/spec/github/git_data/commits_spec.rb +1 -126
- data/spec/github/git_data/references/create_spec.rb +67 -0
- data/spec/github/git_data/references/delete_spec.rb +38 -0
- data/spec/github/git_data/references/get_spec.rb +54 -0
- data/spec/github/git_data/references/list_spec.rb +77 -0
- data/spec/github/git_data/references/update_spec.rb +62 -0
- data/spec/github/git_data/references_spec.rb +1 -298
- data/spec/github/git_data/tags/create_spec.rb +61 -0
- data/spec/github/git_data/tags/get_spec.rb +48 -0
- data/spec/github/git_data/tags_spec.rb +0 -108
- data/spec/github/git_data/trees/create_spec.rb +62 -0
- data/spec/github/git_data/trees/get_spec.rb +69 -0
- data/spec/github/git_data/trees_spec.rb +0 -133
- data/spec/github/gitignore/get_spec.rb +54 -0
- data/spec/github/gitignore/list_spec.rb +42 -0
- data/spec/github/issues/comments_spec.rb +46 -11
- data/spec/github/pull_requests/comments_spec.rb +46 -11
- data/spec/github/pull_requests_spec.rb +3 -3
- data/spec/github/repos/contents/archive_spec.rb +26 -0
- data/spec/github/repos/contents/get_spec.rb +30 -0
- data/spec/github/repos/contents/readme_spec.rb +30 -0
- data/spec/github/repos/hooks/create_spec.rb +68 -0
- data/spec/github/repos/hooks/delete_spec.rb +40 -0
- data/spec/github/repos/hooks/edit_spec.rb +77 -0
- data/spec/github/repos/hooks/get_spec.rb +49 -0
- data/spec/github/repos/hooks/list_spec.rb +54 -0
- data/spec/github/repos/hooks/test_spec.rb +40 -0
- data/spec/github/repos/hooks_spec.rb +2 -337
- data/spec/github/repos/keys/create_spec.rb +50 -0
- data/spec/github/repos/keys/delete_spec.rb +40 -0
- data/spec/github/repos/keys/edit_spec.rb +40 -0
- data/spec/github/repos/keys/get_spec.rb +43 -0
- data/spec/github/repos/keys/list_spec.rb +52 -0
- data/spec/github/repos/keys_spec.rb +2 -213
- data/spec/github/repos/list_spec.rb +19 -3
- data/spec/github/repos/merging/merge_spec.rb +58 -0
- data/spec/github/repos/pub_sub_hubbub_spec.rb +16 -14
- data/spec/github/repos/statuses/create_spec.rb +54 -0
- data/spec/github/repos/statuses/list_spec.rb +53 -0
- data/spec/github/repos/statuses_spec.rb +1 -114
- data/spec/github/users/emails/add_spec.rb +33 -0
- data/spec/github/users/emails/delete_spec.rb +33 -0
- data/spec/github/users/emails/list_spec.rb +52 -0
- data/spec/github/users/followers/list_spec.rb +68 -0
- data/spec/github/users/followers_spec.rb +0 -70
- data/spec/github/users/get_spec.rb +66 -0
- data/spec/github/users/keys/create_spec.rb +51 -0
- data/spec/github/users/keys/delete_spec.rb +37 -0
- data/spec/github/users/keys/get_spec.rb +50 -0
- data/spec/github/users/keys/list_spec.rb +50 -0
- data/spec/github/users/keys/update_spec.rb +56 -0
- data/spec/github/users/list_spec.rb +45 -0
- data/spec/github/users/update_spec.rb +56 -0
- metadata +96 -43
- data/spec/github/repos/contents_spec.rb +0 -65
- data/spec/github/repos/merging_spec.rb +0 -71
- data/spec/github/repos/starring_spec.rb +0 -4
- data/spec/github/users/emails_spec.rb +0 -110
- data/spec/github/users/keys_spec.rb +0 -256
- data/spec/github/users_spec.rb +0 -128
data/spec/github/users_spec.rb
DELETED
@@ -1,128 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Github::Users do
|
4
|
-
let(:github) { Github.new }
|
5
|
-
let(:user) { 'peter-murach' }
|
6
|
-
let(:repo) { 'github' }
|
7
|
-
|
8
|
-
after { reset_authentication_for github }
|
9
|
-
|
10
|
-
describe "#get" do
|
11
|
-
it { github.users.should respond_to :find }
|
12
|
-
|
13
|
-
context "resource found for a user" do
|
14
|
-
before do
|
15
|
-
stub_get("/users/#{user}").
|
16
|
-
to_return(:body => fixture('users/user.json'),
|
17
|
-
:status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should get the resources" do
|
21
|
-
github.users.get :user => user
|
22
|
-
a_get("/users/#{user}").should have_been_made
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should return resource" do
|
26
|
-
user_resource = github.users.get :user => user
|
27
|
-
user_resource.should be_a Hash
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should be a mash type" do
|
31
|
-
user_resource = github.users.get :user => user
|
32
|
-
user_resource.should be_a Hashie::Mash
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should get org information" do
|
36
|
-
user_resource = github.users.get :user => user
|
37
|
-
user_resource.login.should == 'octocat'
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should yield to a block" do
|
41
|
-
github.users.should_receive(:get).with(:user => user).and_yield('web')
|
42
|
-
github.users.get(:user => user) { |param| 'web' }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "resource found for an authenticated user" do
|
47
|
-
before do
|
48
|
-
github.oauth_token = OAUTH_TOKEN
|
49
|
-
stub_get("/user").
|
50
|
-
with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
51
|
-
to_return(:body => fixture('users/user.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should get the resources" do
|
55
|
-
github.users.get
|
56
|
-
a_get("/user").with(:query => {:access_token => "#{OAUTH_TOKEN}"}).
|
57
|
-
should have_been_made
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "resource not found for a user" do
|
62
|
-
before do
|
63
|
-
stub_get("/users/#{user}").
|
64
|
-
to_return(:body => "", :status => [404, "Not Found"])
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should return 404 with a message 'Not Found'" do
|
68
|
-
expect {
|
69
|
-
github.users.get :user => user
|
70
|
-
}.to raise_error(Github::Error::NotFound)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end # get
|
74
|
-
|
75
|
-
describe "#update" do
|
76
|
-
let(:user_params) {
|
77
|
-
{
|
78
|
-
"name" => "monalisa octocat",
|
79
|
-
"email" => "octocat@github.com",
|
80
|
-
"blog" => "https://github.com/blog",
|
81
|
-
"company" => "GitHub",
|
82
|
-
"location" => "San Francisco",
|
83
|
-
"hireable" => true,
|
84
|
-
"bio" => "There once..."
|
85
|
-
}
|
86
|
-
}
|
87
|
-
|
88
|
-
context "resouce updated" do
|
89
|
-
before do
|
90
|
-
github.oauth_token = OAUTH_TOKEN
|
91
|
-
stub_patch("/user?access_token=#{OAUTH_TOKEN}").with(user_params).
|
92
|
-
to_return(:body => fixture('users/user.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should create resource successfully" do
|
97
|
-
github.users.update
|
98
|
-
a_patch("/user?access_token=#{OAUTH_TOKEN}").with(user_params).should have_been_made
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should return the resource" do
|
102
|
-
user_resource = github.users.update
|
103
|
-
user_resource.should be_a Hashie::Mash
|
104
|
-
end
|
105
|
-
|
106
|
-
it "should get the resource information" do
|
107
|
-
user_resource = github.users.update
|
108
|
-
user_resource.login.should == 'octocat'
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context "failed to update resource" do
|
113
|
-
before do
|
114
|
-
github.oauth_token = OAUTH_TOKEN
|
115
|
-
stub_patch("/user?access_token=#{OAUTH_TOKEN}").with(user_params).
|
116
|
-
to_return(:body => fixture('users/user.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should fail to retrieve resource" do
|
121
|
-
expect {
|
122
|
-
github.users.update
|
123
|
-
}.to raise_error(Github::Error::NotFound)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end # update
|
127
|
-
|
128
|
-
end # Github::Users
|