github_api 0.4.11 → 0.5.0.rc1
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 +76 -72
- data/features/cassettes/gists/starred.yml +48 -0
- data/features/cassettes/pagination/repos/commits/list.yml +193 -0
- data/features/cassettes/pagination/repos/commits/next.yml +183 -0
- data/features/cassettes/pagination/repos/diff/next.yml +45 -0
- data/features/cassettes/pagination/repos/list.yml +176 -0
- data/features/cassettes/pagination/repos/list/next.yml +222 -0
- data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
- data/features/cassettes/repos/list.yml +92 -0
- data/features/error_codes.feature +1 -1
- data/features/gists.feature +12 -3
- data/features/gists/comments.feature +3 -3
- data/features/github_api.feature +13 -2
- data/features/pagination.feature +40 -39
- data/features/repos.feature +2 -2
- data/features/step_definitions/common_steps.rb +12 -0
- data/features/step_definitions/github_api_steps.rb +12 -1
- data/lib/github_api.rb +1 -1
- data/lib/github_api/api.rb +4 -2
- data/lib/github_api/api_factory.rb +11 -5
- data/lib/github_api/authorizations.rb +23 -32
- data/lib/github_api/client.rb +1 -0
- data/lib/github_api/events.rb +38 -38
- data/lib/github_api/filter.rb +1 -1
- data/lib/github_api/gists.rb +47 -42
- data/lib/github_api/gists/comments.rb +77 -84
- data/lib/github_api/git_data.rb +25 -6
- data/lib/github_api/git_data/blobs.rb +48 -45
- data/lib/github_api/git_data/commits.rb +76 -73
- data/lib/github_api/git_data/references.rb +137 -118
- data/lib/github_api/git_data/tags.rb +74 -70
- data/lib/github_api/git_data/trees.rb +88 -85
- data/lib/github_api/issues.rb +43 -31
- data/lib/github_api/issues/comments.rb +116 -119
- data/lib/github_api/issues/events.rb +20 -19
- data/lib/github_api/issues/labels.rb +200 -197
- data/lib/github_api/issues/milestones.rb +137 -134
- data/lib/github_api/orgs.rb +27 -23
- data/lib/github_api/orgs/members.rb +105 -108
- data/lib/github_api/orgs/teams.rb +236 -237
- data/lib/github_api/paged_request.rb +1 -1
- data/lib/github_api/pull_requests.rb +40 -42
- data/lib/github_api/pull_requests/comments.rb +140 -143
- data/lib/github_api/repos.rb +101 -67
- data/lib/github_api/repos/collaborators.rb +64 -68
- data/lib/github_api/repos/commits.rb +50 -39
- data/lib/github_api/repos/downloads.rb +107 -110
- data/lib/github_api/repos/forks.rb +38 -39
- data/lib/github_api/repos/hooks.rb +161 -167
- data/lib/github_api/repos/keys.rb +86 -86
- data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
- data/lib/github_api/repos/watching.rb +80 -82
- data/lib/github_api/request.rb +5 -9
- data/lib/github_api/users.rb +26 -16
- data/lib/github_api/users/emails.rb +47 -47
- data/lib/github_api/users/followers.rb +85 -86
- data/lib/github_api/users/keys.rb +73 -75
- data/lib/github_api/validations.rb +25 -0
- data/lib/github_api/validations/format.rb +23 -0
- data/lib/github_api/validations/presence.rb +25 -0
- data/lib/github_api/validations/required.rb +21 -0
- data/lib/github_api/validations/token.rb +41 -0
- data/lib/github_api/version.rb +3 -3
- data/spec/fixtures/repos/commit_comparison.json +112 -0
- data/spec/github/api_factory_spec.rb +17 -1
- data/spec/github/authorizations_spec.rb +36 -34
- data/spec/github/gists/comments_spec.rb +39 -45
- data/spec/github/gists_spec.rb +50 -53
- data/spec/github/git_data/blobs_spec.rb +27 -20
- data/spec/github/git_data/commits_spec.rb +20 -19
- data/spec/github/git_data/references_spec.rb +83 -46
- data/spec/github/git_data/tags_spec.rb +16 -15
- data/spec/github/git_data/trees_spec.rb +20 -19
- data/spec/github/git_data_spec.rb +10 -1
- data/spec/github/issues/comments_spec.rb +78 -68
- data/spec/github/issues/events_spec.rb +42 -34
- data/spec/github/issues/labels_spec.rb +89 -101
- data/spec/github/issues/milestones_spec.rb +76 -54
- data/spec/github/issues_spec.rb +53 -57
- data/spec/github/orgs/members_spec.rb +64 -49
- data/spec/github/orgs/teams_spec.rb +112 -101
- data/spec/github/orgs_spec.rb +41 -31
- data/spec/github/paged_request_spec.rb +6 -5
- data/spec/github/pull_requests/comments_spec.rb +39 -44
- data/spec/github/pull_requests_spec.rb +32 -48
- data/spec/github/repos/collaborators_spec.rb +40 -29
- data/spec/github/repos/commits_spec.rb +108 -64
- data/spec/github/repos/downloads_spec.rb +46 -45
- data/spec/github/repos/forks_spec.rb +23 -24
- data/spec/github/repos/hooks_spec.rb +69 -71
- data/spec/github/repos/keys_spec.rb +39 -34
- data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
- data/spec/github/repos/watching_spec.rb +31 -33
- data/spec/github/repos_spec.rb +74 -83
- data/spec/github/request_spec.rb +31 -2
- data/spec/github/users/emails_spec.rb +19 -17
- data/spec/github/users/followers_spec.rb +30 -28
- data/spec/github/users/keys_spec.rb +37 -33
- data/spec/github/users_spec.rb +124 -125
- data/spec/github/validations/format_spec.rb +42 -0
- data/spec/github/validations/presence_spec.rb +18 -0
- data/spec/github/validations/required_spec.rb +28 -0
- data/spec/github/validations/token_spec.rb +19 -0
- data/spec/github/validations_spec.rb +23 -0
- metadata +33 -10
- data/features/cassettes/pagination/repos.yml +0 -177
- data/features/cassettes/pagination/repos/next.yml +0 -177
- data/lib/github_api/validation.rb +0 -53
- data/spec/github/validation_spec.rb +0 -62
|
@@ -8,49 +8,49 @@ describe Github::Issues::Events do
|
|
|
8
8
|
let(:repo) { 'github' }
|
|
9
9
|
let(:issue_id) { 1 }
|
|
10
10
|
|
|
11
|
-
after {
|
|
11
|
+
after { reset_authentication_for github }
|
|
12
12
|
|
|
13
|
-
describe '
|
|
14
|
-
it { github.issues.should respond_to :
|
|
15
|
-
it { github.issues.should respond_to :list_events }
|
|
16
|
-
it { github.issues.should respond_to :issue_events }
|
|
17
|
-
it { github.issues.should respond_to :repo_events }
|
|
13
|
+
describe '#list' do
|
|
14
|
+
it { github.issues.comments.should respond_to :all }
|
|
18
15
|
|
|
19
16
|
context 'without issue_id' do
|
|
20
17
|
context "resource found" do
|
|
21
18
|
before do
|
|
22
19
|
stub_get("/repos/#{user}/#{repo}/issues/events").
|
|
23
|
-
to_return(:body => fixture('issues/events.json'),
|
|
20
|
+
to_return(:body => fixture('issues/events.json'),
|
|
21
|
+
:status => 200,
|
|
22
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
it "should fail to get resource without username" do
|
|
27
|
-
expect { github.issues.events }.to raise_error(ArgumentError)
|
|
26
|
+
expect { github.issues.events.list }.to raise_error(ArgumentError)
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
it "should get the resources" do
|
|
31
|
-
github.issues.events user, repo
|
|
30
|
+
github.issues.events.list user, repo
|
|
32
31
|
a_get("/repos/#{user}/#{repo}/issues/events").should have_been_made
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
it "should return array of resources" do
|
|
36
|
-
events = github.issues.events user, repo
|
|
35
|
+
events = github.issues.events.list user, repo
|
|
37
36
|
events.should be_an Array
|
|
38
37
|
events.should have(1).items
|
|
39
38
|
end
|
|
40
39
|
|
|
41
40
|
it "should be a mash type" do
|
|
42
|
-
events = github.issues.events user, repo
|
|
41
|
+
events = github.issues.events.list user, repo
|
|
43
42
|
events.first.should be_a Hashie::Mash
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
it "should get issue information" do
|
|
47
|
-
events = github.issues.events user, repo
|
|
46
|
+
events = github.issues.events.list user, repo
|
|
48
47
|
events.first.actor.login.should == 'octocat'
|
|
49
48
|
end
|
|
50
49
|
|
|
51
50
|
it "should yield to a block" do
|
|
52
|
-
github.issues.should_receive(:
|
|
53
|
-
|
|
51
|
+
github.issues.events.should_receive(:list).
|
|
52
|
+
with(user, repo).and_yield('web')
|
|
53
|
+
github.issues.events.list(user, repo) { |param| 'web' }.should == 'web'
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -62,7 +62,7 @@ describe Github::Issues::Events do
|
|
|
62
62
|
|
|
63
63
|
it "should return 404 with a message 'Not Found'" do
|
|
64
64
|
expect {
|
|
65
|
-
github.issues.events user, repo
|
|
65
|
+
github.issues.events.list user, repo
|
|
66
66
|
}.to raise_error(Github::Error::NotFound)
|
|
67
67
|
end
|
|
68
68
|
end
|
|
@@ -76,63 +76,69 @@ describe Github::Issues::Events do
|
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
it "should get the resources" do
|
|
79
|
-
github.issues.events user, repo, issue_id
|
|
79
|
+
github.issues.events.list user, repo, issue_id
|
|
80
80
|
a_get("/repos/#{user}/#{repo}/issues/#{issue_id}/events").should have_been_made
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
it "should return array of resources" do
|
|
84
|
-
events = github.issues.events user, repo, issue_id
|
|
84
|
+
events = github.issues.events.list user, repo, issue_id
|
|
85
85
|
events.should be_an Array
|
|
86
86
|
events.should have(1).items
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
it "should be a mash type" do
|
|
90
|
-
events = github.issues.events user, repo, issue_id
|
|
90
|
+
events = github.issues.events.list user, repo, issue_id
|
|
91
91
|
events.first.should be_a Hashie::Mash
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
it "should get issue information" do
|
|
95
|
-
events = github.issues.events user, repo, issue_id
|
|
95
|
+
events = github.issues.events.list user, repo, issue_id
|
|
96
96
|
events.first.actor.login.should == 'octocat'
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
it "should yield to a block" do
|
|
100
|
-
github.issues.should_receive(:
|
|
101
|
-
|
|
100
|
+
github.issues.events.should_receive(:list).
|
|
101
|
+
with(user, repo, issue_id).and_yield('web')
|
|
102
|
+
github.issues.events.list(user, repo, issue_id) { |param| 'web' }.
|
|
103
|
+
should == 'web'
|
|
102
104
|
end
|
|
103
105
|
end
|
|
104
106
|
end # with issue_id
|
|
105
|
-
end #
|
|
107
|
+
end # list
|
|
106
108
|
|
|
107
|
-
describe "
|
|
109
|
+
describe "#get" do
|
|
108
110
|
let(:event_id) { 1 }
|
|
109
111
|
|
|
110
|
-
it { github.issues.should respond_to :
|
|
111
|
-
it { github.issues.should respond_to :get_event }
|
|
112
|
+
it { github.issues.events.should respond_to :find }
|
|
112
113
|
|
|
113
114
|
context "resource found" do
|
|
114
115
|
before do
|
|
115
116
|
stub_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").
|
|
116
|
-
to_return(:body => fixture('issues/event.json'),
|
|
117
|
+
to_return(:body => fixture('issues/event.json'),
|
|
118
|
+
:status => 200,
|
|
119
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
117
120
|
end
|
|
118
121
|
|
|
119
122
|
it "should fail to get resource without event id" do
|
|
120
|
-
expect {
|
|
123
|
+
expect {
|
|
124
|
+
github.issues.events.get user, repo, nil
|
|
125
|
+
}.to raise_error(ArgumentError)
|
|
121
126
|
end
|
|
122
127
|
|
|
123
128
|
it "should get the resource" do
|
|
124
|
-
github.issues.
|
|
125
|
-
a_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").
|
|
129
|
+
github.issues.events.get user, repo, event_id
|
|
130
|
+
a_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").
|
|
131
|
+
should have_been_made
|
|
126
132
|
end
|
|
127
133
|
|
|
128
134
|
it "should get event information" do
|
|
129
|
-
event = github.issues.
|
|
135
|
+
event = github.issues.events.get user, repo, event_id
|
|
130
136
|
event.actor.id.should == event_id
|
|
131
137
|
event.actor.login.should == 'octocat'
|
|
132
138
|
end
|
|
133
139
|
|
|
134
140
|
it "should return mash" do
|
|
135
|
-
event = github.issues.
|
|
141
|
+
event = github.issues.events.get user, repo, event_id
|
|
136
142
|
event.should be_a Hashie::Mash
|
|
137
143
|
end
|
|
138
144
|
end
|
|
@@ -140,15 +146,17 @@ describe Github::Issues::Events do
|
|
|
140
146
|
context "resource not found" do
|
|
141
147
|
before do
|
|
142
148
|
stub_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").
|
|
143
|
-
to_return(:body => fixture('issues/event.json'),
|
|
149
|
+
to_return(:body => fixture('issues/event.json'),
|
|
150
|
+
:status => 404,
|
|
151
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
144
152
|
end
|
|
145
153
|
|
|
146
154
|
it "should fail to retrive resource" do
|
|
147
155
|
expect {
|
|
148
|
-
github.issues.
|
|
156
|
+
github.issues.events.get user, repo, event_id
|
|
149
157
|
}.to raise_error(Github::Error::NotFound)
|
|
150
158
|
end
|
|
151
159
|
end
|
|
152
|
-
end #
|
|
160
|
+
end # get
|
|
153
161
|
|
|
154
162
|
end # Github::Issues:Events
|
|
@@ -4,14 +4,14 @@ describe Github::Issues::Labels do
|
|
|
4
4
|
let(:github) { Github.new }
|
|
5
5
|
let(:user) { 'peter-murach' }
|
|
6
6
|
let(:repo) { 'github' }
|
|
7
|
+
let(:label_id) { 1 }
|
|
7
8
|
|
|
8
9
|
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
|
9
10
|
|
|
10
11
|
it { described_class::VALID_LABEL_INPUTS.should_not be_nil }
|
|
11
12
|
|
|
12
|
-
describe '
|
|
13
|
-
it { github.issues.should respond_to :
|
|
14
|
-
it { github.issues.should respond_to :list_labels }
|
|
13
|
+
describe '#list' do
|
|
14
|
+
it { github.issues.should respond_to :all }
|
|
15
15
|
|
|
16
16
|
context "resource found" do
|
|
17
17
|
before do
|
|
@@ -20,34 +20,35 @@ describe Github::Issues::Labels do
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "should fail to get resource without username" do
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
expect {
|
|
24
|
+
github.issues.labels.list nil, repo
|
|
25
|
+
}.to raise_error(ArgumentError)
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
it "should get the resources" do
|
|
28
|
-
github.issues.labels user, repo
|
|
29
|
+
github.issues.labels.list user, repo
|
|
29
30
|
a_get("/repos/#{user}/#{repo}/labels").should have_been_made
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
it "should return array of resources" do
|
|
33
|
-
labels = github.issues.labels user, repo
|
|
34
|
+
labels = github.issues.labels.list user, repo
|
|
34
35
|
labels.should be_an Array
|
|
35
36
|
labels.should have(1).items
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
it "should be a mash type" do
|
|
39
|
-
labels = github.issues.labels user, repo
|
|
40
|
+
labels = github.issues.labels.list user, repo
|
|
40
41
|
labels.first.should be_a Hashie::Mash
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
it "should get issue information" do
|
|
44
|
-
labels = github.issues.labels user, repo
|
|
45
|
+
labels = github.issues.labels.list user, repo
|
|
45
46
|
labels.first.name.should == 'bug'
|
|
46
47
|
end
|
|
47
48
|
|
|
48
49
|
it "should yield to a block" do
|
|
49
|
-
github.issues.should_receive(:
|
|
50
|
-
github.issues.labels(user, repo) { |param| 'web' }.should == 'web'
|
|
50
|
+
github.issues.labels.should_receive(:list).with(user, repo).and_yield('web')
|
|
51
|
+
github.issues.labels.list(user, repo) { |param| 'web' }.should == 'web'
|
|
51
52
|
end
|
|
52
53
|
end
|
|
53
54
|
|
|
@@ -59,18 +60,13 @@ describe Github::Issues::Labels do
|
|
|
59
60
|
|
|
60
61
|
it "should return 404 with a message 'Not Found'" do
|
|
61
62
|
expect {
|
|
62
|
-
github.issues.labels user, repo
|
|
63
|
+
github.issues.labels.list user, repo
|
|
63
64
|
}.to raise_error(Github::Error::NotFound)
|
|
64
65
|
end
|
|
65
66
|
end
|
|
66
|
-
end #
|
|
67
|
-
|
|
68
|
-
describe "label" do
|
|
69
|
-
let(:label_id) { 1 }
|
|
70
|
-
|
|
71
|
-
it { github.issues.should respond_to :label }
|
|
72
|
-
it { github.issues.should respond_to :get_label }
|
|
67
|
+
end # list
|
|
73
68
|
|
|
69
|
+
describe "#find" do
|
|
74
70
|
context "resource found" do
|
|
75
71
|
before do
|
|
76
72
|
stub_get("/repos/#{user}/#{repo}/labels/#{label_id}").
|
|
@@ -78,21 +74,23 @@ describe Github::Issues::Labels do
|
|
|
78
74
|
end
|
|
79
75
|
|
|
80
76
|
it "should fail to get resource without label id" do
|
|
81
|
-
expect {
|
|
77
|
+
expect {
|
|
78
|
+
github.issues.labels.find(user, repo, nil)
|
|
79
|
+
}.to raise_error(ArgumentError)
|
|
82
80
|
end
|
|
83
81
|
|
|
84
82
|
it "should get the resource" do
|
|
85
|
-
github.issues.
|
|
83
|
+
github.issues.labels.find user, repo, label_id
|
|
86
84
|
a_get("/repos/#{user}/#{repo}/labels/#{label_id}").should have_been_made
|
|
87
85
|
end
|
|
88
86
|
|
|
89
87
|
it "should get label information" do
|
|
90
|
-
label = github.issues.
|
|
88
|
+
label = github.issues.labels.find user, repo, label_id
|
|
91
89
|
label.name.should == 'bug'
|
|
92
90
|
end
|
|
93
91
|
|
|
94
92
|
it "should return mash" do
|
|
95
|
-
label = github.issues.
|
|
93
|
+
label = github.issues.labels.find user, repo, label_id
|
|
96
94
|
label.should be_a Hashie::Mash
|
|
97
95
|
end
|
|
98
96
|
end
|
|
@@ -105,13 +103,13 @@ describe Github::Issues::Labels do
|
|
|
105
103
|
|
|
106
104
|
it "should fail to retrive resource" do
|
|
107
105
|
expect {
|
|
108
|
-
github.issues.
|
|
106
|
+
github.issues.labels.find user, repo, label_id
|
|
109
107
|
}.to raise_error(Github::Error::NotFound)
|
|
110
108
|
end
|
|
111
109
|
end
|
|
112
|
-
end #
|
|
110
|
+
end # find
|
|
113
111
|
|
|
114
|
-
describe "
|
|
112
|
+
describe "#create" do
|
|
115
113
|
let(:inputs) {
|
|
116
114
|
{
|
|
117
115
|
"name" => "API",
|
|
@@ -127,28 +125,28 @@ describe Github::Issues::Labels do
|
|
|
127
125
|
|
|
128
126
|
it "should fail to create resource if 'name' input is missing" do
|
|
129
127
|
expect {
|
|
130
|
-
github.issues.
|
|
128
|
+
github.issues.labels.create user, repo, inputs.except('name')
|
|
131
129
|
}.to raise_error(Github::Error::RequiredParams)
|
|
132
130
|
end
|
|
133
131
|
|
|
134
132
|
it "should fail to create resource if 'color' input is missing" do
|
|
135
133
|
expect {
|
|
136
|
-
github.issues.
|
|
134
|
+
github.issues.labels.create user, repo, inputs.except('color')
|
|
137
135
|
}.to raise_error(Github::Error::RequiredParams)
|
|
138
136
|
end
|
|
139
137
|
|
|
140
138
|
it "should create resource successfully" do
|
|
141
|
-
github.issues.
|
|
139
|
+
github.issues.labels.create user, repo, inputs
|
|
142
140
|
a_post("/repos/#{user}/#{repo}/labels").with(inputs).should have_been_made
|
|
143
141
|
end
|
|
144
142
|
|
|
145
143
|
it "should return the resource" do
|
|
146
|
-
label = github.issues.
|
|
144
|
+
label = github.issues.labels.create user, repo, inputs
|
|
147
145
|
label.should be_a Hashie::Mash
|
|
148
146
|
end
|
|
149
147
|
|
|
150
148
|
it "should get the label information" do
|
|
151
|
-
label = github.issues.
|
|
149
|
+
label = github.issues.labels.create user, repo, inputs
|
|
152
150
|
label.name.should == 'bug'
|
|
153
151
|
end
|
|
154
152
|
end
|
|
@@ -157,19 +155,17 @@ describe Github::Issues::Labels do
|
|
|
157
155
|
before do
|
|
158
156
|
stub_post("/repos/#{user}/#{repo}/labels").with(inputs).
|
|
159
157
|
to_return(:body => fixture('issues/label.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
160
|
-
|
|
161
158
|
end
|
|
162
159
|
|
|
163
160
|
it "should faile to retrieve resource" do
|
|
164
161
|
expect {
|
|
165
|
-
github.issues.
|
|
162
|
+
github.issues.labels.create user, repo, inputs
|
|
166
163
|
}.to raise_error(Github::Error::NotFound)
|
|
167
164
|
end
|
|
168
165
|
end
|
|
169
|
-
end #
|
|
166
|
+
end # create
|
|
170
167
|
|
|
171
|
-
describe "
|
|
172
|
-
let(:label_id) { 1 }
|
|
168
|
+
describe "#update" do
|
|
173
169
|
let(:inputs) {
|
|
174
170
|
{
|
|
175
171
|
"name" => "API",
|
|
@@ -185,28 +181,28 @@ describe Github::Issues::Labels do
|
|
|
185
181
|
|
|
186
182
|
it "should fail to create resource if 'name' input is missing" do
|
|
187
183
|
expect {
|
|
188
|
-
github.issues.
|
|
184
|
+
github.issues.labels.update user, repo, label_id, inputs.except('name')
|
|
189
185
|
}.to raise_error(Github::Error::RequiredParams)
|
|
190
186
|
end
|
|
191
187
|
|
|
192
188
|
it "should fail to create resource if 'color' input is missing" do
|
|
193
189
|
expect {
|
|
194
|
-
github.issues.
|
|
190
|
+
github.issues.labels.update user, repo, label_id, inputs.except('color')
|
|
195
191
|
}.to raise_error(Github::Error::RequiredParams)
|
|
196
192
|
end
|
|
197
193
|
|
|
198
194
|
it "should update resource successfully" do
|
|
199
|
-
github.issues.
|
|
195
|
+
github.issues.labels.update user, repo, label_id, inputs
|
|
200
196
|
a_patch("/repos/#{user}/#{repo}/labels/#{label_id}").with(inputs).should have_been_made
|
|
201
197
|
end
|
|
202
198
|
|
|
203
199
|
it "should return the resource" do
|
|
204
|
-
label = github.issues.
|
|
200
|
+
label = github.issues.labels.update user, repo, label_id, inputs
|
|
205
201
|
label.should be_a Hashie::Mash
|
|
206
202
|
end
|
|
207
203
|
|
|
208
204
|
it "should get the label information" do
|
|
209
|
-
label = github.issues.
|
|
205
|
+
label = github.issues.labels.update user, repo, label_id, inputs
|
|
210
206
|
label.name.should == 'bug'
|
|
211
207
|
end
|
|
212
208
|
end
|
|
@@ -215,20 +211,17 @@ describe Github::Issues::Labels do
|
|
|
215
211
|
before do
|
|
216
212
|
stub_patch("/repos/#{user}/#{repo}/labels/#{label_id}").with(inputs).
|
|
217
213
|
to_return(:body => fixture('issues/label.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
218
|
-
|
|
219
214
|
end
|
|
220
215
|
|
|
221
216
|
it "should faile to retrieve resource" do
|
|
222
217
|
expect {
|
|
223
|
-
github.issues.
|
|
218
|
+
github.issues.labels.update user, repo, label_id, inputs
|
|
224
219
|
}.to raise_error(Github::Error::NotFound)
|
|
225
220
|
end
|
|
226
221
|
end
|
|
227
|
-
end #
|
|
228
|
-
|
|
229
|
-
describe "delete_label" do
|
|
230
|
-
let(:label_id) { 1 }
|
|
222
|
+
end # update
|
|
231
223
|
|
|
224
|
+
describe "#delete" do
|
|
232
225
|
context "resouce removed" do
|
|
233
226
|
before do
|
|
234
227
|
stub_delete("/repos/#{user}/#{repo}/labels/#{label_id}").
|
|
@@ -236,17 +229,17 @@ describe Github::Issues::Labels do
|
|
|
236
229
|
end
|
|
237
230
|
|
|
238
231
|
it "should remove resource successfully" do
|
|
239
|
-
github.issues.
|
|
232
|
+
github.issues.labels.delete user, repo, label_id
|
|
240
233
|
a_delete("/repos/#{user}/#{repo}/labels/#{label_id}").should have_been_made
|
|
241
234
|
end
|
|
242
235
|
|
|
243
236
|
it "should return the resource" do
|
|
244
|
-
label = github.issues.
|
|
237
|
+
label = github.issues.labels.delete user, repo, label_id
|
|
245
238
|
label.should be_a Hashie::Mash
|
|
246
239
|
end
|
|
247
240
|
|
|
248
241
|
it "should get the label information" do
|
|
249
|
-
label = github.issues.
|
|
242
|
+
label = github.issues.labels.delete user, repo, label_id
|
|
250
243
|
label.name.should == 'bug'
|
|
251
244
|
end
|
|
252
245
|
end
|
|
@@ -259,18 +252,15 @@ describe Github::Issues::Labels do
|
|
|
259
252
|
|
|
260
253
|
it "should faile to retrieve resource" do
|
|
261
254
|
expect {
|
|
262
|
-
github.issues.
|
|
255
|
+
github.issues.labels.delete user, repo, label_id
|
|
263
256
|
}.to raise_error(Github::Error::NotFound)
|
|
264
257
|
end
|
|
265
258
|
end
|
|
266
|
-
end #
|
|
259
|
+
end # delete
|
|
267
260
|
|
|
268
|
-
describe '
|
|
261
|
+
describe '#issue' do
|
|
269
262
|
let(:issue_id) { 1 }
|
|
270
263
|
|
|
271
|
-
it { github.issues.should respond_to :labels_for }
|
|
272
|
-
it { github.issues.should respond_to :issue_labels }
|
|
273
|
-
|
|
274
264
|
context "resource found" do
|
|
275
265
|
before do
|
|
276
266
|
stub_get("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").
|
|
@@ -279,35 +269,36 @@ describe Github::Issues::Labels do
|
|
|
279
269
|
|
|
280
270
|
it "should fail to get resource without issue_id" do
|
|
281
271
|
expect {
|
|
282
|
-
github.issues.
|
|
272
|
+
github.issues.labels.issue user, repo, nil
|
|
283
273
|
}.to raise_error(ArgumentError)
|
|
284
274
|
end
|
|
285
275
|
|
|
286
276
|
it "should get the resources" do
|
|
287
|
-
github.issues.
|
|
277
|
+
github.issues.labels.issue user, repo, issue_id
|
|
288
278
|
a_get("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").
|
|
289
279
|
should have_been_made
|
|
290
280
|
end
|
|
291
281
|
|
|
292
282
|
it "should return array of resources" do
|
|
293
|
-
labels = github.issues.
|
|
283
|
+
labels = github.issues.labels.issue user, repo, issue_id
|
|
294
284
|
labels.should be_an Array
|
|
295
285
|
labels.should have(1).items
|
|
296
286
|
end
|
|
297
287
|
|
|
298
288
|
it "should be a mash type" do
|
|
299
|
-
labels = github.issues.
|
|
289
|
+
labels = github.issues.labels.issue user, repo, issue_id
|
|
300
290
|
labels.first.should be_a Hashie::Mash
|
|
301
291
|
end
|
|
302
292
|
|
|
303
293
|
it "should get issue information" do
|
|
304
|
-
labels = github.issues.
|
|
294
|
+
labels = github.issues.labels.issue user, repo, issue_id
|
|
305
295
|
labels.first.name.should == 'bug'
|
|
306
296
|
end
|
|
307
297
|
|
|
308
298
|
it "should yield to a block" do
|
|
309
|
-
github.issues.should_receive(:
|
|
310
|
-
|
|
299
|
+
github.issues.labels.should_receive(:issue).
|
|
300
|
+
with(user, repo, issue_id).and_yield('web')
|
|
301
|
+
github.issues.labels.issue(user, repo, issue_id) { |param| 'web' }.should == 'web'
|
|
311
302
|
end
|
|
312
303
|
end
|
|
313
304
|
|
|
@@ -319,13 +310,13 @@ describe Github::Issues::Labels do
|
|
|
319
310
|
|
|
320
311
|
it "should return 404 with a message 'Not Found'" do
|
|
321
312
|
expect {
|
|
322
|
-
github.issues.
|
|
313
|
+
github.issues.labels.issue user, repo, issue_id
|
|
323
314
|
}.to raise_error(Github::Error::NotFound)
|
|
324
315
|
end
|
|
325
316
|
end
|
|
326
|
-
end #
|
|
317
|
+
end # issue
|
|
327
318
|
|
|
328
|
-
describe "
|
|
319
|
+
describe "#add" do
|
|
329
320
|
let(:issue_id) { 1 }
|
|
330
321
|
let(:labels) { "Label 1" }
|
|
331
322
|
|
|
@@ -337,22 +328,22 @@ describe Github::Issues::Labels do
|
|
|
337
328
|
|
|
338
329
|
it "should fail to add labels if issue-id is missing" do
|
|
339
330
|
expect {
|
|
340
|
-
github.issues.
|
|
331
|
+
github.issues.labels.add user, repo, nil, labels
|
|
341
332
|
}.to raise_error(ArgumentError)
|
|
342
333
|
end
|
|
343
334
|
|
|
344
335
|
it "should create resource successfully" do
|
|
345
|
-
github.issues.
|
|
336
|
+
github.issues.labels.add user, repo, issue_id, labels
|
|
346
337
|
a_post("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").should have_been_made
|
|
347
338
|
end
|
|
348
339
|
|
|
349
340
|
it "should return the resource" do
|
|
350
|
-
labels = github.issues.
|
|
341
|
+
labels = github.issues.labels.add user, repo, issue_id, labels
|
|
351
342
|
labels.first.should be_a Hashie::Mash
|
|
352
343
|
end
|
|
353
344
|
|
|
354
345
|
it "should get the label information" do
|
|
355
|
-
labels = github.issues.
|
|
346
|
+
labels = github.issues.labels.add user, repo, issue_id, labels
|
|
356
347
|
labels.first.name.should == 'bug'
|
|
357
348
|
end
|
|
358
349
|
end
|
|
@@ -366,13 +357,13 @@ describe Github::Issues::Labels do
|
|
|
366
357
|
|
|
367
358
|
it "should fail to retrieve resource" do
|
|
368
359
|
expect {
|
|
369
|
-
github.issues.
|
|
360
|
+
github.issues.labels.add user, repo, issue_id, labels
|
|
370
361
|
}.to raise_error(Github::Error::NotFound)
|
|
371
362
|
end
|
|
372
363
|
end
|
|
373
|
-
end #
|
|
364
|
+
end # add
|
|
374
365
|
|
|
375
|
-
describe "
|
|
366
|
+
describe "#remove" do
|
|
376
367
|
let(:issue_id) { 1 }
|
|
377
368
|
let(:label_id) { 1 }
|
|
378
369
|
|
|
@@ -384,22 +375,22 @@ describe Github::Issues::Labels do
|
|
|
384
375
|
|
|
385
376
|
it "should throw exception if issue-id not present" do
|
|
386
377
|
expect {
|
|
387
|
-
github.issues.
|
|
378
|
+
github.issues.labels.remove user, repo, nil
|
|
388
379
|
}.to raise_error(ArgumentError)
|
|
389
380
|
end
|
|
390
381
|
|
|
391
382
|
it "should remove label successfully" do
|
|
392
|
-
github.issues.
|
|
383
|
+
github.issues.labels.remove user, repo, issue_id, label_id
|
|
393
384
|
a_delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_id}").should have_been_made
|
|
394
385
|
end
|
|
395
386
|
|
|
396
387
|
it "should return the resource" do
|
|
397
|
-
labels = github.issues.
|
|
388
|
+
labels = github.issues.labels.remove user, repo, issue_id, label_id
|
|
398
389
|
labels.first.should be_a Hashie::Mash
|
|
399
390
|
end
|
|
400
391
|
|
|
401
392
|
it "should get the label information" do
|
|
402
|
-
labels = github.issues.
|
|
393
|
+
labels = github.issues.labels.remove user, repo, issue_id, label_id
|
|
403
394
|
labels.first.name.should == 'bug'
|
|
404
395
|
end
|
|
405
396
|
end
|
|
@@ -411,7 +402,7 @@ describe Github::Issues::Labels do
|
|
|
411
402
|
end
|
|
412
403
|
|
|
413
404
|
it "should remove labels successfully" do
|
|
414
|
-
github.issues.
|
|
405
|
+
github.issues.labels.remove user, repo, issue_id
|
|
415
406
|
a_delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").should have_been_made
|
|
416
407
|
end
|
|
417
408
|
end
|
|
@@ -424,13 +415,13 @@ describe Github::Issues::Labels do
|
|
|
424
415
|
|
|
425
416
|
it "should faile to retrieve resource" do
|
|
426
417
|
expect {
|
|
427
|
-
github.issues.
|
|
418
|
+
github.issues.labels.remove user, repo, issue_id, label_id
|
|
428
419
|
}.to raise_error(Github::Error::NotFound)
|
|
429
420
|
end
|
|
430
421
|
end
|
|
431
|
-
end #
|
|
422
|
+
end # remove
|
|
432
423
|
|
|
433
|
-
describe "
|
|
424
|
+
describe "#replace" do
|
|
434
425
|
let(:issue_id) { 1 }
|
|
435
426
|
let(:labels) { "Label 1" }
|
|
436
427
|
|
|
@@ -442,22 +433,22 @@ describe Github::Issues::Labels do
|
|
|
442
433
|
|
|
443
434
|
it "should fail to add labels if issue-id is missing" do
|
|
444
435
|
expect {
|
|
445
|
-
github.issues.
|
|
436
|
+
github.issues.labels.replace user, repo, nil, labels
|
|
446
437
|
}.to raise_error(ArgumentError)
|
|
447
438
|
end
|
|
448
439
|
|
|
449
440
|
it "should create resource successfully" do
|
|
450
|
-
github.issues.
|
|
441
|
+
github.issues.labels.replace user, repo, issue_id, labels
|
|
451
442
|
a_put("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").should have_been_made
|
|
452
443
|
end
|
|
453
444
|
|
|
454
445
|
it "should return the resource" do
|
|
455
|
-
labels = github.issues.
|
|
446
|
+
labels = github.issues.labels.replace user, repo, issue_id, labels
|
|
456
447
|
labels.first.should be_a Hashie::Mash
|
|
457
448
|
end
|
|
458
449
|
|
|
459
450
|
it "should get the label information" do
|
|
460
|
-
labels = github.issues.
|
|
451
|
+
labels = github.issues.labels.replace user, repo, issue_id, labels
|
|
461
452
|
labels.first.name.should == 'bug'
|
|
462
453
|
end
|
|
463
454
|
end
|
|
@@ -471,19 +462,15 @@ describe Github::Issues::Labels do
|
|
|
471
462
|
|
|
472
463
|
it "should fail to retrieve resource" do
|
|
473
464
|
expect {
|
|
474
|
-
github.issues.
|
|
465
|
+
github.issues.labels.replace user, repo, issue_id, labels
|
|
475
466
|
}.to raise_error(Github::Error::NotFound)
|
|
476
467
|
end
|
|
477
468
|
end
|
|
478
|
-
end #
|
|
469
|
+
end # replace
|
|
479
470
|
|
|
480
|
-
describe '
|
|
471
|
+
describe '#milestone' do
|
|
481
472
|
let(:milestone_id) { 1 }
|
|
482
473
|
|
|
483
|
-
it { github.issues.should respond_to :milestone_labels }
|
|
484
|
-
it { github.issues.should respond_to :milestone_issues_labels }
|
|
485
|
-
it { github.issues.should respond_to :list_milestone_labels }
|
|
486
|
-
|
|
487
474
|
context "resource found" do
|
|
488
475
|
before do
|
|
489
476
|
stub_get("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels").
|
|
@@ -492,34 +479,35 @@ describe Github::Issues::Labels do
|
|
|
492
479
|
|
|
493
480
|
it "should throw exception if milestone-id not present" do
|
|
494
481
|
expect {
|
|
495
|
-
github.issues.
|
|
482
|
+
github.issues.labels.milestone user, repo, nil
|
|
496
483
|
}.to raise_error(ArgumentError)
|
|
497
484
|
end
|
|
498
485
|
|
|
499
486
|
it "should get the resources" do
|
|
500
|
-
github.issues.
|
|
487
|
+
github.issues.labels.milestone user, repo, milestone_id
|
|
501
488
|
a_get("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels").should have_been_made
|
|
502
489
|
end
|
|
503
490
|
|
|
504
491
|
it "should return array of resources" do
|
|
505
|
-
labels = github.issues.
|
|
492
|
+
labels = github.issues.labels.milestone user, repo, milestone_id
|
|
506
493
|
labels.should be_an Array
|
|
507
494
|
labels.should have(1).items
|
|
508
495
|
end
|
|
509
496
|
|
|
510
497
|
it "should be a mash type" do
|
|
511
|
-
labels = github.issues.
|
|
498
|
+
labels = github.issues.labels.milestone user, repo, milestone_id
|
|
512
499
|
labels.first.should be_a Hashie::Mash
|
|
513
500
|
end
|
|
514
501
|
|
|
515
502
|
it "should get issue information" do
|
|
516
|
-
labels = github.issues.
|
|
503
|
+
labels = github.issues.labels.milestone user, repo, milestone_id
|
|
517
504
|
labels.first.name.should == 'bug'
|
|
518
505
|
end
|
|
519
506
|
|
|
520
507
|
it "should yield to a block" do
|
|
521
|
-
github.issues.should_receive(:
|
|
522
|
-
|
|
508
|
+
github.issues.labels.should_receive(:milestone).
|
|
509
|
+
with(user, repo, milestone_id).and_yield('web')
|
|
510
|
+
github.issues.labels.milestone(user, repo, milestone_id) { |param| 'web' }.should == 'web'
|
|
523
511
|
end
|
|
524
512
|
end
|
|
525
513
|
|
|
@@ -531,10 +519,10 @@ describe Github::Issues::Labels do
|
|
|
531
519
|
|
|
532
520
|
it "should return 404 with a message 'Not Found'" do
|
|
533
521
|
expect {
|
|
534
|
-
github.issues.
|
|
522
|
+
github.issues.labels.milestone user, repo, milestone_id
|
|
535
523
|
}.to raise_error(Github::Error::NotFound)
|
|
536
524
|
end
|
|
537
525
|
end
|
|
538
|
-
end #
|
|
526
|
+
end # milestone
|
|
539
527
|
|
|
540
528
|
end # Github::Issues::Labels
|