github_api 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -5
- data/features/{events.feature → activity/events.feature} +8 -8
- data/features/{repos → activity}/starring.feature +6 -6
- data/features/{repos → activity}/watching.feature +6 -6
- data/features/cassettes/{events → activity/events}/issue.yml +0 -0
- data/features/cassettes/{events → activity/events}/network.yml +0 -0
- data/features/cassettes/{events → activity/events}/org.yml +0 -0
- data/features/cassettes/{events → activity/events}/performed.yml +0 -0
- data/features/cassettes/{events → activity/events}/public.yml +0 -0
- data/features/cassettes/{events → activity/events}/received.yml +0 -0
- data/features/cassettes/{events → activity/events}/repo.yml +0 -0
- data/features/cassettes/{events → activity/events}/user_org.yml +0 -0
- data/features/cassettes/{repos → activity}/starring/list.yml +0 -0
- data/features/cassettes/{repos → activity}/starring/star.yml +0 -0
- data/features/cassettes/{repos → activity}/starring/starred.yml +0 -0
- data/features/cassettes/{repos → activity}/starring/starring.yml +0 -0
- data/features/cassettes/{repos → activity}/starring/unstar.yml +0 -0
- data/features/cassettes/{repos → activity}/watching/list.yml +0 -0
- data/features/cassettes/{repos → activity}/watching/unwatch.yml +0 -0
- data/features/cassettes/{repos → activity}/watching/watch.yml +0 -0
- data/features/cassettes/{repos → activity}/watching/watched.yml +0 -0
- data/features/cassettes/{repos → activity}/watching/watching.yml +0 -0
- data/features/github_api.feature +3 -3
- data/lib/github_api.rb +1 -1
- data/lib/github_api/activity.rb +39 -0
- data/lib/github_api/{events.rb → activity/events.rb} +5 -5
- data/lib/github_api/activity/notifications.rb +162 -0
- data/lib/github_api/{repos → activity}/starring.rb +9 -9
- data/lib/github_api/{repos → activity}/watching.rb +9 -9
- data/lib/github_api/client.rb +6 -4
- data/lib/github_api/repos.rb +2 -14
- data/lib/github_api/response.rb +0 -1
- data/lib/github_api/version.rb +2 -2
- data/spec/fixtures/activity/notifications.json +32 -0
- data/spec/fixtures/activity/subscribed.json +8 -0
- data/spec/fixtures/activity/threads.json +32 -0
- data/spec/github/activity/activity_spec.rb +16 -0
- data/spec/github/activity/events/issue_spec.rb +63 -0
- data/spec/github/activity/events/network_spec.rb +61 -0
- data/spec/github/activity/events/org_spec.rb +60 -0
- data/spec/github/activity/events/performed_spec.rb +91 -0
- data/spec/github/activity/events/public_spec.rb +55 -0
- data/spec/github/activity/events/received_spec.rb +91 -0
- data/spec/github/activity/events/repository_spec.rb +65 -0
- data/spec/github/activity/events/user_org_spec.rb +63 -0
- data/spec/github/activity/notifications/create_spec.rb +44 -0
- data/spec/github/activity/notifications/delete_spec.rb +41 -0
- data/spec/github/activity/notifications/get_spec.rb +58 -0
- data/spec/github/activity/notifications/list_spec.rb +82 -0
- data/spec/github/activity/notifications/mark_spec.rb +74 -0
- data/spec/github/activity/notifications/subscribed_spec.rb +48 -0
- data/spec/github/activity/starring/list_spec.rb +64 -0
- data/spec/github/activity/starring/star_spec.rb +36 -0
- data/spec/github/activity/starring/starred_spec.rb +53 -0
- data/spec/github/activity/starring/starring_spec.rb +38 -0
- data/spec/github/activity/starring/unstar_spec.rb +37 -0
- data/spec/github/activity/watching/list_spec.rb +59 -0
- data/spec/github/activity/watching/unwatch_spec.rb +37 -0
- data/spec/github/activity/watching/watch_spec.rb +37 -0
- data/spec/github/activity/watching/watched_spec.rb +53 -0
- data/spec/github/activity/watching/watching_spec.rb +41 -0
- data/spec/github/authorization_spec.rb +2 -2
- data/spec/github/issues_spec.rb +1 -1
- data/spec/github/repos/comments/delete_spec.rb +2 -0
- data/spec/github/repos/delete_spec.rb +1 -1
- data/spec/github/repos/get_spec.rb +2 -2
- data/spec/github/repos/starring_spec.rb +0 -199
- data/spec/github/repos_spec.rb +0 -4
- data/spec/github/result_spec.rb +1 -1
- metadata +88 -62
- data/features/cassettes/git_data/tags/get.yml +0 -54
- data/features/git_data/tags.feature +0 -17
- data/spec/github/events_spec.rb +0 -491
- data/spec/github/repos/watching_spec.rb +0 -203
@@ -0,0 +1,91 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Activity::Events, '#performed' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:request_path) { "/users/#{user}/events" }
|
8
|
+
let(:body) { fixture('events/events.json') }
|
9
|
+
let(:status) { 200 }
|
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
|
+
|
20
|
+
it "should fail to get resource without username" do
|
21
|
+
expect { subject.performed nil }.to raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should get the resources" do
|
25
|
+
subject.performed user
|
26
|
+
a_get(request_path).should have_been_made
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return array of resources" do
|
30
|
+
events = subject.performed user
|
31
|
+
events.should be_an Array
|
32
|
+
events.should have(1).items
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be a mash type" do
|
36
|
+
events = subject.performed user
|
37
|
+
events.first.should be_a Hashie::Mash
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should get event information" do
|
41
|
+
events = subject.performed user
|
42
|
+
events.first.type.should == 'Event'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should yield to a block" do
|
46
|
+
subject.should_receive(:performed).with(user).and_yield('web')
|
47
|
+
subject.performed(user) { |param| 'web' }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "all public resources found" do
|
52
|
+
let(:request_path) { "/users/#{user}/events/public" }
|
53
|
+
|
54
|
+
it "should get the resources" do
|
55
|
+
subject.performed user, :public => true
|
56
|
+
a_get(request_path).should have_been_made
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return array of resources" do
|
60
|
+
events = subject.performed user, :public => true
|
61
|
+
events.should be_an Array
|
62
|
+
events.should have(1).items
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be a mash type" do
|
66
|
+
events = subject.performed user, :public => true
|
67
|
+
events.first.should be_a Hashie::Mash
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should get event information" do
|
71
|
+
events = subject.performed user, :public => true
|
72
|
+
events.first.type.should == 'Event'
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should yield to a block" do
|
76
|
+
subject.should_receive(:performed).with(user).and_yield('web')
|
77
|
+
subject.performed(user) { |param| 'web' }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "resource not found" do
|
82
|
+
let(:body) { '' }
|
83
|
+
let(:status) { [404, "Not Found"] }
|
84
|
+
|
85
|
+
it "should return 404 with a message 'Not Found'" do
|
86
|
+
expect {
|
87
|
+
subject.performed user
|
88
|
+
}.to raise_error(Github::Error::NotFound)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end # performed
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Activity::Events, '#public' do
|
6
|
+
let(:request_path) { "/events" }
|
7
|
+
let(:body) { fixture('events/events.json') }
|
8
|
+
let(:status) { 200 }
|
9
|
+
|
10
|
+
before {
|
11
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
12
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
13
|
+
}
|
14
|
+
|
15
|
+
after { reset_authentication_for subject }
|
16
|
+
|
17
|
+
context "resource found" do
|
18
|
+
|
19
|
+
it "should get the resources" do
|
20
|
+
subject.public
|
21
|
+
a_get(request_path).should have_been_made
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return array of resources" do
|
25
|
+
events = subject.public
|
26
|
+
events.should be_an Array
|
27
|
+
events.should have(1).items
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be a mash type" do
|
31
|
+
events = subject.public
|
32
|
+
events.first.should be_a Hashie::Mash
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should get event information" do
|
36
|
+
events = subject.public
|
37
|
+
events.first.type.should == 'Event'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should yield to a block" do
|
41
|
+
subject.should_receive(:public).and_yield('web')
|
42
|
+
subject.public { |param| 'web' }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "resource not found" do
|
47
|
+
let(:body) { '' }
|
48
|
+
let(:status) { [404, "Not Found"] }
|
49
|
+
|
50
|
+
it "should return 404 with a message 'Not Found'" do
|
51
|
+
expect { subject.public }.to raise_error(Github::Error::NotFound)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end # public
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Activity::Events, '#received' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:request_path) { "/users/#{user}/received_events" }
|
8
|
+
let(:body) { fixture('events/events.json') }
|
9
|
+
let(:status) { 200 }
|
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
|
+
|
20
|
+
it "should fail to get resource without username" do
|
21
|
+
expect { subject.received nil }.to raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should get the resources" do
|
25
|
+
subject.received user
|
26
|
+
a_get(request_path).should have_been_made
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return array of resources" do
|
30
|
+
events = subject.received user
|
31
|
+
events.should be_an Array
|
32
|
+
events.should have(1).items
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be a mash type" do
|
36
|
+
events = subject.received user
|
37
|
+
events.first.should be_a Hashie::Mash
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should get event information" do
|
41
|
+
events = subject.received user
|
42
|
+
events.first.type.should == 'Event'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should yield to a block" do
|
46
|
+
subject.should_receive(:received).with(user).and_yield('web')
|
47
|
+
subject.received(user) { |param| 'web' }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "all public resources found" do
|
52
|
+
let(:request_path) { "/users/#{user}/received_events/public" }
|
53
|
+
|
54
|
+
it "should get the resources" do
|
55
|
+
subject.received user, :public => true
|
56
|
+
a_get(request_path).should have_been_made
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return array of resources" do
|
60
|
+
events = subject.received user, :public => true
|
61
|
+
events.should be_an Array
|
62
|
+
events.should have(1).items
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be a mash type" do
|
66
|
+
events = subject.received user, :public => true
|
67
|
+
events.first.should be_a Hashie::Mash
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should get event information" do
|
71
|
+
events = subject.received user, :public => true
|
72
|
+
events.first.type.should == 'Event'
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should yield to a block" do
|
76
|
+
subject.should_receive(:received).with(user).and_yield('web')
|
77
|
+
subject.received(user) { |param| 'web' }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "resource not found" do
|
82
|
+
let(:body) { '' }
|
83
|
+
let(:status) { [404, "Not Found"] }
|
84
|
+
|
85
|
+
it "should return 404 with a message 'Not Found'" do
|
86
|
+
expect {
|
87
|
+
subject.received user
|
88
|
+
}.to raise_error(Github::Error::NotFound)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end # received
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Activity::Events, '#repository' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:request_path) { "/repos/#{user}/#{repo}/events" }
|
9
|
+
let(:body) { fixture('events/events.json') }
|
10
|
+
let(:status) { 200 }
|
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 "resource found" do
|
20
|
+
it { should respond_to :repo }
|
21
|
+
|
22
|
+
it { should respond_to :repo_events }
|
23
|
+
|
24
|
+
it "should fail to get resource without username" do
|
25
|
+
expect { subject.repository nil, repo }.to raise_error(ArgumentError)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should get the resources" do
|
29
|
+
subject.repository user, repo
|
30
|
+
a_get(request_path).should have_been_made
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return array of resources" do
|
34
|
+
events = subject.repository user, repo
|
35
|
+
events.should be_an Array
|
36
|
+
events.should have(1).items
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be a mash type" do
|
40
|
+
events = subject.repository user, repo
|
41
|
+
events.first.should be_a Hashie::Mash
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should get event information" do
|
45
|
+
events = subject.repository user, repo
|
46
|
+
events.first.type.should == 'Event'
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should yield to a block" do
|
50
|
+
subject.should_receive(:repository).with(user, repo).and_yield('web')
|
51
|
+
subject.repository(user, repo) { |param| 'web' }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "resource not found" do
|
56
|
+
let(:body) { '' }
|
57
|
+
let(:status) { [404, "Not Found"] }
|
58
|
+
|
59
|
+
it "should return 404 with a message 'Not Found'" do
|
60
|
+
expect {
|
61
|
+
subject.repository user, repo
|
62
|
+
}.to raise_error(Github::Error::NotFound)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end # repository
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Activity::Events, '#user_org' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:org) { 'github' }
|
8
|
+
let(:request_path) { "/users/#{user}/events/orgs/#{org}" }
|
9
|
+
let(:body) { fixture('events/events.json') }
|
10
|
+
let(:status) { 200 }
|
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 "resource found" do
|
20
|
+
it { should respond_to :user_organization }
|
21
|
+
|
22
|
+
it "should fail to get resource without orgname" do
|
23
|
+
expect { subject.user_org user, nil }.to raise_error(ArgumentError)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should get the resources" do
|
27
|
+
subject.user_org user, org
|
28
|
+
a_get(request_path).should have_been_made
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return array of resources" do
|
32
|
+
events = subject.user_org user, org
|
33
|
+
events.should be_an Array
|
34
|
+
events.should have(1).items
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should be a mash type" do
|
38
|
+
events = subject.user_org user, org
|
39
|
+
events.first.should be_a Hashie::Mash
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should get event information" do
|
43
|
+
events = subject.user_org user, org
|
44
|
+
events.first.type.should == 'Event'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should yield to a block" do
|
48
|
+
subject.should_receive(:user_org).with(user, org).and_yield('web')
|
49
|
+
subject.user_org(user, org) { |param| 'web' }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "resource not found" do
|
54
|
+
let(:body) { '' }
|
55
|
+
let(:status) { [404, "Not Found"] }
|
56
|
+
|
57
|
+
it "should return 404 with a message 'Not Found'" do
|
58
|
+
expect {
|
59
|
+
subject.user_org user, org
|
60
|
+
}.to raise_error(Github::Error::NotFound)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end # user_org
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Activity::Notifications, '#create' do
|
6
|
+
let(:thread_id) { 1 }
|
7
|
+
let(:request_path) { "/notifications/threads/#{thread_id}/subscription" }
|
8
|
+
|
9
|
+
let(:inputs) {{
|
10
|
+
:subscribed => true,
|
11
|
+
:ignored => false
|
12
|
+
}}
|
13
|
+
|
14
|
+
before {
|
15
|
+
subject.oauth_token = OAUTH_TOKEN
|
16
|
+
stub_put(request_path).
|
17
|
+
with(:body => inputs, :query => {:access_token => OAUTH_TOKEN}).
|
18
|
+
to_return(:body => body, :status => status,
|
19
|
+
:headers => {:content_type => "application/json; charset=utf-8"} )
|
20
|
+
}
|
21
|
+
|
22
|
+
after { reset_authentication_for subject }
|
23
|
+
|
24
|
+
context "resource created successfully" do
|
25
|
+
let(:body) { fixture('activity/subscribed.json') }
|
26
|
+
let(:status) { 200 }
|
27
|
+
|
28
|
+
it 'asserts thread id presence' do
|
29
|
+
expect { subject.create nil }.to raise_error(ArgumentError)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should create resource' do
|
33
|
+
subject.create thread_id, inputs
|
34
|
+
a_put(request_path).
|
35
|
+
with(:body => inputs, :query => {:access_token => OAUTH_TOKEN}).
|
36
|
+
should have_been_made
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should return the resource' do
|
40
|
+
thread = subject.create thread_id, inputs
|
41
|
+
thread.subscribed.should be_true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end # create
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Activity::Notifications, '#delete' do
|
6
|
+
let(:thread_id) { 1 }
|
7
|
+
let(:request_path) { "/notifications/threads/#{thread_id}/subscription" }
|
8
|
+
let(:body) { '' }
|
9
|
+
let(:status) { 204 }
|
10
|
+
|
11
|
+
before {
|
12
|
+
subject.oauth_token = OAUTH_TOKEN
|
13
|
+
stub_delete(request_path).with(:query => {:access_token => OAUTH_TOKEN}).
|
14
|
+
to_return(:body => body, :status => status,
|
15
|
+
:headers => { :content_type => "application/json; charset=utf-8"})
|
16
|
+
}
|
17
|
+
|
18
|
+
after { reset_authentication_for subject }
|
19
|
+
|
20
|
+
it { should respond_to :remove }
|
21
|
+
|
22
|
+
it "should delete the resource successfully" do
|
23
|
+
subject.delete thread_id
|
24
|
+
a_delete(request_path).with(:query => {:access_token => OAUTH_TOKEN}).
|
25
|
+
should have_been_made
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should fail to delete resource without 'user' parameter" do
|
29
|
+
expect { subject.delete nil }.to raise_error(ArgumentError)
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'failed to delete' do
|
33
|
+
let(:status) { 404 }
|
34
|
+
|
35
|
+
it "should fail to delete resource that is not found" do
|
36
|
+
expect {
|
37
|
+
subject.delete thread_id
|
38
|
+
}.to raise_error(Github::Error::NotFound)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end # delete
|