github_api 0.8.4 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/features/cassettes/issues/comments/create.yml +55 -0
- data/features/cassettes/issues/comments/delete.yml +46 -0
- data/features/cassettes/issues/comments/edit.yml +53 -0
- data/features/issues/comments.feature +35 -0
- data/features/issues/labels.feature +3 -3
- data/features/issues/milestones.feature +3 -3
- data/lib/github_api/authorizations.rb +5 -3
- data/lib/github_api/repos.rb +1 -1
- data/lib/github_api/version.rb +1 -1
- data/spec/github/issues/comments/create_spec.rb +50 -0
- data/spec/github/issues/comments/delete_spec.rb +36 -0
- data/spec/github/issues/comments/edit_spec.rb +50 -0
- data/spec/github/issues/comments/get_spec.rb +49 -0
- data/spec/github/issues/comments/list_spec.rb +79 -0
- data/spec/github/issues/comments_spec.rb +0 -294
- data/spec/github/issues/events/get_spec.rb +49 -0
- data/spec/github/issues/events/list_spec.rb +84 -0
- data/spec/github/issues/events_spec.rb +0 -155
- data/spec/github/issues/labels/remove_spec.rb +58 -0
- data/spec/github/issues/labels/replace_spec.rb +50 -0
- data/spec/github/issues/labels_spec.rb +1 -112
- metadata +44 -32
@@ -0,0 +1,84 @@
|
|
1
|
+
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe Github::Issues::Events, '#list' do
|
7
|
+
let(:user) { 'peter-murach' }
|
8
|
+
let(:repo) { 'github' }
|
9
|
+
let(:issue_id) { 1 }
|
10
|
+
let(:request_path) { "/repos/#{user}/#{repo}/issues/events" }
|
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
|
+
after { reset_authentication_for(subject) }
|
18
|
+
|
19
|
+
context 'without issue_id' do
|
20
|
+
let(:body) { fixture('issues/events.json') }
|
21
|
+
let(:status) { 200 }
|
22
|
+
|
23
|
+
context "resource found" do
|
24
|
+
|
25
|
+
it { subject.should respond_to :all }
|
26
|
+
|
27
|
+
it "should fail to get resource without username" do
|
28
|
+
expect { subject.list }.to raise_error(ArgumentError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should get the resources" do
|
32
|
+
subject.list user, repo
|
33
|
+
a_get(request_path).should have_been_made
|
34
|
+
end
|
35
|
+
|
36
|
+
it_should_behave_like 'an array of resources' do
|
37
|
+
let(:requestable) { subject.list user, repo }
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should get issue information" do
|
41
|
+
events = subject.list user, repo
|
42
|
+
events.first.actor.login.should == 'octocat'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should yield to a block" do
|
46
|
+
yielded = []
|
47
|
+
result = subject.list(user, repo) { |obj| yielded << obj }
|
48
|
+
yielded.should == result
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it_should_behave_like 'request failure' do
|
53
|
+
let(:requestable) { subject.list user, repo }
|
54
|
+
end
|
55
|
+
end # without issue_id
|
56
|
+
|
57
|
+
context 'with issue_id' do
|
58
|
+
let(:request_path) { "/repos/#{user}/#{repo}/issues/#{issue_id}/events" }
|
59
|
+
let(:body) { fixture('issues/events.json') }
|
60
|
+
let(:status) { 200 }
|
61
|
+
|
62
|
+
context "resource found" do
|
63
|
+
it "should get the resources" do
|
64
|
+
subject.list user, repo, :issue_id => issue_id
|
65
|
+
a_get(request_path).should have_been_made
|
66
|
+
end
|
67
|
+
|
68
|
+
it_should_behave_like 'an array of resources' do
|
69
|
+
let(:requestable) { subject.list user, repo, :issue_id => issue_id }
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should get issue information" do
|
73
|
+
events = subject.list user, repo, :issue_id => issue_id
|
74
|
+
events.first.actor.login.should == 'octocat'
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should yield to a block" do
|
78
|
+
yielded = []
|
79
|
+
result = subject.list(user, repo, :issue_id => issue_id) { |obj| yielded << obj }
|
80
|
+
yielded.should == result
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end # with issue_id
|
84
|
+
end # list
|
@@ -3,160 +3,5 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Github::Issues::Events do
|
6
|
-
let(:github) { Github.new }
|
7
|
-
let(:user) { 'peter-murach' }
|
8
|
-
let(:repo) { 'github' }
|
9
|
-
let(:issue_id) { 1 }
|
10
|
-
|
11
|
-
after { reset_authentication_for github }
|
12
|
-
|
13
|
-
describe '#list' do
|
14
|
-
it { github.issues.comments.should respond_to :all }
|
15
|
-
|
16
|
-
context 'without issue_id' do
|
17
|
-
context "resource found" do
|
18
|
-
before do
|
19
|
-
stub_get("/repos/#{user}/#{repo}/issues/events").
|
20
|
-
to_return(:body => fixture('issues/events.json'),
|
21
|
-
:status => 200,
|
22
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should fail to get resource without username" do
|
26
|
-
expect { github.issues.events.list }.to raise_error(ArgumentError)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should get the resources" do
|
30
|
-
github.issues.events.list user, repo
|
31
|
-
a_get("/repos/#{user}/#{repo}/issues/events").should have_been_made
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should return array of resources" do
|
35
|
-
events = github.issues.events.list user, repo
|
36
|
-
events.should be_an Array
|
37
|
-
events.should have(1).items
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should be a mash type" do
|
41
|
-
events = github.issues.events.list user, repo
|
42
|
-
events.first.should be_a Hashie::Mash
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should get issue information" do
|
46
|
-
events = github.issues.events.list user, repo
|
47
|
-
events.first.actor.login.should == 'octocat'
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should yield to a block" do
|
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
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context "resource not found" do
|
58
|
-
before do
|
59
|
-
stub_get("/repos/#{user}/#{repo}/issues/events").
|
60
|
-
to_return(:body => "", :status => [404, "Not Found"])
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should return 404 with a message 'Not Found'" do
|
64
|
-
expect {
|
65
|
-
github.issues.events.list user, repo
|
66
|
-
}.to raise_error(Github::Error::NotFound)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end # without issue_id
|
70
|
-
|
71
|
-
context 'with issue_id' do
|
72
|
-
context "resource found" do
|
73
|
-
before do
|
74
|
-
stub_get("/repos/#{user}/#{repo}/issues/#{issue_id}/events").
|
75
|
-
to_return(:body => fixture('issues/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should get the resources" do
|
79
|
-
github.issues.events.list user, repo, :issue_id => issue_id
|
80
|
-
a_get("/repos/#{user}/#{repo}/issues/#{issue_id}/events").should have_been_made
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should return array of resources" do
|
84
|
-
events = github.issues.events.list user, repo, :issue_id => issue_id
|
85
|
-
events.should be_an Array
|
86
|
-
events.should have(1).items
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should be a mash type" do
|
90
|
-
events = github.issues.events.list user, repo, :issue_id => issue_id
|
91
|
-
events.first.should be_a Hashie::Mash
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should get issue information" do
|
95
|
-
events = github.issues.events.list user, repo, :issue_id => issue_id
|
96
|
-
events.first.actor.login.should == 'octocat'
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should yield to a block" do
|
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'
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end # with issue_id
|
107
|
-
end # list
|
108
|
-
|
109
|
-
describe "#get" do
|
110
|
-
let(:event_id) { 1 }
|
111
|
-
|
112
|
-
it { github.issues.events.should respond_to :find }
|
113
|
-
|
114
|
-
context "resource found" do
|
115
|
-
before do
|
116
|
-
stub_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").
|
117
|
-
to_return(:body => fixture('issues/event.json'),
|
118
|
-
:status => 200,
|
119
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
120
|
-
end
|
121
|
-
|
122
|
-
it "should fail to get resource without event id" do
|
123
|
-
expect {
|
124
|
-
github.issues.events.get user, repo, nil
|
125
|
-
}.to raise_error(ArgumentError)
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should get the resource" do
|
129
|
-
github.issues.events.get user, repo, event_id
|
130
|
-
a_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").
|
131
|
-
should have_been_made
|
132
|
-
end
|
133
|
-
|
134
|
-
it "should get event information" do
|
135
|
-
event = github.issues.events.get user, repo, event_id
|
136
|
-
event.actor.id.should == event_id
|
137
|
-
event.actor.login.should == 'octocat'
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should return mash" do
|
141
|
-
event = github.issues.events.get user, repo, event_id
|
142
|
-
event.should be_a Hashie::Mash
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
context "resource not found" do
|
147
|
-
before do
|
148
|
-
stub_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").
|
149
|
-
to_return(:body => fixture('issues/event.json'),
|
150
|
-
:status => 404,
|
151
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
152
|
-
end
|
153
|
-
|
154
|
-
it "should fail to retrive resource" do
|
155
|
-
expect {
|
156
|
-
github.issues.events.get user, repo, event_id
|
157
|
-
}.to raise_error(Github::Error::NotFound)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end # get
|
161
6
|
|
162
7
|
end # Github::Issues:Events
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Issues::Labels, '#remove' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:issue_id) { 1 }
|
9
|
+
let(:label_id) { 1 }
|
10
|
+
let(:request_path) { "/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_id}" }
|
11
|
+
|
12
|
+
before {
|
13
|
+
stub_delete(request_path).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 "remove a label from an issue" do
|
20
|
+
let(:body) { fixture('issues/labels.json') }
|
21
|
+
let(:status) { 200 }
|
22
|
+
|
23
|
+
it "should throw exception if issue-id not present" do
|
24
|
+
expect { subject.remove user, repo, nil }.to raise_error(ArgumentError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should remove label successfully" do
|
28
|
+
subject.remove user, repo, issue_id, label_id
|
29
|
+
a_delete(request_path).should have_been_made
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return the resource" do
|
33
|
+
labels = subject.remove user, repo, issue_id, label_id
|
34
|
+
labels.first.should be_a Hashie::Mash
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should get the label information" do
|
38
|
+
labels = subject.remove user, repo, issue_id, label_id
|
39
|
+
labels.first.name.should == 'bug'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "remove all labels from an issue" do
|
44
|
+
let(:request_path) { "/repos/#{user}/#{repo}/issues/#{issue_id}/labels" }
|
45
|
+
let(:body) { '[]' }
|
46
|
+
let(:status) { 204 }
|
47
|
+
|
48
|
+
it "should remove labels successfully" do
|
49
|
+
subject.remove user, repo, issue_id
|
50
|
+
a_delete(request_path).should have_been_made
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it_should_behave_like 'request failure' do
|
55
|
+
let(:requestable) { subject.remove user, repo, issue_id, label_id }
|
56
|
+
end
|
57
|
+
|
58
|
+
end # remove
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Issues::Labels, '#replace' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:issue_id) { 1 }
|
9
|
+
let(:labels) { "Label 1" }
|
10
|
+
let(:request_path) { "/repos/#{user}/#{repo}/issues/#{issue_id}/labels" }
|
11
|
+
|
12
|
+
before {
|
13
|
+
stub_put(request_path).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
|
+
|
20
|
+
context "labels replaced" do
|
21
|
+
let(:body) { fixture('issues/labels.json') }
|
22
|
+
let(:status) { 200 }
|
23
|
+
|
24
|
+
it "should fail to add labels if issue-id is missing" do
|
25
|
+
expect {
|
26
|
+
subject.replace user, repo, nil, labels
|
27
|
+
}.to raise_error(ArgumentError)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should create resource successfully" do
|
31
|
+
subject.replace user, repo, issue_id, labels
|
32
|
+
a_put(request_path).should have_been_made
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return the resource" do
|
36
|
+
labels = subject.replace user, repo, issue_id, labels
|
37
|
+
labels.first.should be_a Hashie::Mash
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should get the label information" do
|
41
|
+
labels = subject.replace user, repo, issue_id, labels
|
42
|
+
labels.first.name.should == 'bug'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it_should_behave_like 'request failure' do
|
47
|
+
let(:requestable) { subject.replace user, repo, issue_id, labels }
|
48
|
+
end
|
49
|
+
|
50
|
+
end # replace
|
@@ -1,118 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Github::Issues::Labels do
|
4
|
-
let(:github) { Github.new }
|
5
|
-
let(:user) { 'peter-murach' }
|
6
|
-
let(:repo) { 'github' }
|
7
|
-
let(:label_id) { 1 }
|
8
|
-
|
9
|
-
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
3
|
+
describe Github::Issues::Labels, 'integration' do
|
10
4
|
|
11
5
|
it { described_class::VALID_LABEL_INPUTS.should_not be_nil }
|
12
6
|
|
13
|
-
describe "#remove" do
|
14
|
-
let(:issue_id) { 1 }
|
15
|
-
let(:label_id) { 1 }
|
16
|
-
|
17
|
-
context "remove a label from an issue" do
|
18
|
-
before do
|
19
|
-
stub_delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_id}").
|
20
|
-
to_return(:body => fixture('issues/labels.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should throw exception if issue-id not present" do
|
24
|
-
expect {
|
25
|
-
github.issues.labels.remove user, repo, nil
|
26
|
-
}.to raise_error(ArgumentError)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should remove label successfully" do
|
30
|
-
github.issues.labels.remove user, repo, issue_id, label_id
|
31
|
-
a_delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_id}").should have_been_made
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should return the resource" do
|
35
|
-
labels = github.issues.labels.remove user, repo, issue_id, label_id
|
36
|
-
labels.first.should be_a Hashie::Mash
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should get the label information" do
|
40
|
-
labels = github.issues.labels.remove user, repo, issue_id, label_id
|
41
|
-
labels.first.name.should == 'bug'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "remove all labels from an issue" do
|
46
|
-
before do
|
47
|
-
stub_delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").
|
48
|
-
to_return(:body => "", :status => 204, :headers => {:content_type => "application/json; charset=utf-8"})
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should remove labels successfully" do
|
52
|
-
github.issues.labels.remove user, repo, issue_id
|
53
|
-
a_delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").should have_been_made
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context "failed to remove label from an issue" do
|
58
|
-
before do
|
59
|
-
stub_delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_id}").
|
60
|
-
to_return(:body => fixture('issues/label.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should faile to retrieve resource" do
|
64
|
-
expect {
|
65
|
-
github.issues.labels.remove user, repo, issue_id, label_id
|
66
|
-
}.to raise_error(Github::Error::NotFound)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end # remove
|
70
|
-
|
71
|
-
describe "#replace" do
|
72
|
-
let(:issue_id) { 1 }
|
73
|
-
let(:labels) { "Label 1" }
|
74
|
-
|
75
|
-
context "labels added" do
|
76
|
-
before do
|
77
|
-
stub_put("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").
|
78
|
-
to_return(:body => fixture('issues/labels.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should fail to add labels if issue-id is missing" do
|
82
|
-
expect {
|
83
|
-
github.issues.labels.replace user, repo, nil, labels
|
84
|
-
}.to raise_error(ArgumentError)
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should create resource successfully" do
|
88
|
-
github.issues.labels.replace user, repo, issue_id, labels
|
89
|
-
a_put("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").should have_been_made
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should return the resource" do
|
93
|
-
labels = github.issues.labels.replace user, repo, issue_id, labels
|
94
|
-
labels.first.should be_a Hashie::Mash
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should get the label information" do
|
98
|
-
labels = github.issues.labels.replace user, repo, issue_id, labels
|
99
|
-
labels.first.name.should == 'bug'
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
context "failed to add labels" do
|
104
|
-
before do
|
105
|
-
stub_put("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").
|
106
|
-
to_return(:body => fixture('issues/label.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should fail to retrieve resource" do
|
111
|
-
expect {
|
112
|
-
github.issues.labels.replace user, repo, issue_id, labels
|
113
|
-
}.to raise_error(Github::Error::NotFound)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end # replace
|
117
|
-
|
118
7
|
end # Github::Issues::Labels
|