github_api 0.9.0 → 0.9.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 +50 -5
- data/features/cassettes/git_data/commits/get.yml +69 -0
- data/features/git_data/commmits.feature +14 -0
- data/lib/github_api.rb +1 -0
- data/lib/github_api/activity/events.rb +42 -33
- data/lib/github_api/activity/notifications.rb +22 -22
- data/lib/github_api/activity/starring.rb +16 -21
- data/lib/github_api/activity/watching.rb +16 -19
- data/lib/github_api/api.rb +51 -8
- data/lib/github_api/arguments.rb +155 -0
- data/lib/github_api/authorizations.rb +19 -20
- data/lib/github_api/configuration.rb +5 -0
- data/lib/github_api/emojis.rb +3 -3
- data/lib/github_api/error/validations.rb +2 -2
- data/lib/github_api/gists.rb +32 -42
- data/lib/github_api/gists/comments.rb +21 -23
- data/lib/github_api/git_data/blobs.rb +13 -16
- data/lib/github_api/git_data/commits.rb +12 -10
- data/lib/github_api/git_data/references.rb +24 -28
- data/lib/github_api/git_data/tags.rb +9 -11
- data/lib/github_api/git_data/trees.rb +10 -13
- data/lib/github_api/gitignore.rb +4 -6
- data/lib/github_api/issues.rb +24 -32
- data/lib/github_api/issues/assignees.rb +11 -8
- data/lib/github_api/issues/comments.rb +21 -26
- data/lib/github_api/issues/events.rb +7 -9
- data/lib/github_api/issues/labels.rb +39 -53
- data/lib/github_api/issues/milestones.rb +26 -33
- data/lib/github_api/markdown.rb +5 -6
- data/lib/github_api/meta.rb +3 -3
- data/lib/github_api/orgs.rb +10 -11
- data/lib/github_api/orgs/members.rb +18 -20
- data/lib/github_api/orgs/teams.rb +54 -58
- data/lib/github_api/pull_requests.rb +40 -54
- data/lib/github_api/pull_requests/comments.rb +19 -26
- data/lib/github_api/repos.rb +146 -101
- data/lib/github_api/repos/collaborators.rb +29 -30
- data/lib/github_api/repos/comments.rb +20 -25
- data/lib/github_api/repos/commits.rb +12 -14
- data/lib/github_api/repos/contents.rb +22 -14
- data/lib/github_api/repos/downloads.rb +19 -23
- data/lib/github_api/repos/forks.rb +6 -11
- data/lib/github_api/repos/hooks.rb +25 -34
- data/lib/github_api/repos/keys.rb +25 -27
- data/lib/github_api/repos/merging.rb +7 -6
- data/lib/github_api/repos/pub_sub_hubbub.rb +14 -18
- data/lib/github_api/repos/statuses.rb +13 -14
- data/lib/github_api/say.rb +1 -3
- data/lib/github_api/search.rb +12 -21
- data/lib/github_api/users.rb +10 -9
- data/lib/github_api/users/emails.rb +11 -9
- data/lib/github_api/users/followers.rb +25 -23
- data/lib/github_api/users/keys.rb +27 -29
- data/lib/github_api/version.rb +1 -1
- data/spec/github/activity/events/org_spec.rb +6 -6
- data/spec/github/activity/events/performed_spec.rb +1 -1
- data/spec/github/activity/events/received_spec.rb +1 -1
- data/spec/github/activity/events/user_org_spec.rb +4 -2
- data/spec/github/activity/notifications/create_spec.rb +1 -1
- data/spec/github/activity/notifications/delete_spec.rb +1 -1
- data/spec/github/activity/notifications/get_spec.rb +1 -1
- data/spec/github/activity/notifications/subscribed_spec.rb +1 -1
- data/spec/github/activity/starring/list_spec.rb +2 -0
- data/spec/github/activity/starring/starring_spec.rb +1 -1
- data/spec/github/activity/watching/list_spec.rb +2 -0
- data/spec/github/activity/watching/watching_spec.rb +1 -3
- data/spec/github/api/set_spec.rb +18 -4
- data/spec/github/api/with_spec.rb +28 -0
- data/spec/github/api_spec.rb +11 -33
- data/spec/github/arguments/parse_spec.rb +68 -0
- data/spec/github/authorizations/delete_spec.rb +1 -1
- data/spec/github/authorizations/get_spec.rb +1 -1
- data/spec/github/error/validations_spec.rb +3 -3
- data/spec/github/gists/comments/list_spec.rb +1 -1
- data/spec/github/gists/delete_spec.rb +1 -1
- data/spec/github/gists/fork_spec.rb +1 -1
- data/spec/github/gists/get_spec.rb +1 -1
- data/spec/github/gists/is_starred_spec.rb +2 -0
- data/spec/github/gists/star_spec.rb +1 -1
- data/spec/github/gists/unstar_spec.rb +1 -1
- data/spec/github/git_data/blobs/create_spec.rb +2 -0
- data/spec/github/git_data/blobs/get_spec.rb +1 -1
- data/spec/github/git_data/commits/create_spec.rb +2 -0
- data/spec/github/git_data/commits/get_spec.rb +3 -3
- data/spec/github/git_data/references/create_spec.rb +1 -1
- data/spec/github/git_data/references/delete_spec.rb +3 -1
- data/spec/github/git_data/tags/create_spec.rb +2 -0
- data/spec/github/gitignore/get_spec.rb +1 -1
- data/spec/github/issues/events/get_spec.rb +3 -1
- data/spec/github/issues/events/list_spec.rb +3 -1
- data/spec/github/issues/labels/add_spec.rb +6 -6
- data/spec/github/issues/labels/list_spec.rb +3 -1
- data/spec/github/issues/labels/replace_spec.rb +6 -7
- data/spec/github/issues/milestones/get_spec.rb +2 -0
- data/spec/github/normalizer_spec.rb +18 -6
- data/spec/github/orgs/members/conceal_spec.rb +6 -4
- data/spec/github/orgs/members/delete_spec.rb +2 -0
- data/spec/github/orgs/members/list_spec.rb +1 -1
- data/spec/github/orgs/members/member_spec.rb +3 -1
- data/spec/github/orgs/members/publicize_spec.rb +2 -0
- data/spec/github/orgs/teams/add_member_spec.rb +2 -0
- data/spec/github/orgs/teams/create_spec.rb +1 -1
- data/spec/github/orgs/teams/delete_spec.rb +1 -1
- data/spec/github/orgs/teams/edit_spec.rb +1 -1
- data/spec/github/orgs/teams/get_spec.rb +1 -1
- data/spec/github/orgs/teams/list_spec.rb +1 -1
- data/spec/github/orgs/teams/team_member_spec.rb +3 -1
- data/spec/github/parameter_filter_spec.rb +19 -58
- data/spec/github/pull_requests/comments/create_spec.rb +3 -1
- data/spec/github/pull_requests/comments/delete_spec.rb +1 -1
- data/spec/github/pull_requests/comments/edit_spec.rb +2 -0
- data/spec/github/pull_requests/comments/get_spec.rb +3 -1
- data/spec/github/pull_requests/comments/list_spec.rb +3 -1
- data/spec/github/pull_requests/commits_spec.rb +3 -3
- data/spec/github/pull_requests/create_spec.rb +4 -0
- data/spec/github/pull_requests/files_spec.rb +4 -0
- data/spec/github/pull_requests/get_spec.rb +3 -3
- data/spec/github/pull_requests/list_spec.rb +3 -3
- data/spec/github/pull_requests/merge_spec.rb +2 -0
- data/spec/github/pull_requests/merged_spec.rb +3 -1
- data/spec/github/pull_requests/update_spec.rb +4 -0
- data/spec/github/repos/collaborators/add_spec.rb +3 -1
- data/spec/github/repos/collaborators/get_spec.rb +1 -3
- data/spec/github/repos/collaborators/list_spec.rb +5 -1
- data/spec/github/repos/collaborators/remove_spec.rb +3 -1
- data/spec/github/repos/comments/create_spec.rb +4 -0
- data/spec/github/repos/comments/delete_spec.rb +2 -2
- data/spec/github/repos/comments/get_spec.rb +6 -2
- data/spec/github/repos/commits/compare_spec.rb +3 -3
- data/spec/github/repos/commits/get_spec.rb +3 -3
- data/spec/github/repos/commits/list_spec.rb +3 -3
- data/spec/github/repos/contents/archive_spec.rb +12 -0
- data/spec/github/repos/contents/get_spec.rb +5 -0
- data/spec/github/repos/contributors_spec.rb +7 -2
- data/spec/github/repos/downloads/create_spec.rb +4 -0
- data/spec/github/repos/downloads/delete_spec.rb +5 -1
- data/spec/github/repos/downloads/get_spec.rb +3 -1
- data/spec/github/repos/downloads/list_spec.rb +3 -1
- data/spec/github/repos/forks/create_spec.rb +2 -0
- data/spec/github/repos/forks/list_spec.rb +3 -1
- data/spec/github/repos/hooks/edit_spec.rb +1 -1
- data/spec/github/repos/keys/delete_spec.rb +1 -1
- data/spec/github/repos/keys/edit_spec.rb +2 -0
- data/spec/github/repos/keys/get_spec.rb +3 -1
- data/spec/github/repos/keys/list_spec.rb +4 -2
- data/spec/github/repos/list_spec.rb +6 -1
- data/spec/github/repos/pub_sub_hubbub/subscribe_service_spec.rb +27 -0
- data/spec/github/repos/pub_sub_hubbub/subscribe_spec.rb +51 -0
- data/spec/github/repos/pub_sub_hubbub/unsubscribe_service_spec.rb +21 -0
- data/spec/github/repos/pub_sub_hubbub/unsubscribe_spec.rb +58 -0
- data/spec/github/repos/statuses/create_spec.rb +2 -0
- data/spec/github/search_spec.rb +25 -10
- data/spec/github/users/followers/follow_spec.rb +1 -1
- data/spec/github/users/followers/is_following_spec.rb +1 -1
- data/spec/github/users/followers/unfollow_spec.rb +1 -1
- data/spec/github/users/keys/delete_spec.rb +1 -1
- data/spec/github/users/keys/get_spec.rb +1 -1
- data/spec/github/users/keys/update_spec.rb +1 -1
- data/spec/github/users/update_spec.rb +1 -1
- data/spec/integration/arguments_spec.rb +76 -0
- data/spec/{github → integration}/authorizations_spec.rb +0 -0
- metadata +44 -35
- data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -78
|
@@ -21,10 +21,10 @@ describe Github::Repos::Commits, '#get' do
|
|
|
21
21
|
|
|
22
22
|
it { should respond_to :find }
|
|
23
23
|
|
|
24
|
+
it { expect { subject.get }.to raise_error(ArgumentError) }
|
|
25
|
+
|
|
24
26
|
it "should fail to get resource without sha key" do
|
|
25
|
-
expect {
|
|
26
|
-
subject.get user, repo, nil
|
|
27
|
-
}.to raise_error(ArgumentError)
|
|
27
|
+
expect { subject.get user, repo }.to raise_error(ArgumentError)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "should get the resource" do
|
|
@@ -20,9 +20,9 @@ describe Github::Repos::Commits, '#list' do
|
|
|
20
20
|
|
|
21
21
|
it { should respond_to :all }
|
|
22
22
|
|
|
23
|
-
it
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
it { expect { subject.list }.to raise_error(ArgumentError) }
|
|
24
|
+
|
|
25
|
+
it { expect { subject user }.to raise_error(ArgumentError) }
|
|
26
26
|
|
|
27
27
|
it "should get the resources" do
|
|
28
28
|
subject.list user, repo
|
|
@@ -19,8 +19,20 @@ describe Github::Repos::Contents, '#get' do
|
|
|
19
19
|
let(:body) { '[]' }
|
|
20
20
|
let(:status) { 302 }
|
|
21
21
|
|
|
22
|
+
|
|
22
23
|
it "should get the resources" do
|
|
23
24
|
subject.archive user, repo, :archive_format => archive_format, :ref => ref
|
|
24
25
|
a_get(request_path).should have_been_made
|
|
25
26
|
end
|
|
27
|
+
|
|
28
|
+
context 'with defaults' do
|
|
29
|
+
let(:request_path) { "/repos/#{user}/#{repo}/zipball/master" }
|
|
30
|
+
|
|
31
|
+
it { expect { subject.archive user }.to raise_error(ArgumentError) }
|
|
32
|
+
|
|
33
|
+
it 'should get the resource' do
|
|
34
|
+
subject.archive user, repo
|
|
35
|
+
a_get(request_path).should have_been_made
|
|
36
|
+
end
|
|
37
|
+
end
|
|
26
38
|
end
|
|
@@ -5,6 +5,7 @@ require 'spec_helper'
|
|
|
5
5
|
describe Github::Repos::Contents, '#get' do
|
|
6
6
|
let(:user) { 'peter-murach' }
|
|
7
7
|
let(:repo) { 'github' }
|
|
8
|
+
let(:path) { 'README.md' }
|
|
8
9
|
let(:request_path) { "/repos/#{user}/#{repo}/contents/#{path}" }
|
|
9
10
|
|
|
10
11
|
before {
|
|
@@ -18,6 +19,10 @@ describe Github::Repos::Contents, '#get' do
|
|
|
18
19
|
let(:body) { fixture('repos/content.json') }
|
|
19
20
|
let(:status) { 200 }
|
|
20
21
|
|
|
22
|
+
it { expect { subject.get user, repo }.to raise_error(ArgumentError) }
|
|
23
|
+
|
|
24
|
+
it { expect { subject.get }.to raise_error(ArgumentError)}
|
|
25
|
+
|
|
21
26
|
it "should get the resources" do
|
|
22
27
|
subject.get user, repo, path
|
|
23
28
|
a_get(request_path).should have_been_made
|
|
@@ -20,11 +20,16 @@ describe Github::Repos, '#contributors' do
|
|
|
20
20
|
let(:status) { 200 }
|
|
21
21
|
|
|
22
22
|
it "should raise error when no user/repo parameters" do
|
|
23
|
-
expect { subject.contributors
|
|
23
|
+
expect { subject.contributors }.to raise_error(ArgumentError)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "should raise error when no repository" do
|
|
27
|
-
expect { subject.contributors user
|
|
27
|
+
expect { subject.contributors user }.to raise_error(ArgumentError)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'filters out unkown parameters' do
|
|
31
|
+
subject.contributors user, repo, :unknown => true
|
|
32
|
+
a_get(request_path).with({}).should have_been_made
|
|
28
33
|
end
|
|
29
34
|
|
|
30
35
|
it "should find resources" do
|
|
@@ -25,6 +25,10 @@ describe Github::Repos::Downloads, '#create' do
|
|
|
25
25
|
let(:body) { fixture('repos/download_s3.json') }
|
|
26
26
|
let(:status) { 201}
|
|
27
27
|
|
|
28
|
+
it { expect { subject.create }.to raise_error(ArgumentError) }
|
|
29
|
+
|
|
30
|
+
it { expect { subject.create user }.to raise_error(ArgumentError) }
|
|
31
|
+
|
|
28
32
|
it "should fail to create resource if 'name' input is missing" do
|
|
29
33
|
expect {
|
|
30
34
|
subject.create user, repo, inputs.except(:name)
|
|
@@ -21,8 +21,12 @@ describe Github::Repos::Downloads, '#delete' do
|
|
|
21
21
|
let(:body) { "" }
|
|
22
22
|
let(:status) { 204 }
|
|
23
23
|
|
|
24
|
+
it { should respond_to :remove }
|
|
25
|
+
|
|
26
|
+
it { expect { subject.delete }.to raise_error(ArgumentError) }
|
|
27
|
+
|
|
24
28
|
it "should fail to delete without 'user/repo' parameters" do
|
|
25
|
-
expect { subject.delete }.to raise_error(ArgumentError)
|
|
29
|
+
expect { subject.delete user }.to raise_error(ArgumentError)
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
it "should fail to delete resource without 'download_id'" do
|
|
@@ -22,8 +22,10 @@ describe Github::Repos::Downloads, '#get' do
|
|
|
22
22
|
|
|
23
23
|
it { should respond_to :find }
|
|
24
24
|
|
|
25
|
+
it { expect { subject.get }.to raise_error(ArgumentError) }
|
|
26
|
+
|
|
25
27
|
it "should fail to get resource without download id" do
|
|
26
|
-
expect { subject.get user, repo
|
|
28
|
+
expect { subject.get user, repo }.to raise_error(ArgumentError)
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
it "should get the resource" do
|
|
@@ -21,8 +21,10 @@ describe Github::Repos::Downloads, '#list' do
|
|
|
21
21
|
|
|
22
22
|
it { should respond_to :all }
|
|
23
23
|
|
|
24
|
+
it { expect { subject.list }.to raise_error(ArgumentError) }
|
|
25
|
+
|
|
24
26
|
it "should fail to get resource without username" do
|
|
25
|
-
expect { subject.list }.to raise_error(ArgumentError)
|
|
27
|
+
expect { subject.list user }.to raise_error(ArgumentError)
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
it "should get the resources" do
|
|
@@ -20,6 +20,8 @@ describe Github::Repos::Forks, '#create' do
|
|
|
20
20
|
let(:body) { fixture('repos/fork.json') }
|
|
21
21
|
let(:status) { 202 }
|
|
22
22
|
|
|
23
|
+
it { expect { subject.create user }.to raise_error(ArgumentError) }
|
|
24
|
+
|
|
23
25
|
it "should create resource successfully" do
|
|
24
26
|
subject.create(user, repo, inputs)
|
|
25
27
|
a_post(request_path).with(inputs).should have_been_made
|
|
@@ -20,8 +20,10 @@ describe Github::Repos::Forks, '#list' do
|
|
|
20
20
|
|
|
21
21
|
it { should respond_to :all }
|
|
22
22
|
|
|
23
|
+
it { expect { subject.list }.to raise_error(ArgumentError) }
|
|
24
|
+
|
|
23
25
|
it "should fail to get resource without username" do
|
|
24
|
-
expect { subject.list }.to raise_error(ArgumentError)
|
|
26
|
+
expect { subject.list user }.to raise_error(ArgumentError)
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
it "should get the resources" do
|
|
@@ -40,7 +40,7 @@ describe Github::Repos::Hooks, '#list' do
|
|
|
40
40
|
|
|
41
41
|
it "should fail to edit resource without 'name' parameter" do
|
|
42
42
|
expect{
|
|
43
|
-
subject.edit user, repo, inputs.except(:name)
|
|
43
|
+
subject.edit user, repo, hook_id, inputs.except(:name)
|
|
44
44
|
}.to raise_error(Github::Error::RequiredParams)
|
|
45
45
|
end
|
|
46
46
|
|
|
@@ -24,7 +24,7 @@ describe Github::Repos::Keys, '#delete' do
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "should fail to delete resource without key id" do
|
|
27
|
-
expect { subject.delete user, repo
|
|
27
|
+
expect { subject.delete user, repo }.to raise_error(ArgumentError)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "should delete the resource" do
|
|
@@ -21,6 +21,8 @@ describe Github::Repos::Keys, '#edit' do
|
|
|
21
21
|
let(:body) { fixture("repos/key.json") }
|
|
22
22
|
let(:status) { 200 }
|
|
23
23
|
|
|
24
|
+
it { expect {subject.edit user, repo }.to raise_error(ArgumentError) }
|
|
25
|
+
|
|
24
26
|
it "should edit the resource" do
|
|
25
27
|
subject.edit user, repo, key_id, inputs
|
|
26
28
|
a_patch(request_path).should have_been_made
|
|
@@ -21,8 +21,10 @@ describe Github::Repos::Keys, '#get' do
|
|
|
21
21
|
|
|
22
22
|
it { should respond_to :find }
|
|
23
23
|
|
|
24
|
+
it { expect { subject.get }.to raise_error(ArgumentError) }
|
|
25
|
+
|
|
24
26
|
it "should fail to get resource without key" do
|
|
25
|
-
expect { subject.get user, repo
|
|
27
|
+
expect { subject.get user, repo }.to raise_error(ArgumentError)
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
it "should get the resource" do
|
|
@@ -20,8 +20,10 @@ describe Github::Repos::Keys, '#list' do
|
|
|
20
20
|
|
|
21
21
|
it { should respond_to :all }
|
|
22
22
|
|
|
23
|
-
it
|
|
24
|
-
|
|
23
|
+
it { expect { subject.list }.to raise_error(ArgumentError) }
|
|
24
|
+
|
|
25
|
+
it "should fail to get resource without repository" do
|
|
26
|
+
expect { subject.list user }.to raise_error(ArgumentError)
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
it "should get the resources" do
|
|
@@ -88,7 +88,7 @@ describe Github::Repos, '#list' do
|
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
-
context "resource found for
|
|
91
|
+
context "resource found for a user" do
|
|
92
92
|
let(:request_path) { "/users/#{user}/repos" }
|
|
93
93
|
|
|
94
94
|
before {
|
|
@@ -96,6 +96,11 @@ describe Github::Repos, '#list' do
|
|
|
96
96
|
:headers => {:content_type => "application/json; charset=utf-8"} )
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
it "should filter the parameters" do
|
|
100
|
+
subject.list 'user' => user, :unkown => true
|
|
101
|
+
a_get(request_path).with({}).should have_been_made
|
|
102
|
+
end
|
|
103
|
+
|
|
99
104
|
it "should get the resources" do
|
|
100
105
|
subject.list :user => user
|
|
101
106
|
a_get(request_path).should have_been_made
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::PubSubHubbub, '#subscribe_service' do
|
|
6
|
+
let(:topic) { "https://github.com/peter-murach/github/events/push"}
|
|
7
|
+
let(:callback) { "github://campfire?subdomain=github&room=Commits" }
|
|
8
|
+
let(:user) { 'peter-murach' }
|
|
9
|
+
let(:repo) { 'github' }
|
|
10
|
+
let(:service) { 'campfire' }
|
|
11
|
+
let(:options) {
|
|
12
|
+
{
|
|
13
|
+
:subdomain => 'github',
|
|
14
|
+
:room => 'Commits'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
after { reset_authentication_for subject }
|
|
19
|
+
|
|
20
|
+
it { expect { subject.subscribe_service }.to raise_error(ArgumentError) }
|
|
21
|
+
|
|
22
|
+
it "subscribes to service" do
|
|
23
|
+
subject.should_receive(:subscribe).with(topic, callback)
|
|
24
|
+
subject.subscribe_service user, repo, service, options
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end # subscribe_service
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::PubSubHubbub, '#subscribe' do
|
|
6
|
+
let(:topic) { "https://github.com/peter-murach/github/events/push"}
|
|
7
|
+
let(:callback) { "github://campfire?subdomain=github&room=Commits&token=abc123" }
|
|
8
|
+
let(:hub_inputs) {
|
|
9
|
+
{
|
|
10
|
+
"hub.mode" => 'subscribe',
|
|
11
|
+
"hub.topic" => topic,
|
|
12
|
+
"hub.callback" => callback,
|
|
13
|
+
"hub.verify" => 'sync',
|
|
14
|
+
"hub.secret" => ''
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let(:request_path) { "/hub?access_token=#{OAUTH_TOKEN}" }
|
|
19
|
+
|
|
20
|
+
before {
|
|
21
|
+
subject.oauth_token = OAUTH_TOKEN
|
|
22
|
+
stub_post(request_path).with(hub_inputs).
|
|
23
|
+
to_return(:body => '[]', :status => status,
|
|
24
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
after { reset_authentication_for subject }
|
|
29
|
+
|
|
30
|
+
context "success" do
|
|
31
|
+
let(:status) { 200 }
|
|
32
|
+
|
|
33
|
+
it { expect { subject.subscribe }.to raise_error(ArgumentError) }
|
|
34
|
+
|
|
35
|
+
it { expect { subject.subscribe topic, nil}.to raise_error(ArgumentError) }
|
|
36
|
+
|
|
37
|
+
it "subscribes to hub" do
|
|
38
|
+
subject.subscribe topic, callback
|
|
39
|
+
a_post("/hub?access_token=#{OAUTH_TOKEN}").with(hub_inputs).should have_been_made
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "" do
|
|
43
|
+
subject.subscribe(topic, callback)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it_should_behave_like 'request failure' do
|
|
48
|
+
let(:requestable) { subject.subscribe topic, callback }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end # subscribe
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::PubSubHubbub, '#unsubscribe_service' do
|
|
6
|
+
let(:topic) { "https://github.com/peter-murach/github/events/push"}
|
|
7
|
+
let(:callback) { "github://campfire" }
|
|
8
|
+
let(:user) { 'peter-murach' }
|
|
9
|
+
let(:repo) { 'github' }
|
|
10
|
+
let(:service) { 'campfire' }
|
|
11
|
+
|
|
12
|
+
after { reset_authentication_for subject }
|
|
13
|
+
|
|
14
|
+
it { expect { subject.unsubscribe_service }.to raise_error(ArgumentError) }
|
|
15
|
+
|
|
16
|
+
it "subscribes to service" do
|
|
17
|
+
subject.should_receive(:unsubscribe).with(topic, callback)
|
|
18
|
+
subject.unsubscribe_service user, repo, service
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end # unsubscribe_service
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::PubSubHubbub, '#unsubscribe' do
|
|
6
|
+
let(:topic) { "https://github.com/peter-murach/github/events/push"}
|
|
7
|
+
let(:callback) { "github://campfire?subdomain=github&room=Commits&token=abc123" }
|
|
8
|
+
let(:hub_inputs) {
|
|
9
|
+
{
|
|
10
|
+
"hub.mode" => 'subscribe',
|
|
11
|
+
"hub.topic" => topic,
|
|
12
|
+
"hub.callback" => callback,
|
|
13
|
+
"hub.verify" => 'sync',
|
|
14
|
+
"hub.secret" => ''
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let(:request_path) { "/hub?access_token=#{OAUTH_TOKEN}" }
|
|
19
|
+
|
|
20
|
+
before {
|
|
21
|
+
subject.oauth_token = OAUTH_TOKEN
|
|
22
|
+
stub_post(request_path).with(hub_inputs.merge("hub.mode" => 'unsubscribe')).
|
|
23
|
+
to_return(:body => '[]', :status => status,
|
|
24
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
after { reset_authentication_for subject }
|
|
29
|
+
|
|
30
|
+
context "success" do
|
|
31
|
+
let(:status) { 200 }
|
|
32
|
+
|
|
33
|
+
it { expect { subject.unsubscribe }.to raise_error(ArgumentError) }
|
|
34
|
+
|
|
35
|
+
it "should subscribe to hub" do
|
|
36
|
+
subject.unsubscribe topic, callback
|
|
37
|
+
a_post("/hub?access_token=#{OAUTH_TOKEN}").with(hub_inputs).should have_been_made
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it_should_behave_like 'request failure' do
|
|
42
|
+
let(:requestable) { subject.unsubscribe topic, callback }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# context "failure" do
|
|
46
|
+
# before do
|
|
47
|
+
# subject.oauth_token = OAUTH_TOKEN
|
|
48
|
+
# stub_post("/hub?access_token=#{OAUTH_TOKEN}").with(hub_inputs.merge("hub.mode" => 'unsubscribe')).
|
|
49
|
+
# to_return(:body => '[]', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
50
|
+
# end
|
|
51
|
+
#
|
|
52
|
+
# it "should fail to subscribe to hub" do
|
|
53
|
+
# expect {
|
|
54
|
+
# subject.unsubscribe topic, callback
|
|
55
|
+
# }.to raise_error(Github::Error::NotFound)
|
|
56
|
+
# end
|
|
57
|
+
# end
|
|
58
|
+
end # unsubscribe
|
|
@@ -25,6 +25,8 @@ describe Github::Repos::Statuses, '#create' do
|
|
|
25
25
|
let(:body) { fixture('repos/status.json') }
|
|
26
26
|
let(:status) { 201 }
|
|
27
27
|
|
|
28
|
+
it { expect { subject.create user, repo }.to raise_error(ArgumentError) }
|
|
29
|
+
|
|
28
30
|
it "should fail to create resource if 'state' input is missing" do
|
|
29
31
|
expect {
|
|
30
32
|
subject.create user, repo, sha, inputs.except('state')
|
data/spec/github/search_spec.rb
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
describe Github::Search do
|
|
6
|
-
let(:github) { Github.new }
|
|
7
6
|
let(:keyword) { 'api' }
|
|
8
7
|
|
|
9
|
-
after { reset_authentication_for(
|
|
8
|
+
after { reset_authentication_for(subject) }
|
|
10
9
|
|
|
11
10
|
context "#issues" do
|
|
12
11
|
let(:owner) { 'peter-murach' }
|
|
@@ -20,12 +19,17 @@ describe Github::Search do
|
|
|
20
19
|
end
|
|
21
20
|
|
|
22
21
|
it "should get the resources" do
|
|
23
|
-
|
|
22
|
+
subject.issues owner, repo, state, keyword
|
|
23
|
+
a_get("/legacy/issues/search/#{owner}/#{repo}/#{state}/#{keyword}").should have_been_made
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should get the resources through params hash" do
|
|
27
|
+
subject.issues :owner => owner, :repo => repo, :state => state, :keyword => keyword
|
|
24
28
|
a_get("/legacy/issues/search/#{owner}/#{repo}/#{state}/#{keyword}").should have_been_made
|
|
25
29
|
end
|
|
26
30
|
|
|
27
31
|
it "should get issue information" do
|
|
28
|
-
issues =
|
|
32
|
+
issues = subject.issues :owner => owner, :repo => repo, :state => state, :keyword => keyword
|
|
29
33
|
issues.issues.first.user.should == 'ckarbass'
|
|
30
34
|
end
|
|
31
35
|
end
|
|
@@ -37,13 +41,20 @@ describe Github::Search do
|
|
|
37
41
|
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
38
42
|
end
|
|
39
43
|
|
|
44
|
+
it { expect { subject.repos }.to raise_error(ArgumentError) }
|
|
45
|
+
|
|
40
46
|
it "should get the resources" do
|
|
41
|
-
|
|
47
|
+
subject.repos keyword
|
|
48
|
+
a_get("/legacy/repos/search/#{keyword}").should have_been_made
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should get the resource through params hash" do
|
|
52
|
+
subject.repos :keyword => keyword
|
|
42
53
|
a_get("/legacy/repos/search/#{keyword}").should have_been_made
|
|
43
54
|
end
|
|
44
55
|
|
|
45
56
|
it "should get repository information" do
|
|
46
|
-
repos =
|
|
57
|
+
repos = subject.repos :keyword => keyword
|
|
47
58
|
repos.repositories.first.username.should == 'mathiasbynens'
|
|
48
59
|
end
|
|
49
60
|
end
|
|
@@ -55,13 +66,15 @@ describe Github::Search do
|
|
|
55
66
|
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
56
67
|
end
|
|
57
68
|
|
|
69
|
+
it { expect { subject.users }.to raise_error(ArgumentError) }
|
|
70
|
+
|
|
58
71
|
it "should get the resources" do
|
|
59
|
-
|
|
72
|
+
subject.users :keyword => keyword
|
|
60
73
|
a_get("/legacy/user/search/#{keyword}").should have_been_made
|
|
61
74
|
end
|
|
62
75
|
|
|
63
76
|
it "should get user information" do
|
|
64
|
-
users =
|
|
77
|
+
users = subject.users :keyword => keyword
|
|
65
78
|
users.users.first.username.should == 'techno'
|
|
66
79
|
end
|
|
67
80
|
end
|
|
@@ -73,13 +86,15 @@ describe Github::Search do
|
|
|
73
86
|
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
74
87
|
end
|
|
75
88
|
|
|
89
|
+
it { expect { subject.email }.to raise_error(Github::Error::RequiredParams) }
|
|
90
|
+
|
|
76
91
|
it "should get the resources" do
|
|
77
|
-
|
|
92
|
+
subject.email :email => keyword
|
|
78
93
|
a_get("/legacy/user/email/#{keyword}").should have_been_made
|
|
79
94
|
end
|
|
80
95
|
|
|
81
96
|
it "should get user information" do
|
|
82
|
-
user =
|
|
97
|
+
user = subject.email :email => keyword
|
|
83
98
|
user.user.username.should == 'techno'
|
|
84
99
|
end
|
|
85
100
|
end
|