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,61 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::GitData::Tags, '#create' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:sha) { "940bd336248efae0f9ee5bc7b2d5c985887b16ac" }
|
|
9
|
+
let(:request_path) { "/repos/#{user}/#{repo}/git/tags" }
|
|
10
|
+
|
|
11
|
+
before {
|
|
12
|
+
stub_post(request_path).with(inputs.except('unrelated')).
|
|
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
|
+
let(:inputs) {
|
|
20
|
+
{
|
|
21
|
+
"tag" => "v0.0.1",
|
|
22
|
+
"message" => "initial version\n",
|
|
23
|
+
"object" => {
|
|
24
|
+
"type" => "commit",
|
|
25
|
+
"sha" => "c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c",
|
|
26
|
+
"url" => "https://api.github.com/repos/octocat/Hello-World/git/commits/c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c"
|
|
27
|
+
},
|
|
28
|
+
"tagger" => {
|
|
29
|
+
"name" => "Scott Chacon",
|
|
30
|
+
"email" => "schacon@gmail.com",
|
|
31
|
+
"date" => "2011-06-17T14:53:35-07:00"
|
|
32
|
+
},
|
|
33
|
+
'unrelated' => 'giberrish'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
context "resouce created" do
|
|
38
|
+
let(:body) { fixture('git_data/tag.json') }
|
|
39
|
+
let(:status) { 201 }
|
|
40
|
+
|
|
41
|
+
it "should create resource successfully" do
|
|
42
|
+
subject.create user, repo, inputs
|
|
43
|
+
a_post(request_path).with(inputs).should have_been_made
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should return the resource" do
|
|
47
|
+
tag = subject.create user, repo, inputs
|
|
48
|
+
tag.should be_a Hashie::Mash
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should get the tag information" do
|
|
52
|
+
tag = subject.create user, repo, inputs
|
|
53
|
+
tag.sha.should == sha
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it_should_behave_like 'request failure' do
|
|
58
|
+
let(:requestable) { subject.create user, repo, inputs }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end # create
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::GitData::Tags, '#get' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:sha) { "940bd336248efae0f9ee5bc7b2d5c985887b16ac" }
|
|
9
|
+
let(:request_path) { "/repos/#{user}/#{repo}/git/tags/#{sha}" }
|
|
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('git_data/tag.json') }
|
|
20
|
+
let(:status) { 200 }
|
|
21
|
+
|
|
22
|
+
it { should respond_to :find }
|
|
23
|
+
|
|
24
|
+
it "should fail to get resource without sha" do
|
|
25
|
+
expect { subject.get user, repo }.to raise_error(ArgumentError)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should get the resource" do
|
|
29
|
+
subject.get user, repo, sha
|
|
30
|
+
a_get(request_path).should have_been_made
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should get tag information" do
|
|
34
|
+
tag = subject.get user, repo, sha
|
|
35
|
+
tag.tag.should eql "v0.0.1"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should return mash" do
|
|
39
|
+
tag = subject.get user, repo, sha
|
|
40
|
+
tag.should be_a Hashie::Mash
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it_should_behave_like 'request failure' do
|
|
45
|
+
let(:requestable) { subject.get user, repo, sha }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end # get
|
|
@@ -3,115 +3,7 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
describe Github::GitData::Tags do
|
|
6
|
-
let(:github) { Github.new }
|
|
7
|
-
let(:user) { 'peter-murach' }
|
|
8
|
-
let(:repo) { 'github' }
|
|
9
|
-
let(:sha) { "940bd336248efae0f9ee5bc7b2d5c985887b16ac" }
|
|
10
|
-
|
|
11
|
-
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
|
12
6
|
|
|
13
7
|
it { described_class::VALID_TAG_PARAM_NAMES.should_not be_nil }
|
|
14
8
|
|
|
15
|
-
describe "#get" do
|
|
16
|
-
it { github.git_data.tags.should respond_to :find }
|
|
17
|
-
|
|
18
|
-
context "resource found" do
|
|
19
|
-
before do
|
|
20
|
-
stub_get("/repos/#{user}/#{repo}/git/tags/#{sha}").
|
|
21
|
-
to_return(:body => fixture('git_data/tag.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "should fail to get resource without sha" do
|
|
25
|
-
expect {
|
|
26
|
-
github.git_data.tags.get user, repo, nil
|
|
27
|
-
}.to raise_error(ArgumentError)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "should get the resource" do
|
|
31
|
-
github.git_data.tags.get user, repo, sha
|
|
32
|
-
a_get("/repos/#{user}/#{repo}/git/tags/#{sha}").should have_been_made
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "should get tag information" do
|
|
36
|
-
tag = github.git_data.tags.get user, repo, sha
|
|
37
|
-
tag.tag.should eql "v0.0.1"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "should return mash" do
|
|
41
|
-
tag = github.git_data.tags.get user, repo, sha
|
|
42
|
-
tag.should be_a Hashie::Mash
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
context "resource not found" do
|
|
47
|
-
before do
|
|
48
|
-
stub_get("/repos/#{user}/#{repo}/git/tags/#{sha}").
|
|
49
|
-
to_return(:body => fixture('git_data/tag.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it "should fail to retrive resource" do
|
|
53
|
-
expect {
|
|
54
|
-
github.git_data.tags.get user, repo, sha
|
|
55
|
-
}.to raise_error(Github::Error::NotFound)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end # get
|
|
59
|
-
|
|
60
|
-
describe "#create" do
|
|
61
|
-
let(:inputs) {
|
|
62
|
-
{
|
|
63
|
-
"tag" => "v0.0.1",
|
|
64
|
-
"message" => "initial version\n",
|
|
65
|
-
"object" => {
|
|
66
|
-
"type" => "commit",
|
|
67
|
-
"sha" => "c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c",
|
|
68
|
-
"url" => "https://api.github.com/repos/octocat/Hello-World/git/commits/c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c"
|
|
69
|
-
},
|
|
70
|
-
"tagger" => {
|
|
71
|
-
"name" => "Scott Chacon",
|
|
72
|
-
"email" => "schacon@gmail.com",
|
|
73
|
-
"date" => "2011-06-17T14:53:35-07:00"
|
|
74
|
-
},
|
|
75
|
-
'unrelated' => 'giberrish'
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
context "resouce created" do
|
|
80
|
-
before do
|
|
81
|
-
stub_post("/repos/#{user}/#{repo}/git/tags").
|
|
82
|
-
with(inputs.except('unrelated')).
|
|
83
|
-
to_return(:body => fixture('git_data/tag.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it "should create resource successfully" do
|
|
87
|
-
github.git_data.tags.create user, repo, inputs
|
|
88
|
-
a_post("/repos/#{user}/#{repo}/git/tags").with(inputs).should have_been_made
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "should return the resource" do
|
|
92
|
-
tag = github.git_data.tags.create user, repo, inputs
|
|
93
|
-
tag.should be_a Hashie::Mash
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "should get the tag information" do
|
|
97
|
-
tag = github.git_data.tags.create user, repo, inputs
|
|
98
|
-
tag.sha.should == sha
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
context "failed to create resource" do
|
|
103
|
-
before do
|
|
104
|
-
stub_post("/repos/#{user}/#{repo}/git/tags").
|
|
105
|
-
with(inputs).
|
|
106
|
-
to_return(:body => fixture('git_data/tag.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
it "should faile to retrieve resource" do
|
|
110
|
-
expect {
|
|
111
|
-
github.git_data.tags.create user, repo, inputs
|
|
112
|
-
}.to raise_error(Github::Error::NotFound)
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end # create
|
|
116
|
-
|
|
117
9
|
end # Github::GitData::Tags
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::GitData::Trees, '#create' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:sha) { "9fb037999f264ba9a7fc6274d15fa3ae2ab98312" }
|
|
9
|
+
let(:request_path) { "/repos/#{user}/#{repo}/git/trees" }
|
|
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
|
+
let(:inputs) {
|
|
20
|
+
{
|
|
21
|
+
"tree" => [
|
|
22
|
+
{
|
|
23
|
+
"path" => "file.rb",
|
|
24
|
+
"mode" => "100644",
|
|
25
|
+
"type" => "blob",
|
|
26
|
+
"sha" => "44b4fc6d56897b048c772eb4087f854f46256132"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
context "resouce created" do
|
|
33
|
+
let(:body) { fixture('git_data/tree.json') }
|
|
34
|
+
let(:status) { 201 }
|
|
35
|
+
|
|
36
|
+
it "should fail to create resource if 'content' input is missing" do
|
|
37
|
+
expect {
|
|
38
|
+
subject.create user, repo, inputs.except('tree')
|
|
39
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should create resource successfully" do
|
|
43
|
+
subject.create user, repo, inputs
|
|
44
|
+
a_post(request_path).with(inputs).should have_been_made
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should return the resource" do
|
|
48
|
+
tree_sha = subject.create user, repo, inputs
|
|
49
|
+
tree_sha.should be_a Hashie::Mash
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "should get the tree information" do
|
|
53
|
+
tree_sha = subject.create user, repo, inputs
|
|
54
|
+
tree_sha.sha.should == sha
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it_should_behave_like 'request failure' do
|
|
59
|
+
let(:requestable) { subject.create user, repo, inputs }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end # create
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::GitData::Trees, '#get' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:sha) { "9fb037999f264ba9a7fc6274d15fa3ae2ab98312" }
|
|
9
|
+
let(:request_path) { "/repos/#{user}/#{repo}/git/trees/#{sha}" }
|
|
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 "non-resursive" do
|
|
19
|
+
let(:body) { fixture('git_data/tree.json') }
|
|
20
|
+
let(:status) { 200 }
|
|
21
|
+
|
|
22
|
+
it { should respond_to :find }
|
|
23
|
+
|
|
24
|
+
it "should fail to get resource without sha" do
|
|
25
|
+
expect { subject.get user, repo }.to raise_error(ArgumentError)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should get the resource" do
|
|
29
|
+
subject.get user, repo, sha
|
|
30
|
+
a_get(request_path).should have_been_made
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should get tree information" do
|
|
34
|
+
tree = subject.get user, repo, sha
|
|
35
|
+
tree.sha.should eql sha
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should return mash" do
|
|
39
|
+
tree = subject.get user, repo, sha
|
|
40
|
+
tree.should be_a Hashie::Mash
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context "resursive" do
|
|
45
|
+
let(:request_path) { "/repos/#{user}/#{repo}/git/trees/#{sha}?recursive=1" }
|
|
46
|
+
let(:body) { fixture('git_data/tree.json') }
|
|
47
|
+
let(:status) { 200 }
|
|
48
|
+
|
|
49
|
+
it "should get the resource" do
|
|
50
|
+
subject.get user, repo, sha, 'recursive' => true
|
|
51
|
+
a_get(request_path).should have_been_made
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should get tree information" do
|
|
55
|
+
tree = subject.get user, repo, sha, 'recursive' => true
|
|
56
|
+
tree.sha.should eql sha
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "should return mash" do
|
|
60
|
+
tree = subject.get user, repo, sha, 'recursive' => true
|
|
61
|
+
tree.should be_a Hashie::Mash
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it_should_behave_like 'request failure' do
|
|
66
|
+
let(:requestable) { subject.get user, repo, sha }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end # get
|
|
@@ -3,140 +3,7 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
describe Github::GitData::Trees do
|
|
6
|
-
let(:github) { Github.new }
|
|
7
|
-
let(:user) { 'peter-murach' }
|
|
8
|
-
let(:repo) { 'github' }
|
|
9
|
-
let(:sha) { "9fb037999f264ba9a7fc6274d15fa3ae2ab98312" }
|
|
10
|
-
|
|
11
|
-
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
|
12
6
|
|
|
13
7
|
it { described_class::VALID_TREE_PARAM_NAMES.should_not be_nil }
|
|
14
8
|
|
|
15
|
-
describe "#get" do
|
|
16
|
-
it { github.git_data.trees.should respond_to :find }
|
|
17
|
-
|
|
18
|
-
context "non-resursive" do
|
|
19
|
-
before do
|
|
20
|
-
stub_get("/repos/#{user}/#{repo}/git/trees/#{sha}").
|
|
21
|
-
to_return(:body => fixture('git_data/tree.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "should fail to get resource without sha" do
|
|
25
|
-
expect {
|
|
26
|
-
github.git_data.trees.get user, repo, nil
|
|
27
|
-
}.to raise_error(ArgumentError)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "should get the resource" do
|
|
31
|
-
github.git_data.trees.get user, repo, sha
|
|
32
|
-
a_get("/repos/#{user}/#{repo}/git/trees/#{sha}").should have_been_made
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "should get tree information" do
|
|
36
|
-
tree = github.git_data.trees.get user, repo, sha
|
|
37
|
-
tree.sha.should eql sha
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "should return mash" do
|
|
41
|
-
tree = github.git_data.trees.get user, repo, sha
|
|
42
|
-
tree.should be_a Hashie::Mash
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
context "resursive" do
|
|
47
|
-
before do
|
|
48
|
-
stub_get("/repos/#{user}/#{repo}/git/trees/#{sha}?recursive=1").
|
|
49
|
-
to_return(:body => fixture('git_data/tree.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it "should get the resource" do
|
|
53
|
-
github.git_data.trees.get user, repo, sha, 'recursive' => true
|
|
54
|
-
a_get("/repos/#{user}/#{repo}/git/trees/#{sha}?recursive=1").should have_been_made
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it "should get tree information" do
|
|
58
|
-
tree = github.git_data.trees.get user, repo, sha, 'recursive' => true
|
|
59
|
-
tree.sha.should eql sha
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "should return mash" do
|
|
63
|
-
tree = github.git_data.trees.get user, repo, sha, 'recursive' => true
|
|
64
|
-
tree.should be_a Hashie::Mash
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
context "resource not found" do
|
|
69
|
-
before do
|
|
70
|
-
stub_get("/repos/#{user}/#{repo}/git/trees/#{sha}").
|
|
71
|
-
to_return(:body => fixture('git_data/tree.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it "should fail to retrive resource" do
|
|
75
|
-
expect {
|
|
76
|
-
github.git_data.trees.get user, repo, sha
|
|
77
|
-
}.to raise_error(Github::Error::NotFound)
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end # get
|
|
81
|
-
|
|
82
|
-
describe "#create" do
|
|
83
|
-
let(:inputs) {
|
|
84
|
-
{
|
|
85
|
-
"tree" => [
|
|
86
|
-
{
|
|
87
|
-
"path" => "file.rb",
|
|
88
|
-
"mode" => "100644",
|
|
89
|
-
"type" => "blob",
|
|
90
|
-
"sha" => "44b4fc6d56897b048c772eb4087f854f46256132"
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
context "resouce created" do
|
|
97
|
-
before do
|
|
98
|
-
stub_post("/repos/#{user}/#{repo}/git/trees").
|
|
99
|
-
with(inputs).
|
|
100
|
-
to_return(:body => fixture('git_data/tree.json'),
|
|
101
|
-
:status => 201,
|
|
102
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it "should fail to create resource if 'content' input is missing" do
|
|
106
|
-
expect {
|
|
107
|
-
github.git_data.trees.create user, repo, inputs.except('tree')
|
|
108
|
-
}.to raise_error(Github::Error::RequiredParams)
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
it "should create resource successfully" do
|
|
112
|
-
github.git_data.trees.create user, repo, inputs
|
|
113
|
-
a_post("/repos/#{user}/#{repo}/git/trees").with(inputs).should have_been_made
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
it "should return the resource" do
|
|
117
|
-
tree_sha = github.git_data.trees.create user, repo, inputs
|
|
118
|
-
tree_sha.should be_a Hashie::Mash
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
it "should get the tree information" do
|
|
122
|
-
tree_sha = github.git_data.trees.create user, repo, inputs
|
|
123
|
-
tree_sha.sha.should == sha
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
context "failed to create resource" do
|
|
128
|
-
before do
|
|
129
|
-
stub_post("/repos/#{user}/#{repo}/git/trees").with(inputs).
|
|
130
|
-
to_return(:body => fixture('git_data/tree.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
131
|
-
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
it "should faile to retrieve resource" do
|
|
135
|
-
expect {
|
|
136
|
-
github.git_data.trees.create user, repo, inputs
|
|
137
|
-
}.to raise_error(Github::Error::NotFound)
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end # create
|
|
141
|
-
|
|
142
9
|
end # Github::GitData::Trees
|