github_api 0.8.1 → 0.8.2
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 +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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Users::Emails, '#list' do
|
|
6
|
+
let(:email) { "octocat@github.com" }
|
|
7
|
+
let(:request_path) { "/user/emails" }
|
|
8
|
+
|
|
9
|
+
before {
|
|
10
|
+
subject.oauth_token = OAUTH_TOKEN
|
|
11
|
+
stub_delete(request_path).with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
|
12
|
+
to_return(:body => body, :status => status,
|
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
after { reset_authentication_for(subject) }
|
|
17
|
+
|
|
18
|
+
let(:params) { { :per_page => 21, :page => 1 }}
|
|
19
|
+
let(:body) { fixture('users/emails.json') }
|
|
20
|
+
let(:status) { 204 }
|
|
21
|
+
|
|
22
|
+
it 'extracts request parameters and email data' do
|
|
23
|
+
subject.should_receive(:delete_request).
|
|
24
|
+
with(request_path, { "per_page" => 21, "page" => 1, 'data' => [email] })
|
|
25
|
+
subject.delete email, params
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'submits request successfully' do
|
|
29
|
+
subject.delete email
|
|
30
|
+
a_delete(request_path).with(:query => { :access_token => "#{OAUTH_TOKEN}" } ).
|
|
31
|
+
should have_been_made
|
|
32
|
+
end
|
|
33
|
+
end # delete
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Users::Emails, '#list' do
|
|
6
|
+
let(:email) { "octocat@github.com" }
|
|
7
|
+
let(:request_path) { "/user/emails" }
|
|
8
|
+
|
|
9
|
+
before {
|
|
10
|
+
subject.oauth_token = OAUTH_TOKEN
|
|
11
|
+
stub_get(request_path).with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
|
12
|
+
to_return(:body => body, :status => status,
|
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
after { reset_authentication_for(subject) }
|
|
17
|
+
|
|
18
|
+
context "resource found for an authenticated user" do
|
|
19
|
+
let(:body) { fixture('users/emails.json') }
|
|
20
|
+
let(:status) { 200 }
|
|
21
|
+
|
|
22
|
+
it { should respond_to :all }
|
|
23
|
+
|
|
24
|
+
it "should get the resources" do
|
|
25
|
+
subject.list
|
|
26
|
+
a_get(request_path).with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
|
27
|
+
should have_been_made
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should return resource" do
|
|
31
|
+
emails = subject.list
|
|
32
|
+
emails.should be_an Array
|
|
33
|
+
emails.should have(2).items
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should get emails information" do
|
|
37
|
+
emails = subject.list
|
|
38
|
+
emails.first.should == email
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should yield to a block" do
|
|
42
|
+
yielded = []
|
|
43
|
+
result = subject.list { |obj| yielded << obj }
|
|
44
|
+
yielded.should == result
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it_should_behave_like 'request failure' do
|
|
49
|
+
let(:requestable) { subject.list }
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end # list
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Users::Followers, '#list' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:request_path) { "/users/#{user}/followers" }
|
|
8
|
+
|
|
9
|
+
before {
|
|
10
|
+
subject.oauth_token = OAUTH_TOKEN
|
|
11
|
+
stub_get(request_path).with(:query => { :access_token => OAUTH_TOKEN}).
|
|
12
|
+
to_return(:body => body, :status => status,
|
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
after { reset_authentication_for(subject) }
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
context "resource found for a user" do
|
|
20
|
+
let(:status) { 200 }
|
|
21
|
+
let(:body) { fixture('users/followers.json') }
|
|
22
|
+
|
|
23
|
+
it { should respond_to :all }
|
|
24
|
+
|
|
25
|
+
it "should get the resources" do
|
|
26
|
+
subject.list user
|
|
27
|
+
a_get(request_path).with(:query => { :access_token => OAUTH_TOKEN}).
|
|
28
|
+
should have_been_made
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it_should_behave_like 'an array of resources' do
|
|
32
|
+
let(:requestable) { subject.list user }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should get followers information" do
|
|
36
|
+
followers = subject.list user
|
|
37
|
+
followers.first.login.should == 'octocat'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should yield to a block" do
|
|
41
|
+
yielded = []
|
|
42
|
+
result = subject.list(user) { |obj| yielded << obj }
|
|
43
|
+
yielded.should == result
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context "resource found for an authenticated user" do
|
|
48
|
+
let(:request_path) { "/user/followers" }
|
|
49
|
+
let(:body) { fixture('users/followers.json') }
|
|
50
|
+
let(:status) { 200 }
|
|
51
|
+
|
|
52
|
+
it "should get the resources" do
|
|
53
|
+
subject.list
|
|
54
|
+
a_get(request_path).with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
|
55
|
+
should have_been_made
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context "rosource not found for authenticated user" do
|
|
60
|
+
let(:body) { '' }
|
|
61
|
+
let(:status) { 404 }
|
|
62
|
+
|
|
63
|
+
it "fail to find resources" do
|
|
64
|
+
expect { subject.list user }.to raise_error(Github::Error::NotFound)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end # list
|
|
@@ -8,76 +8,6 @@ describe Github::Users::Followers do
|
|
|
8
8
|
|
|
9
9
|
after { reset_authentication_for github }
|
|
10
10
|
|
|
11
|
-
describe "#list" do
|
|
12
|
-
it { github.users.followers.should respond_to :all }
|
|
13
|
-
|
|
14
|
-
context "resource found for a user" do
|
|
15
|
-
before do
|
|
16
|
-
stub_get("/users/#{user}/followers").
|
|
17
|
-
to_return(:body => fixture('users/followers.json'),
|
|
18
|
-
:status => 200,
|
|
19
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should get the resources" do
|
|
23
|
-
github.users.followers.list user
|
|
24
|
-
a_get("/users/#{user}/followers").should have_been_made
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "should return resource" do
|
|
28
|
-
followers = github.users.followers.list user
|
|
29
|
-
followers.should be_an Array
|
|
30
|
-
followers.should have(1).items
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "should be a mash type" do
|
|
34
|
-
followers = github.users.followers.list user
|
|
35
|
-
followers.first.should be_a Hashie::Mash
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "should get followers information" do
|
|
39
|
-
followers = github.users.followers.list user
|
|
40
|
-
followers.first.login.should == 'octocat'
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "should yield to a block" do
|
|
44
|
-
github.users.followers.should_receive(:list).with(user).and_yield('web')
|
|
45
|
-
github.users.followers.list(user) { |param| 'web' }
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context "resource found for an authenticated user" do
|
|
50
|
-
before do
|
|
51
|
-
github.oauth_token = OAUTH_TOKEN
|
|
52
|
-
stub_get("/user/followers").
|
|
53
|
-
with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
|
54
|
-
to_return(:body => fixture('users/followers.json'),
|
|
55
|
-
:status => 200,
|
|
56
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "should get the resources" do
|
|
60
|
-
github.users.followers.list
|
|
61
|
-
a_get("/user/followers").
|
|
62
|
-
with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
|
63
|
-
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}/followers").
|
|
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.followers.list user
|
|
76
|
-
}.to raise_error(Github::Error::NotFound)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end # list
|
|
80
|
-
|
|
81
11
|
describe "#following" do
|
|
82
12
|
context "resource found for a user" do
|
|
83
13
|
before do
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Users, '#get' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:request_path) { "/users/#{user}" }
|
|
8
|
+
|
|
9
|
+
before {
|
|
10
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
|
11
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
after { reset_authentication_for(subject) }
|
|
15
|
+
|
|
16
|
+
context "resource found for a user" do
|
|
17
|
+
let(:body) { fixture('users/user.json') }
|
|
18
|
+
let(:status) { 200 }
|
|
19
|
+
|
|
20
|
+
it { should respond_to :find }
|
|
21
|
+
|
|
22
|
+
it "should get the resources" do
|
|
23
|
+
subject.get :user => user
|
|
24
|
+
a_get(request_path).should have_been_made
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should return resource" do
|
|
28
|
+
user_resource = subject.get :user => user
|
|
29
|
+
user_resource.should be_a Hash
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should be a mash type" do
|
|
33
|
+
user_resource = subject.get :user => user
|
|
34
|
+
user_resource.should be_a Hashie::Mash
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should get org information" do
|
|
38
|
+
user_resource = subject.get :user => user
|
|
39
|
+
user_resource.login.should == 'octocat'
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context "resource found for an authenticated user" do
|
|
44
|
+
let(:request_path) { "/user" }
|
|
45
|
+
let(:body) { fixture('users/user.json') }
|
|
46
|
+
let(:status) { 200 }
|
|
47
|
+
|
|
48
|
+
before do
|
|
49
|
+
subject.oauth_token = OAUTH_TOKEN
|
|
50
|
+
stub_get(request_path).with(:query => { :access_token => OAUTH_TOKEN}).
|
|
51
|
+
to_return(:body => fixture('users/user.json'), :status => 200,
|
|
52
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should get the resources" do
|
|
56
|
+
subject.get
|
|
57
|
+
a_get(request_path).with(:query => {:access_token => OAUTH_TOKEN}).
|
|
58
|
+
should have_been_made
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it_should_behave_like 'request failure' do
|
|
63
|
+
let(:requestable) { subject.get :user => user }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end # get
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Users::Keys, '#create' do
|
|
6
|
+
let(:request_path) { "/user/keys" }
|
|
7
|
+
|
|
8
|
+
before {
|
|
9
|
+
subject.oauth_token = OAUTH_TOKEN
|
|
10
|
+
stub_post(request_path).with(:body => inputs.except(:unrelated),
|
|
11
|
+
:query => {:access_token => OAUTH_TOKEN}).
|
|
12
|
+
to_return(:body => body, :status => status,
|
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
after { reset_authentication_for(subject) }
|
|
17
|
+
|
|
18
|
+
let(:inputs) {
|
|
19
|
+
{
|
|
20
|
+
:title => "octocat@octomac",
|
|
21
|
+
:key => "ssh-rsa AAA...",
|
|
22
|
+
:unrelated => true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
context "resouce created" do
|
|
27
|
+
let(:body) { fixture('users/key.json') }
|
|
28
|
+
let(:status) { 201 }
|
|
29
|
+
|
|
30
|
+
it "should create resource successfully" do
|
|
31
|
+
subject.create inputs
|
|
32
|
+
a_post(request_path).with(:body => inputs.except(:unrelated),
|
|
33
|
+
:query => {:access_token => OAUTH_TOKEN}).should have_been_made
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should return the resource" do
|
|
37
|
+
key = subject.create inputs
|
|
38
|
+
key.should be_a Hashie::Mash
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should get the key information" do
|
|
42
|
+
key = subject.create inputs
|
|
43
|
+
key.title.should == 'octocat@octomac'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it_should_behave_like 'request failure' do
|
|
48
|
+
let(:requestable) { subject.create inputs }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end # create
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Users::Keys, '#delete' do
|
|
6
|
+
let(:key_id) { 1 }
|
|
7
|
+
let(:request_path) { "/user/keys/#{key_id}" }
|
|
8
|
+
|
|
9
|
+
before {
|
|
10
|
+
subject.oauth_token = OAUTH_TOKEN
|
|
11
|
+
stub_delete(request_path).with(:query => {:access_token => OAUTH_TOKEN}).
|
|
12
|
+
to_return(:body => body, :status => status,
|
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
after { reset_authentication_for(subject) }
|
|
17
|
+
|
|
18
|
+
context "resouce deleted" do
|
|
19
|
+
let(:body) { fixture('users/key.json') }
|
|
20
|
+
let(:status) { 204 }
|
|
21
|
+
|
|
22
|
+
it "should fail to get resource without key id" do
|
|
23
|
+
expect { subject.delete nil }.to raise_error(ArgumentError)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should create resource successfully" do
|
|
27
|
+
subject.delete key_id
|
|
28
|
+
a_delete(request_path).with(:query => {:access_token => OAUTH_TOKEN}).
|
|
29
|
+
should have_been_made
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it_should_behave_like 'request failure' do
|
|
34
|
+
let(:requestable) { subject.delete key_id }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end # delete
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Users::Keys, '#get' do
|
|
6
|
+
let(:key_id) { 1 }
|
|
7
|
+
let(:request_path) { "/user/keys/#{key_id}" }
|
|
8
|
+
|
|
9
|
+
before {
|
|
10
|
+
subject.oauth_token = OAUTH_TOKEN
|
|
11
|
+
stub_get(request_path).with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
|
12
|
+
to_return(:body => body, :status => status,
|
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
after { reset_authentication_for(subject) }
|
|
17
|
+
|
|
18
|
+
context "resource found for an authenticated user" do
|
|
19
|
+
let(:body) { fixture('users/key.json') }
|
|
20
|
+
let(:status) { 200 }
|
|
21
|
+
|
|
22
|
+
it { should respond_to :find }
|
|
23
|
+
|
|
24
|
+
it "should fail to get resource without key id" do
|
|
25
|
+
expect { subject.get nil }.to raise_error(ArgumentError)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should get the resource" do
|
|
29
|
+
subject.get key_id
|
|
30
|
+
a_get(request_path).with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
|
31
|
+
should have_been_made
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should get public key information" do
|
|
35
|
+
key = subject.get key_id
|
|
36
|
+
key.id.should == key_id
|
|
37
|
+
key.title.should == 'octocat@octomac'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should return mash" do
|
|
41
|
+
key = subject.get key_id
|
|
42
|
+
key.should be_a Hashie::Mash
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it_should_behave_like 'request failure' do
|
|
47
|
+
let(:requestable) { subject.get key_id }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end # get
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Users::Keys, '#list' do
|
|
6
|
+
let(:key_id) { 1 }
|
|
7
|
+
let(:request_path) { "/user/keys" }
|
|
8
|
+
|
|
9
|
+
before {
|
|
10
|
+
subject.oauth_token = OAUTH_TOKEN
|
|
11
|
+
stub_get(request_path).with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
|
12
|
+
to_return(:body => body, :status => status,
|
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
after { reset_authentication_for(subject) }
|
|
17
|
+
|
|
18
|
+
context "resource found for an authenticated user" do
|
|
19
|
+
let(:body) { fixture('users/keys.json') }
|
|
20
|
+
let(:status) { 200 }
|
|
21
|
+
|
|
22
|
+
it {should respond_to :all }
|
|
23
|
+
|
|
24
|
+
it "should get the resources" do
|
|
25
|
+
subject.list
|
|
26
|
+
a_get(request_path).with(:query => { :access_token => "#{OAUTH_TOKEN}"}).
|
|
27
|
+
should have_been_made
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it_should_behave_like 'an array of resources' do
|
|
31
|
+
let(:requestable) { subject.list }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should get keys information" do
|
|
35
|
+
keys = subject.list
|
|
36
|
+
keys.first.id.should == key_id
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should yield to a block" do
|
|
40
|
+
yielded = []
|
|
41
|
+
result = subject.list { |obj| yielded << obj }
|
|
42
|
+
yielded.should == result
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it_should_behave_like 'request failure' do
|
|
47
|
+
let(:requestable) { subject.list }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end # list
|