github_api 0.7.0 → 0.7.1
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 +11 -5
- data/Rakefile +2 -0
- data/features/repos/statuses.feature +12 -12
- data/lib/github_api/api.rb +1 -1
- data/lib/github_api/authorizations.rb +3 -3
- data/lib/github_api/events.rb +7 -7
- data/lib/github_api/gists.rb +7 -7
- data/lib/github_api/gists/comments.rb +4 -4
- data/lib/github_api/git_data/blobs.rb +2 -3
- data/lib/github_api/git_data/commits.rb +2 -3
- data/lib/github_api/git_data/references.rb +10 -17
- data/lib/github_api/git_data/tags.rb +2 -3
- data/lib/github_api/git_data/trees.rb +2 -3
- data/lib/github_api/issues.rb +4 -6
- data/lib/github_api/issues/assignees.rb +5 -4
- data/lib/github_api/issues/comments.rb +5 -10
- data/lib/github_api/issues/events.rb +2 -3
- data/lib/github_api/issues/labels.rb +11 -20
- data/lib/github_api/issues/milestones.rb +5 -8
- data/lib/github_api/orgs.rb +2 -2
- data/lib/github_api/orgs/members.rb +7 -7
- data/lib/github_api/orgs/teams.rb +13 -13
- data/lib/github_api/page_iterator.rb +3 -1
- data/lib/github_api/pull_requests.rb +8 -16
- data/lib/github_api/pull_requests/comments.rb +5 -10
- data/lib/github_api/repos.rb +27 -8
- data/lib/github_api/repos/collaborators.rb +4 -7
- data/lib/github_api/repos/commits.rb +9 -16
- data/lib/github_api/repos/downloads.rb +5 -7
- data/lib/github_api/repos/forks.rb +3 -3
- data/lib/github_api/repos/hooks.rb +10 -13
- data/lib/github_api/repos/keys.rb +5 -8
- data/lib/github_api/repos/pub_sub_hubbub.rb +4 -4
- data/lib/github_api/repos/starring.rb +4 -4
- data/lib/github_api/repos/statuses.rb +2 -2
- data/lib/github_api/repos/watching.rb +4 -4
- data/lib/github_api/users/followers.rb +3 -3
- data/lib/github_api/users/keys.rb +3 -3
- data/lib/github_api/validations/presence.rb +16 -17
- data/lib/github_api/version.rb +1 -1
- data/spec/fixtures/repos/repos_sorted_by_pushed.json +56 -0
- data/spec/github/git_data_spec.rb +5 -7
- data/spec/github/issues_spec.rb +12 -12
- data/spec/github/orgs_spec.rb +2 -4
- data/spec/github/pull_requests_spec.rb +1 -1
- data/spec/github/repos/branch_spec.rb +48 -0
- data/spec/github/repos/branches_spec.rb +62 -0
- data/spec/github/repos/contributors_spec.rb +62 -0
- data/spec/github/repos/create_spec.rb +77 -0
- data/spec/github/repos/delete_spec.rb +43 -0
- data/spec/github/repos/downloads_spec.rb +51 -45
- data/spec/github/repos/edit_spec.rb +66 -0
- data/spec/github/repos/forks/create_spec.rb +49 -0
- data/spec/github/repos/forks/list_spec.rb +65 -0
- data/spec/github/repos/get_spec.rb +57 -0
- data/spec/github/repos/languages_spec.rb +61 -0
- data/spec/github/repos/list_spec.rb +99 -0
- data/spec/github/repos/tags_spec.rb +59 -0
- data/spec/github/repos/teams_spec.rb +59 -0
- data/spec/github/repos_spec.rb +13 -578
- data/spec/github/validations/presence_spec.rb +23 -4
- metadata +48 -42
- data/spec/github/repos/forks_spec.rb +0 -106
@@ -18,7 +18,7 @@ module Github
|
|
18
18
|
# :secret => '...'
|
19
19
|
#
|
20
20
|
def subscribe(topic, callback, params={})
|
21
|
-
|
21
|
+
assert_presence_of topic, callback
|
22
22
|
normalize! params
|
23
23
|
_merge_action!("subscribe", topic, callback, params)
|
24
24
|
|
@@ -40,7 +40,7 @@ module Github
|
|
40
40
|
# :secret => '...'
|
41
41
|
#
|
42
42
|
def unsubscribe(topic, callback, params={})
|
43
|
-
|
43
|
+
assert_presence_of topic, callback
|
44
44
|
normalize! params
|
45
45
|
_merge_action!("unsubscribe", topic, callback, params)
|
46
46
|
|
@@ -63,7 +63,7 @@ module Github
|
|
63
63
|
# :event => 'watch'
|
64
64
|
#
|
65
65
|
def subscribe_service(user_name, repo_name, service_name, params={})
|
66
|
-
|
66
|
+
assert_presence_of user_name, repo_name, service_name
|
67
67
|
normalize! params
|
68
68
|
event = params.delete('event') || 'push'
|
69
69
|
topic = "https://github.com/#{user_name}/#{repo_name}/events/#{event}"
|
@@ -86,7 +86,7 @@ module Github
|
|
86
86
|
# github.repos.pubsubhubbub.unsubscribe_service 'user-name', 'repo-name', 'campfire'
|
87
87
|
#
|
88
88
|
def unsubscribe_service(user_name, repo_name, service_name, params={})
|
89
|
-
|
89
|
+
assert_presence_of user_name, repo_name, service_name
|
90
90
|
normalize! params
|
91
91
|
event = params.delete('event') || 'push'
|
92
92
|
topic = "https://github.com/#{user_name}/#{repo_name}/events/#{event}"
|
@@ -14,7 +14,7 @@ module Github
|
|
14
14
|
#
|
15
15
|
def list(user_name, repo_name, params={})
|
16
16
|
_update_user_repo_params(user_name, repo_name)
|
17
|
-
|
17
|
+
assert_presence_of user, repo
|
18
18
|
normalize! params
|
19
19
|
|
20
20
|
response = get_request("/repos/#{user}/#{repo}/stargazers", params)
|
@@ -57,7 +57,7 @@ module Github
|
|
57
57
|
# github.repos.starring.starring? 'user-name', 'repo-name'
|
58
58
|
#
|
59
59
|
def starring?(user_name, repo_name, params={})
|
60
|
-
|
60
|
+
assert_presence_of user_name, repo_name
|
61
61
|
normalize! params
|
62
62
|
get_request("/user/starred/#{user_name}/#{repo_name}", params)
|
63
63
|
true
|
@@ -74,7 +74,7 @@ module Github
|
|
74
74
|
# github.repos.starring.star 'user-name', 'repo-name'
|
75
75
|
#
|
76
76
|
def star(user_name, repo_name, params={})
|
77
|
-
|
77
|
+
assert_presence_of user_name, repo_name
|
78
78
|
normalize! params
|
79
79
|
put_request("/user/starred/#{user_name}/#{repo_name}", params)
|
80
80
|
end
|
@@ -88,7 +88,7 @@ module Github
|
|
88
88
|
# github.repos.starring.unstar 'user-name', 'repo-name'
|
89
89
|
#
|
90
90
|
def unstar(user_name, repo_name, params={})
|
91
|
-
|
91
|
+
assert_presence_of user_name, repo_name
|
92
92
|
normalize! params
|
93
93
|
delete_request("/user/starred/#{user_name}/#{repo_name}", params)
|
94
94
|
end
|
@@ -23,7 +23,7 @@ module Github
|
|
23
23
|
#
|
24
24
|
def list(user_name, repo_name, sha, params={})
|
25
25
|
_update_user_repo_params(user_name, repo_name)
|
26
|
-
|
26
|
+
assert_presence_of user, repo
|
27
27
|
normalize! params
|
28
28
|
|
29
29
|
response = get_request("/repos/#{user}/#{repo}/statuses/#{sha}", params)
|
@@ -51,7 +51,7 @@ module Github
|
|
51
51
|
#
|
52
52
|
def create(user_name, repo_name, sha, params={})
|
53
53
|
_update_user_repo_params(user_name, repo_name)
|
54
|
-
|
54
|
+
assert_presence_of user, repo
|
55
55
|
|
56
56
|
normalize! params
|
57
57
|
filter! VALID_STATUS_PARAM_NAMES, params, :recursive => false
|
@@ -14,7 +14,7 @@ module Github
|
|
14
14
|
#
|
15
15
|
def list(user_name, repo_name, params={})
|
16
16
|
_update_user_repo_params(user_name, repo_name)
|
17
|
-
|
17
|
+
assert_presence_of user, repo
|
18
18
|
normalize! params
|
19
19
|
|
20
20
|
response = get_request("/repos/#{user}/#{repo}/subscribers", params)
|
@@ -56,7 +56,7 @@ module Github
|
|
56
56
|
# github.repos.watching.watching? 'user-name', 'repo-name'
|
57
57
|
#
|
58
58
|
def watching?(user_name, repo_name, params={})
|
59
|
-
|
59
|
+
assert_presence_of user_name, repo_name
|
60
60
|
normalize! params
|
61
61
|
get_request("/user/subscriptions/#{user_name}/#{repo_name}", params)
|
62
62
|
true
|
@@ -73,7 +73,7 @@ module Github
|
|
73
73
|
# github.repos.watching.watch 'user-name', 'repo-name'
|
74
74
|
#
|
75
75
|
def watch(user_name, repo_name, params={})
|
76
|
-
|
76
|
+
assert_presence_of user_name, repo_name
|
77
77
|
normalize! params
|
78
78
|
put_request("/user/subscriptions/#{user_name}/#{repo_name}", params)
|
79
79
|
end
|
@@ -86,7 +86,7 @@ module Github
|
|
86
86
|
# github.repos.watching.unwatch 'user-name', 'repo-name'
|
87
87
|
#
|
88
88
|
def unwatch(user_name, repo_name, params={})
|
89
|
-
|
89
|
+
assert_presence_of user_name, repo_name
|
90
90
|
normalize! params
|
91
91
|
delete_request("/user/subscriptions/#{user_name}/#{repo_name}", params)
|
92
92
|
end
|
@@ -61,7 +61,7 @@ module Github
|
|
61
61
|
# github.users.followers.following? 'user-name'
|
62
62
|
#
|
63
63
|
def following?(user_name, params={})
|
64
|
-
|
64
|
+
assert_presence_of user_name
|
65
65
|
normalize! params
|
66
66
|
get_request("/user/following/#{user_name}", params)
|
67
67
|
true
|
@@ -76,7 +76,7 @@ module Github
|
|
76
76
|
# github.users.followers.follow 'user-name'
|
77
77
|
#
|
78
78
|
def follow(user_name, params={})
|
79
|
-
|
79
|
+
assert_presence_of user_name
|
80
80
|
normalize! params
|
81
81
|
put_request("/user/following/#{user_name}", params)
|
82
82
|
end
|
@@ -88,7 +88,7 @@ module Github
|
|
88
88
|
# github.users.followers.unfollow 'user-name'
|
89
89
|
#
|
90
90
|
def unfollow(user_name, params={})
|
91
|
-
|
91
|
+
assert_presence_of user_name
|
92
92
|
normalize! params
|
93
93
|
delete_request("/user/following/#{user_name}", params)
|
94
94
|
end
|
@@ -27,7 +27,7 @@ module Github
|
|
27
27
|
# github.users.followers.get 'key-id'
|
28
28
|
#
|
29
29
|
def get(key_id, params={})
|
30
|
-
|
30
|
+
assert_presence_of key_id
|
31
31
|
normalize! params
|
32
32
|
get_request("/user/keys/#{key_id}", params)
|
33
33
|
end
|
@@ -62,7 +62,7 @@ module Github
|
|
62
62
|
# "key" => "ssh-rsa AAA..."
|
63
63
|
#
|
64
64
|
def update(key_id, params={})
|
65
|
-
|
65
|
+
assert_presence_of key_id
|
66
66
|
normalize! params
|
67
67
|
filter! VALID_KEY_PARAM_NAMES, params
|
68
68
|
patch_request("/user/keys/#{key_id}", params)
|
@@ -75,7 +75,7 @@ module Github
|
|
75
75
|
# github.users.followers.delete 'key-id'
|
76
76
|
#
|
77
77
|
def delete(key_id, params={})
|
78
|
-
|
78
|
+
assert_presence_of key_id
|
79
79
|
normalize! params
|
80
80
|
delete_request("/user/keys/#{key_id}", params)
|
81
81
|
end
|
@@ -2,28 +2,27 @@
|
|
2
2
|
|
3
3
|
module Github
|
4
4
|
module Validations
|
5
|
+
# A mixin to help validate presence of non-empty values
|
5
6
|
module Presence
|
6
7
|
|
7
|
-
#
|
8
|
-
# Ensures that esential arguments are present before request is made
|
8
|
+
# Ensure that esential arguments are present before request is made.
|
9
9
|
#
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
10
|
+
# == Parameters
|
11
|
+
# Hash/Array of arguments to be checked against nil and empty string
|
12
|
+
#
|
13
|
+
# == Example
|
14
|
+
# assert_presence_of user: '...', repo: '...'
|
15
|
+
# assert_presence_of user, repo
|
16
|
+
#
|
17
|
+
def assert_presence_of(*args)
|
18
|
+
hash = args.last.is_a?(::Hash) ? args.pop : {}
|
20
19
|
|
20
|
+
errors = hash.select { |key, val| val.to_s.empty? }
|
21
|
+
raise Github::Error::Validations.new(errors) unless errors.empty?
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
raise ArgumentError, "[user] parameter cannot be nil" if user_name.nil?
|
26
|
-
raise ArgumentError, "[repo] parameter cannot be nil" if repo_name.nil?
|
23
|
+
args.each do |arg|
|
24
|
+
raise ArgumentError, "parameter cannot be nil" if arg.nil?
|
25
|
+
end
|
27
26
|
end
|
28
27
|
|
29
28
|
end # Presence
|
data/lib/github_api/version.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"url": "https://api.github.com/repos/octocat/Hello-World-2",
|
4
|
+
"html_url": "https://github.com/octocat/Hello-World-2",
|
5
|
+
"clone_url": "https://github.com/octocat/Hello-World-2.git",
|
6
|
+
"git_url": "git://github.com/octocat/Hello-World-2.git",
|
7
|
+
"ssh_url": "git@github.com:octocat/Hello-World-2.git",
|
8
|
+
"svn_url": "https://svn.github.com/octocat/Hello-World-2",
|
9
|
+
"owner": {
|
10
|
+
"login": "octocat",
|
11
|
+
"id": 1,
|
12
|
+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
13
|
+
"url": "https://api.github.com/users/octocat"
|
14
|
+
},
|
15
|
+
"name": "Hello-World-2",
|
16
|
+
"description": "This your second repo!",
|
17
|
+
"homepage": "https://github.com",
|
18
|
+
"language": null,
|
19
|
+
"private": false,
|
20
|
+
"fork": false,
|
21
|
+
"forks": 9,
|
22
|
+
"watchers": 80,
|
23
|
+
"size": 108,
|
24
|
+
"master_branch": "master",
|
25
|
+
"open_issues": 0,
|
26
|
+
"pushed_at": "2011-02-26T19:06:43Z",
|
27
|
+
"created_at": "2011-02-26T19:01:12Z"
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"url": "https://api.github.com/repos/octocat/Hello-World",
|
31
|
+
"html_url": "https://github.com/octocat/Hello-World",
|
32
|
+
"clone_url": "https://github.com/octocat/Hello-World.git",
|
33
|
+
"git_url": "git://github.com/octocat/Hello-World.git",
|
34
|
+
"ssh_url": "git@github.com:octocat/Hello-World.git",
|
35
|
+
"svn_url": "https://svn.github.com/octocat/Hello-World",
|
36
|
+
"owner": {
|
37
|
+
"login": "octocat",
|
38
|
+
"id": 1,
|
39
|
+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
40
|
+
"url": "https://api.github.com/users/octocat"
|
41
|
+
},
|
42
|
+
"name": "Hello-World",
|
43
|
+
"description": "This your first repo!",
|
44
|
+
"homepage": "https://github.com",
|
45
|
+
"language": null,
|
46
|
+
"private": false,
|
47
|
+
"fork": false,
|
48
|
+
"forks": 9,
|
49
|
+
"watchers": 80,
|
50
|
+
"size": 108,
|
51
|
+
"master_branch": "master",
|
52
|
+
"open_issues": 0,
|
53
|
+
"pushed_at": "2011-01-26T19:06:43Z",
|
54
|
+
"created_at": "2011-01-26T19:01:12Z"
|
55
|
+
}
|
56
|
+
]
|
@@ -2,12 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Github::GitData do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
it { subject.trees.should be_a Github::GitData::Trees }
|
11
|
-
end
|
5
|
+
its(:blobs) { should be_a Github::GitData::Blobs }
|
6
|
+
its(:commits) { should be_a Github::GitData::Commits }
|
7
|
+
its(:references) { should be_a Github::GitData::References }
|
8
|
+
its(:tags) { should be_a Github::GitData::Tags }
|
9
|
+
its(:trees) { should be_a Github::GitData::Trees }
|
12
10
|
|
13
11
|
end # Github::GitData
|
data/spec/github/issues_spec.rb
CHANGED
@@ -11,20 +11,19 @@ describe Github::Issues do
|
|
11
11
|
|
12
12
|
after { reset_authentication_for github }
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
it { subject.milestones.should be_a Github::Issues::Milestones }
|
19
|
-
end
|
14
|
+
its(:comments) { should be_a Github::Issues::Comments }
|
15
|
+
its(:events) { should be_a Github::Issues::Events }
|
16
|
+
its(:labels) { should be_a Github::Issues::Labels }
|
17
|
+
its(:milestones) { should be_a Github::Issues::Milestones }
|
20
18
|
|
21
19
|
context '#list' do
|
22
|
-
it {
|
20
|
+
it { should respond_to(:all) }
|
23
21
|
|
24
22
|
context "resource found" do
|
25
23
|
before do
|
26
24
|
stub_get("/issues").
|
27
|
-
to_return(:body => fixture('issues/issues.json'), :status => 200,
|
25
|
+
to_return(:body => fixture('issues/issues.json'), :status => 200,
|
26
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
28
27
|
end
|
29
28
|
|
30
29
|
it "should get the resources" do
|
@@ -67,12 +66,13 @@ describe Github::Issues do
|
|
67
66
|
end # list
|
68
67
|
|
69
68
|
describe '#list_repo' do
|
70
|
-
it {
|
69
|
+
it { should respond_to :list_repository }
|
71
70
|
|
72
71
|
context "resource found" do
|
73
72
|
before do
|
74
73
|
stub_get("/repos/#{user}/#{repo}/issues").
|
75
|
-
to_return(:body => fixture('issues/issues.json'), :status => 200,
|
74
|
+
to_return(:body => fixture('issues/issues.json'), :status => 200,
|
75
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should raise error if user-name empty" do
|
@@ -123,7 +123,7 @@ describe Github::Issues do
|
|
123
123
|
end # list_repo
|
124
124
|
|
125
125
|
describe "#get" do
|
126
|
-
it {
|
126
|
+
it { should respond_to :find }
|
127
127
|
|
128
128
|
context "resource found" do
|
129
129
|
before do
|
@@ -279,6 +279,6 @@ describe Github::Issues do
|
|
279
279
|
}.to raise_error(Github::Error::NotFound)
|
280
280
|
end
|
281
281
|
end
|
282
|
-
end #
|
282
|
+
end # edit
|
283
283
|
|
284
284
|
end # Github::Issues
|
data/spec/github/orgs_spec.rb
CHANGED
@@ -10,10 +10,8 @@ describe Github::Orgs do
|
|
10
10
|
|
11
11
|
after { reset_authentication_for github }
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
it { subject.teams.should be_a Github::Orgs::Teams }
|
16
|
-
end
|
13
|
+
its(:members) { should be_a Github::Orgs::Members }
|
14
|
+
its(:teams) { should be_a Github::Orgs::Teams }
|
17
15
|
|
18
16
|
describe "#list" do
|
19
17
|
context "resource found for a user" do
|
@@ -9,7 +9,7 @@ describe Github::PullRequests do
|
|
9
9
|
after { reset_authentication_for github }
|
10
10
|
|
11
11
|
describe "#list" do
|
12
|
-
it {
|
12
|
+
it { should respond_to :all }
|
13
13
|
|
14
14
|
context 'resource found' do
|
15
15
|
let(:inputs) { { 'state'=> 'closed', 'unrelated' => true } }
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Repos, '#branch' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:request_path) { "/repos/#{user}/#{repo}/branches/#{branch}" }
|
9
|
+
let(:branch) { 'master' }
|
10
|
+
|
11
|
+
after { reset_authentication_for subject }
|
12
|
+
|
13
|
+
before {
|
14
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
15
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
16
|
+
}
|
17
|
+
|
18
|
+
context "resource found" do
|
19
|
+
let(:body) { fixture('repos/branch.json') }
|
20
|
+
let(:status) { 200 }
|
21
|
+
|
22
|
+
it "should find resources" do
|
23
|
+
subject.branch user, repo, branch
|
24
|
+
a_get(request_path).should have_been_made
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return repository mash" do
|
28
|
+
repo_branch = subject.branch user, repo, branch
|
29
|
+
repo_branch.should be_a Hashie::Mash
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should get repository branch information" do
|
33
|
+
repo_branch = subject.branch user, repo, branch
|
34
|
+
repo_branch.name.should == 'master'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "resource not found" do
|
39
|
+
let(:body) { '' }
|
40
|
+
let(:status) { 404 }
|
41
|
+
|
42
|
+
it "should fail to get resource" do
|
43
|
+
expect {
|
44
|
+
subject.branch user, repo, branch
|
45
|
+
}.to raise_error(Github::Error::NotFound)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end # branch
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Repos, '#branches' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:request_path) { "/repos/#{user}/#{repo}/branches" }
|
9
|
+
|
10
|
+
after { reset_authentication_for subject }
|
11
|
+
|
12
|
+
before {
|
13
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
14
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
15
|
+
}
|
16
|
+
|
17
|
+
context "resource found" do
|
18
|
+
let(:body) { fixture('repos/branches.json') }
|
19
|
+
let(:status) { 200 }
|
20
|
+
|
21
|
+
it "should raise error when no user/repo parameters" do
|
22
|
+
expect { subject.branches nil, repo }.to raise_error(ArgumentError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise error when no repository" do
|
26
|
+
expect { subject.branches user, nil }.to raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should find resources" do
|
30
|
+
subject.branches user, repo
|
31
|
+
a_get(request_path).should have_been_made
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return array of resources" do
|
35
|
+
branches = subject.branches user, repo
|
36
|
+
branches.should be_an Array
|
37
|
+
branches.should have(1).items
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should get branch information" do
|
41
|
+
branches = subject.branches user, repo
|
42
|
+
branches.first.name.should == 'master'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should yield to a block" do
|
46
|
+
block = lambda { |el| repo }
|
47
|
+
subject.should_receive(:branches).with(user, repo).and_yield repo
|
48
|
+
subject.branches(user, repo, &block)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "resource not found" do
|
53
|
+
let(:body) { '' }
|
54
|
+
let(:status) { 404 }
|
55
|
+
|
56
|
+
it "should fail to get resource" do
|
57
|
+
expect {
|
58
|
+
subject.branches user, repo
|
59
|
+
}.to raise_error(Github::Error::NotFound)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end # branches
|