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,50 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::Keys, '#create' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:request_path) { "/repos/#{user}/#{repo}/keys" }
|
|
9
|
+
let(:inputs) { {:title => "octocat@octomac", :key => "ssh-rsa AAA..." } }
|
|
10
|
+
|
|
11
|
+
before {
|
|
12
|
+
stub_post(request_path).with(inputs).
|
|
13
|
+
to_return(:body => body, :status => status,
|
|
14
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
after { reset_authentication_for(subject) }
|
|
18
|
+
|
|
19
|
+
context "resource created" do
|
|
20
|
+
let(:body) { fixture("repos/key.json") }
|
|
21
|
+
let(:status) { 201 }
|
|
22
|
+
|
|
23
|
+
it "should fail to create resource if 'title' input is missing" do
|
|
24
|
+
expect {
|
|
25
|
+
subject.create user, repo, :key => 'ssh-rsa AAA...'
|
|
26
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should fail to create resource if 'key' input is missing" do
|
|
30
|
+
expect {
|
|
31
|
+
subject.create user, repo, :title => 'octocat@octomac'
|
|
32
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should create the resource" do
|
|
36
|
+
subject.create user, repo, inputs
|
|
37
|
+
a_post(request_path).with(inputs).should have_been_made
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should get the key information back" do
|
|
41
|
+
key = subject.create user, repo, inputs
|
|
42
|
+
key.title.should == 'octocat@octomac'
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it_should_behave_like 'request failure' do
|
|
47
|
+
let(:requestable) { subject.create user, repo, inputs }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end # create
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::Keys, '#delete' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:request_path) { "/repos/#{user}/#{repo}/keys/#{key_id}" }
|
|
9
|
+
let(:key_id) { 1 }
|
|
10
|
+
|
|
11
|
+
before {
|
|
12
|
+
stub_delete(request_path).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 successfully" do
|
|
19
|
+
let(:body) { '' }
|
|
20
|
+
let(:status) { 204 }
|
|
21
|
+
|
|
22
|
+
it "should fail to delete without 'user/repo' parameters" do
|
|
23
|
+
expect { subject.delete }.to raise_error(ArgumentError)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should fail to delete resource without key id" do
|
|
27
|
+
expect { subject.delete user, repo, nil }.to raise_error(ArgumentError)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should delete the resource" do
|
|
31
|
+
subject.delete user, repo, key_id
|
|
32
|
+
a_delete(request_path).should have_been_made
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it_should_behave_like 'request failure' do
|
|
37
|
+
let(:requestable) { subject.delete user, repo, key_id }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end # delete
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::Keys, '#edit' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:request_path) { "/repos/#{user}/#{repo}/keys/#{key_id}" }
|
|
9
|
+
let(:key_id) { 1 }
|
|
10
|
+
let(:inputs) { {:title => "octocat@octomac", :key => "ssh-rsa AAA..." } }
|
|
11
|
+
|
|
12
|
+
before {
|
|
13
|
+
stub_patch(request_path).with(inputs).
|
|
14
|
+
to_return(:body => body, :status => status,
|
|
15
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
after { reset_authentication_for(subject) }
|
|
19
|
+
|
|
20
|
+
context "resource edited successfully" do
|
|
21
|
+
let(:body) { fixture("repos/key.json") }
|
|
22
|
+
let(:status) { 200 }
|
|
23
|
+
|
|
24
|
+
it "should edit the resource" do
|
|
25
|
+
subject.edit user, repo, key_id, inputs
|
|
26
|
+
a_patch(request_path).should have_been_made
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should get the key information back" do
|
|
30
|
+
key = subject.edit user, repo, key_id, inputs
|
|
31
|
+
key.id.should == key_id
|
|
32
|
+
key.title.should == 'octocat@octomac'
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it_should_behave_like 'request failure' do
|
|
37
|
+
let(:requestable) { subject.edit user, repo, key_id, inputs }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end # edit
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::Keys, '#get' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:key_id) { 1 }
|
|
9
|
+
let(:request_path) { "/repos/#{user}/#{repo}/keys/#{key_id}" }
|
|
10
|
+
|
|
11
|
+
before {
|
|
12
|
+
stub_get(request_path).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" do
|
|
19
|
+
let(:body) { fixture("repos/key.json") }
|
|
20
|
+
let(:status) { 200 }
|
|
21
|
+
|
|
22
|
+
it { should respond_to :find }
|
|
23
|
+
|
|
24
|
+
it "should fail to get resource without key" do
|
|
25
|
+
expect { subject.get user, repo, nil }.to raise_error(ArgumentError)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should get the resource" do
|
|
29
|
+
subject.get user, repo, key_id
|
|
30
|
+
a_get(request_path).should have_been_made
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should get key information" do
|
|
34
|
+
key = subject.get user, repo, key_id
|
|
35
|
+
key.id.should == key_id
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it_should_behave_like 'request failure' do
|
|
40
|
+
let(:requestable) { subject.get user, repo, key_id }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end # get
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::Keys, '#list' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:request_path) { "/repos/#{user}/#{repo}/keys" }
|
|
9
|
+
|
|
10
|
+
before {
|
|
11
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
|
12
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
after { reset_authentication_for(subject) }
|
|
16
|
+
|
|
17
|
+
context "resource found" do
|
|
18
|
+
let(:body) { fixture("repos/keys.json") }
|
|
19
|
+
let(:status) { 200 }
|
|
20
|
+
|
|
21
|
+
it { should respond_to :all }
|
|
22
|
+
|
|
23
|
+
it "should fail to get resource without username" do
|
|
24
|
+
expect { subject.list }.to raise_error(ArgumentError)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should get the resources" do
|
|
28
|
+
subject.list user, repo
|
|
29
|
+
a_get(request_path).should have_been_made
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it_should_behave_like 'an array of resources' do
|
|
33
|
+
let(:requestable) { subject.list user, repo }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should get key information" do
|
|
37
|
+
keys = subject.list user, repo
|
|
38
|
+
keys.first.title.should == 'octocat@octomac'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should yield to a block" do
|
|
42
|
+
yielded = []
|
|
43
|
+
result = subject.list(user, repo) { |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 user, repo }
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end # list
|
|
@@ -1,220 +1,9 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Github::Repos::Keys do
|
|
4
|
-
let(:github) { Github.new }
|
|
5
|
-
let(:user) { 'peter-murach' }
|
|
6
|
-
let(:repo) { 'github' }
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
it_should_behave_like 'api interface'
|
|
9
6
|
|
|
10
|
-
it { described_class::
|
|
11
|
-
|
|
12
|
-
describe "#list" do
|
|
13
|
-
it { github.repos.keys.should respond_to :all }
|
|
14
|
-
|
|
15
|
-
context "resource found" do
|
|
16
|
-
before do
|
|
17
|
-
stub_get("/repos/#{user}/#{repo}/keys").
|
|
18
|
-
to_return(:body => fixture("repos/keys.json"),
|
|
19
|
-
:status => 200, :headers => {})
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should fail to get resource without username" do
|
|
23
|
-
expect { github.repos.keys.list }.to raise_error(ArgumentError)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should get the resources" do
|
|
27
|
-
github.repos.keys.list user, repo
|
|
28
|
-
a_get("/repos/#{user}/#{repo}/keys").should have_been_made
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should return array of resources" do
|
|
32
|
-
keys = github.repos.keys.list user, repo
|
|
33
|
-
keys.should be_an Array
|
|
34
|
-
keys.should have(1).items
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "should get key information" do
|
|
38
|
-
keys = github.repos.keys.list user, repo
|
|
39
|
-
keys.first.title.should == 'octocat@octomac'
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context "resource not found" do
|
|
44
|
-
before do
|
|
45
|
-
stub_get("/repos/#{user}/#{repo}/keys").
|
|
46
|
-
to_return(:body => '', :status => 404)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "should fail to retrieve resource" do
|
|
50
|
-
expect {
|
|
51
|
-
github.repos.keys.list user, repo
|
|
52
|
-
}.to raise_error(Github::Error::NotFound)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end # list
|
|
56
|
-
|
|
57
|
-
describe "#get" do
|
|
58
|
-
let(:key_id) { 1 }
|
|
59
|
-
|
|
60
|
-
it { github.repos.keys.should respond_to :find }
|
|
61
|
-
|
|
62
|
-
context "resource found" do
|
|
63
|
-
before do
|
|
64
|
-
stub_get("/repos/#{user}/#{repo}/keys/#{key_id}").
|
|
65
|
-
to_return(:body => fixture("repos/key.json"), :status => 200)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "should fail to get resource without key" do
|
|
69
|
-
expect {
|
|
70
|
-
github.repos.keys.get user, repo, nil
|
|
71
|
-
}.to raise_error(ArgumentError)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it "should get the resource" do
|
|
75
|
-
github.repos.keys.get user, repo, key_id
|
|
76
|
-
a_get("/repos/#{user}/#{repo}/keys/#{key_id}").should have_been_made
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it "should get key information" do
|
|
80
|
-
key = github.repos.keys.get user, repo, key_id
|
|
81
|
-
key.id.should == key_id
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
context "resource not found" do
|
|
86
|
-
before do
|
|
87
|
-
stub_get("/repos/#{user}/#{repo}/keys/#{key_id}").
|
|
88
|
-
to_return(:body => '', :status => 404)
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "should fail to retrieve resource" do
|
|
92
|
-
expect {
|
|
93
|
-
github.repos.keys.get user, repo, key_id
|
|
94
|
-
}.to raise_error(Github::Error::NotFound)
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end # get
|
|
98
|
-
|
|
99
|
-
describe "#create" do
|
|
100
|
-
let(:inputs) { {:title => "octocat@octomac", :key => "ssh-rsa AAA..." } }
|
|
101
|
-
|
|
102
|
-
context "resource created" do
|
|
103
|
-
before do
|
|
104
|
-
stub_post("/repos/#{user}/#{repo}/keys").with(inputs).
|
|
105
|
-
to_return(:body => fixture("repos/key.json"), :status => 201)
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
it "should fail to create resource if 'title' input is missing" do
|
|
109
|
-
expect {
|
|
110
|
-
github.repos.keys.create user, repo, :key => 'ssh-rsa AAA...'
|
|
111
|
-
}.to raise_error(Github::Error::RequiredParams)
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
it "should fail to create resource if 'key' input is missing" do
|
|
115
|
-
expect {
|
|
116
|
-
github.repos.keys.create user, repo, :title => 'octocat@octomac'
|
|
117
|
-
}.to raise_error(Github::Error::RequiredParams)
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it "should create the resource" do
|
|
121
|
-
github.repos.keys.create user, repo, inputs
|
|
122
|
-
a_post("/repos/#{user}/#{repo}/keys").with(inputs).should have_been_made
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it "should get the key information back" do
|
|
126
|
-
key = github.repos.keys.create user, repo, inputs
|
|
127
|
-
key.title.should == 'octocat@octomac'
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
context "failed to create resource" do
|
|
132
|
-
before do
|
|
133
|
-
stub_post("/repos/#{user}/#{repo}/keys").
|
|
134
|
-
to_return(:body => fixture("repos/key.json"), :status => 404)
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
it "should fail to retrieve resource" do
|
|
138
|
-
expect {
|
|
139
|
-
github.repos.keys.create user, repo, inputs
|
|
140
|
-
}.to raise_error(Github::Error::NotFound)
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end # create
|
|
144
|
-
|
|
145
|
-
describe "#edit" do
|
|
146
|
-
let(:key_id) { 1 }
|
|
147
|
-
let(:inputs) { {:title => "octocat@octomac", :key => "ssh-rsa AAA..." } }
|
|
148
|
-
|
|
149
|
-
context "resource edited successfully" do
|
|
150
|
-
before do
|
|
151
|
-
stub_patch("/repos/#{user}/#{repo}/keys/#{key_id}").
|
|
152
|
-
to_return(:body => fixture("repos/key.json"), :status => 200)
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
it "should edit the resource" do
|
|
156
|
-
github.repos.keys.edit user, repo, key_id, inputs
|
|
157
|
-
a_patch("/repos/#{user}/#{repo}/keys/#{key_id}").should have_been_made
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
it "should get the key information back" do
|
|
161
|
-
key = github.repos.keys.edit user, repo, key_id, inputs
|
|
162
|
-
key.id.should == key_id
|
|
163
|
-
key.title.should == 'octocat@octomac'
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
context "failed to edit resource" do
|
|
168
|
-
before do
|
|
169
|
-
stub_patch("/repos/#{user}/#{repo}/keys/#{key_id}").
|
|
170
|
-
to_return(:body => fixture("repos/key.json"), :status => 404)
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
it "should fail to retrieve resource" do
|
|
174
|
-
expect {
|
|
175
|
-
github.repos.keys.edit user, repo, key_id, inputs
|
|
176
|
-
}.to raise_error(Github::Error::NotFound)
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
end # edit
|
|
180
|
-
|
|
181
|
-
describe "#delete" do
|
|
182
|
-
let(:key_id) { 1 }
|
|
183
|
-
|
|
184
|
-
context "resource found successfully" do
|
|
185
|
-
before do
|
|
186
|
-
stub_delete("/repos/#{user}/#{repo}/keys/#{key_id}").
|
|
187
|
-
to_return(:body => "", :status => 204,
|
|
188
|
-
:headers => { :content_type => "application/json; charset=utf-8"} )
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
it "should fail to delete without 'user/repo' parameters" do
|
|
192
|
-
expect { github.repos.keys.delete }.to raise_error(ArgumentError)
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
it "should fail to delete resource without key id" do
|
|
196
|
-
expect {
|
|
197
|
-
github.repos.keys.delete user, repo, nil
|
|
198
|
-
}.to raise_error(ArgumentError)
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
it "should delete the resource" do
|
|
202
|
-
github.repos.keys.delete user, repo, key_id
|
|
203
|
-
a_delete("/repos/#{user}/#{repo}/keys/#{key_id}").should have_been_made
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
context "failed to find resource" do
|
|
208
|
-
before do
|
|
209
|
-
stub_delete("/repos/#{user}/#{repo}/keys/#{key_id}").
|
|
210
|
-
to_return(:body => "", :status => 404)
|
|
211
|
-
end
|
|
212
|
-
it "should fail to find resource" do
|
|
213
|
-
expect {
|
|
214
|
-
github.repos.keys.delete user, repo, key_id
|
|
215
|
-
}.to raise_error(Github::Error::NotFound)
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
end # delete
|
|
7
|
+
it { described_class::VALID_KEY_OPTIONS.should_not be_nil }
|
|
219
8
|
|
|
220
9
|
end # Github::Repos::Keys
|