ghee 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +1 -0
- data/.gitignore +5 -0
- data/.rspec +0 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +353 -0
- data/Rakefile +15 -0
- data/ghee.gemspec +31 -0
- data/lib/ghee.rb +49 -0
- data/lib/ghee/api/authorizations.rb +14 -0
- data/lib/ghee/api/events.rb +25 -0
- data/lib/ghee/api/gists.rb +75 -0
- data/lib/ghee/api/issues.rb +98 -0
- data/lib/ghee/api/milestones.rb +47 -0
- data/lib/ghee/api/orgs.rb +103 -0
- data/lib/ghee/api/repos.rb +96 -0
- data/lib/ghee/api/users.rb +72 -0
- data/lib/ghee/connection.rb +33 -0
- data/lib/ghee/resource_proxy.rb +111 -0
- data/lib/ghee/state_methods.rb +29 -0
- data/lib/ghee/version.rb +4 -0
- data/spec/ghee/api/authorizations_spec.rb +46 -0
- data/spec/ghee/api/events_spec.rb +47 -0
- data/spec/ghee/api/gists_spec.rb +153 -0
- data/spec/ghee/api/hooks_spec.rb +52 -0
- data/spec/ghee/api/issues_spec.rb +122 -0
- data/spec/ghee/api/milestones_spec.rb +103 -0
- data/spec/ghee/api/orgs_spec.rb +56 -0
- data/spec/ghee/api/repos_spec.rb +126 -0
- data/spec/ghee/api/teams_spec.rb +90 -0
- data/spec/ghee/api/users_spec.rb +102 -0
- data/spec/ghee/connection_spec.rb +54 -0
- data/spec/ghee/resource_proxy_spec.rb +207 -0
- data/spec/ghee_spec.rb +42 -0
- data/spec/settings.yml.sample +5 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +16 -0
- metadata +208 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ghee::API::Repos::Hooks do
|
4
|
+
subject { Ghee.new(GH_AUTH) }
|
5
|
+
|
6
|
+
def should_be_a_hook(hook)
|
7
|
+
hook['url'].should include('hooks')
|
8
|
+
hook['active'].should be_true
|
9
|
+
hook['events'].size.should > 0
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#repos(login,name)#hooks" do
|
13
|
+
context "with a test web hook" do
|
14
|
+
before :all do
|
15
|
+
VCR.use_cassette "repos(login,name).hook.create.test" do
|
16
|
+
@test_hook = subject.repos(GH_USER,GH_REPO).hooks.create({
|
17
|
+
:name => "web",
|
18
|
+
:config => {:url => "http://google.com"}
|
19
|
+
})
|
20
|
+
@test_hook.should_not be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
let(:test_hook) {@test_hook}
|
24
|
+
|
25
|
+
it "should return a hook" do
|
26
|
+
VCR.use_cassette "repos(login,name).hooks" do
|
27
|
+
hooks = subject.repos(GH_USER,GH_REPO).hooks
|
28
|
+
should_be_a_hook hooks.first
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should patch the hook" do
|
33
|
+
VCR.use_cassette "repos(login,name).hooks.patch" do
|
34
|
+
hook = subject.repos(GH_USER,GH_REPO).hooks(test_hook['id']).patch({
|
35
|
+
:config => {:url => "http://herpderp.com"}
|
36
|
+
})
|
37
|
+
should_be_a_hook hook
|
38
|
+
hook["config"]["url"].should == "http://herpderp.com"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should destroy the hook" do
|
44
|
+
VCR.use_cassette "repos(login,name).hooks.destroy" do
|
45
|
+
hook = subject.repos(GH_USER,GH_REPO).hooks(test_hook['id']).destroy.should be_true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ghee::API::Issues do
|
4
|
+
subject { Ghee.new(GH_AUTH) }
|
5
|
+
|
6
|
+
def should_be_an_issue(issue)
|
7
|
+
issue["user"]["login"].should_not be_nil
|
8
|
+
issue["comments"].should_not be_nil
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#repos(login,name)#issues" do
|
12
|
+
it "should return repos issues" do
|
13
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO}).issues") do
|
14
|
+
issues = subject.repos(GH_USER, GH_REPO).issues
|
15
|
+
issues.size.should > 0
|
16
|
+
should_be_an_issue(issues.first)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#repos(login,name)#issues#closed" do
|
21
|
+
it "should return repos closed issues" do
|
22
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO}).issues.closed") do
|
23
|
+
issues = subject.repos(GH_USER, GH_REPO).issues.closed
|
24
|
+
issues.size.should > 0
|
25
|
+
should_be_an_issue(issues.first)
|
26
|
+
issues.each do |i|
|
27
|
+
i["state"].should == "closed"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#repos(login,name)#issues(1)" do
|
34
|
+
it "should return an issue by id" do
|
35
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO}).issues(1)") do
|
36
|
+
issue = subject.repos(GH_USER, GH_REPO).issues(1)
|
37
|
+
should_be_an_issue(issue)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Testing issue proxy
|
42
|
+
context "with issue number" do
|
43
|
+
before(:all) do
|
44
|
+
VCR.use_cassette "issues.test" do
|
45
|
+
@repo = subject.repos(GH_USER, GH_REPO)
|
46
|
+
@test_issue = @repo.issues.create({
|
47
|
+
:title => "Test issue"
|
48
|
+
})
|
49
|
+
end
|
50
|
+
end
|
51
|
+
let(:test_issue) { @test_issue }
|
52
|
+
let(:test_repo) { @repo }
|
53
|
+
|
54
|
+
describe "#patch" do
|
55
|
+
it "should patch the issue" do
|
56
|
+
VCR.use_cassette "issues(id).patch" do
|
57
|
+
issue = test_repo.issues(test_issue["number"]).patch({
|
58
|
+
:body => "awesome description"
|
59
|
+
})
|
60
|
+
should_be_an_issue(issue)
|
61
|
+
issue["body"].should == "awesome description"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#close" do
|
67
|
+
it "should close the issue" do
|
68
|
+
VCR.use_cassette "issues(id).close" do
|
69
|
+
closed = test_repo.issues(test_issue["number"]).close
|
70
|
+
closed.should be_true
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#comments" do
|
76
|
+
context "issue with comments " do
|
77
|
+
before :all do
|
78
|
+
VCR.use_cassette "issues(id).comments.create.test" do
|
79
|
+
@comment = test_repo.issues(test_issue["number"]).comments.create :body => "test comment"
|
80
|
+
@comment.should_not be_nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
let(:test_comment) { @comment }
|
84
|
+
|
85
|
+
it "should create comment" do
|
86
|
+
VCR.use_cassette "issues(id).comments.create" do
|
87
|
+
comment = test_repo.issues(test_issue["number"]).comments.create :body => "test comment"
|
88
|
+
comment.should_not be_nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should return comment by id" do
|
93
|
+
VCR.use_cassette "issues.comments(id)" do
|
94
|
+
comment = test_repo.issues.comments(test_comment["id"])
|
95
|
+
comment.should_not be_nil
|
96
|
+
comment["body"].should == "test comment"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should patch comment" do
|
101
|
+
VCR.use_cassette "issues.comments(id).patch" do
|
102
|
+
body = "some other description"
|
103
|
+
comment = test_repo.issues.comments(test_comment["id"]).patch(:body => body)
|
104
|
+
comment.should_not be_nil
|
105
|
+
comment["body"].should == body
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should destroy comment" do
|
110
|
+
VCR.use_cassette "issues.comments(id).destroy" do
|
111
|
+
comment = test_repo.issues(test_issue["number"]).comments.create :body => "test comment"
|
112
|
+
comment.should_not be_nil
|
113
|
+
comment["body"].should == "test comment"
|
114
|
+
test_repo.issues.comments(comment["id"]).destroy.should be_true
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ghee::API::Milestones do
|
4
|
+
subject { Ghee.new(GH_AUTH) }
|
5
|
+
|
6
|
+
def should_be_an_milestone(milestone)
|
7
|
+
milestone["creator"]["login"].should_not be_nil
|
8
|
+
milestone["title"].should_not be_nil
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#repos(login,name)#milestones" do
|
12
|
+
it "should return repos milestones" do
|
13
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO}).milestones") do
|
14
|
+
temp_milestone = subject.repos(GH_USER, GH_REPO).milestones.create({ :title => "Destroy test milestone" })
|
15
|
+
|
16
|
+
milestones = subject.repos(GH_USER, GH_REPO).milestones
|
17
|
+
milestones.size.should > 0
|
18
|
+
should_be_an_milestone(milestones.first)
|
19
|
+
|
20
|
+
subject.repos(GH_USER, GH_REPO).milestones(temp_milestone["number"]).destroy
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#repos(login,name)#milestones#closed" do
|
25
|
+
it "should return repos closed milestones" do
|
26
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO}).milestones.closed") do
|
27
|
+
temp_milestone = subject.repos(GH_USER, GH_REPO).milestones.create({ :title => "Destroy test milestone" })
|
28
|
+
subject.repos(GH_USER, GH_REPO).milestones(temp_milestone["number"]).close
|
29
|
+
|
30
|
+
milestones = subject.repos(GH_USER, GH_REPO).milestones.closed
|
31
|
+
milestones.size.should > 0
|
32
|
+
should_be_an_milestone(milestones.first)
|
33
|
+
milestones.each do |i|
|
34
|
+
i["state"].should == "closed"
|
35
|
+
end
|
36
|
+
|
37
|
+
subject.repos(GH_USER, GH_REPO).milestones(temp_milestone["number"]).destroy
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#repos(login,name)#milestones(1)" do
|
43
|
+
it "should return an milestone by id" do
|
44
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO}).milestones(1)") do
|
45
|
+
temp_milestone = subject.repos(GH_USER, GH_REPO).milestones.create({ :title => "Destroy test milestone" })
|
46
|
+
|
47
|
+
milestone = subject.repos(GH_USER, GH_REPO).milestones(1)
|
48
|
+
should_be_an_milestone(milestone)
|
49
|
+
|
50
|
+
subject.repos(GH_USER, GH_REPO).milestones(temp_milestone["number"]).destroy
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#destroy" do
|
55
|
+
it "should delete milestone" do
|
56
|
+
VCR.use_cassette "milestones(id).destroy" do
|
57
|
+
repo = subject.repos(GH_USER, GH_REPO)
|
58
|
+
test_milestone = repo.milestones.create({
|
59
|
+
:title => "Destroy test milestone"
|
60
|
+
})
|
61
|
+
should_be_an_milestone(test_milestone)
|
62
|
+
subject.repos(GH_USER, GH_REPO).milestones(test_milestone["number"]).destroy.should be_true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Testing milestone proxy
|
68
|
+
context "with milestone number" do
|
69
|
+
before(:all) do
|
70
|
+
VCR.use_cassette "milestones.test" do
|
71
|
+
@repo = subject.repos(GH_USER, GH_REPO)
|
72
|
+
@test_milestone = @repo.milestones.create({
|
73
|
+
:title => "Test milestone #{rand(100)}"
|
74
|
+
})
|
75
|
+
end
|
76
|
+
end
|
77
|
+
let(:test_milestone) { @test_milestone }
|
78
|
+
let(:test_repo) { @repo }
|
79
|
+
|
80
|
+
describe "#patch" do
|
81
|
+
it "should patch the milestone" do
|
82
|
+
VCR.use_cassette "milestones(id).patch" do
|
83
|
+
milestone = test_repo.milestones(test_milestone["number"]).patch({
|
84
|
+
:description => "awesome description"
|
85
|
+
})
|
86
|
+
should_be_an_milestone(milestone)
|
87
|
+
milestone["description"].should == "awesome description"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#close" do
|
93
|
+
it "should close the milestone" do
|
94
|
+
VCR.use_cassette "milestones(id).close" do
|
95
|
+
closed = test_repo.milestones(test_milestone["number"]).close
|
96
|
+
closed.should be_true
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ghee::API::Orgs do
|
4
|
+
subject { Ghee.new(GH_AUTH) }
|
5
|
+
|
6
|
+
describe "#orgs" do
|
7
|
+
|
8
|
+
it "should return list of authenticated users organizations" do
|
9
|
+
VCR.use_cassette "orgs" do
|
10
|
+
orgs = subject.orgs
|
11
|
+
orgs.size.should > 0
|
12
|
+
orgs.first["url"].should include("https://api.github.com/orgs")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return specific organization" do
|
17
|
+
VCR.use_cassette "orgs(name)" do
|
18
|
+
org = subject.orgs(GH_ORG)
|
19
|
+
org["url"].should include("https://api.github.com/orgs/#{GH_ORG}")
|
20
|
+
org["type"].should == "Organization"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# not sure how to test this. there isn't a good way to actually
|
25
|
+
# patch an organization
|
26
|
+
describe "#patch" do
|
27
|
+
it "should patch the org" do
|
28
|
+
true.should be_true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#repos" do
|
33
|
+
it "should return a list of repos" do
|
34
|
+
VCR.use_cassette "orgs(login).repos" do
|
35
|
+
repos = subject.orgs(GH_ORG).repos
|
36
|
+
repos.size.should > 0
|
37
|
+
repo = repos.first
|
38
|
+
repo['url'].should include('https://api.github.com/repos/')
|
39
|
+
repo['ssh_url'].should include('git@github.com:')
|
40
|
+
repo['owner']['login'].should_not be_nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return a repo" do
|
45
|
+
VCR.use_cassette "orgs(login).repos(name)" do
|
46
|
+
repos = subject.orgs(GH_ORG).repos
|
47
|
+
|
48
|
+
repo = subject.orgs(GH_ORG).repos(repos.first['name'])
|
49
|
+
repo['url'].should include('https://api.github.com/repos/')
|
50
|
+
repo['ssh_url'].should include('git@github.com:')
|
51
|
+
repo['owner']['login'].should_not be_nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ghee::API::Repos do
|
4
|
+
subject { Ghee.new(GH_AUTH) }
|
5
|
+
|
6
|
+
def should_be_a_repo(repo)
|
7
|
+
repo['url'].should include('https://api.github.com/repos/')
|
8
|
+
repo['ssh_url'].should include('git@github.com:')
|
9
|
+
repo['owner']['login'].should_not be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
describe "#repos(login,name)" do
|
14
|
+
it "should be a repo" do
|
15
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO})") do
|
16
|
+
repo = subject.repos(GH_USER, GH_REPO)
|
17
|
+
should_be_a_repo(repo)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#issues" do
|
22
|
+
it "should return issues for repo" do
|
23
|
+
VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).issues") do
|
24
|
+
issues = subject.repos(GH_USER, GH_REPO).issues
|
25
|
+
puts issues.sort_by! { |r| r["title"]}.reverse
|
26
|
+
issues.is_a?(Array).should be_true
|
27
|
+
issues.size.should > 0
|
28
|
+
issues.first["title"].should_not be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#labels" do
|
34
|
+
it "should return all the labels" do
|
35
|
+
VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).labels") do
|
36
|
+
temp_label = subject.repos(GH_USER, GH_REPO).labels.create(:color => "efefef", :name => "temp label")
|
37
|
+
|
38
|
+
labels = subject.repos(GH_USER, GH_REPO).labels
|
39
|
+
labels.size.should > 0
|
40
|
+
labels.first["color"].should_not be_nil
|
41
|
+
|
42
|
+
subject.repos(GH_USER, GH_REPO).labels(temp_label['name']).destroy
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should get a single label" do
|
47
|
+
VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).labels(id)") do
|
48
|
+
temp_label = subject.repos(GH_USER, GH_REPO).labels.create(:color => "efefef", :name => "temp label")
|
49
|
+
|
50
|
+
label = subject.repos(GH_USER,GH_REPO).labels(temp_label["name"])
|
51
|
+
label["color"].should == 'efefef'
|
52
|
+
label["name"].should == 'temp label'
|
53
|
+
|
54
|
+
subject.repos(GH_USER, GH_REPO).labels(temp_label['name']).destroy
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should patch a label" do
|
59
|
+
VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).labels.patched") do
|
60
|
+
label = subject.repos(GH_USER, GH_REPO).labels.create(:color => "efefef", :name => "patch label")
|
61
|
+
label["color"].should == "efefef"
|
62
|
+
label["url"].should include "labels/patch"
|
63
|
+
label["name"].should == "patch label"
|
64
|
+
|
65
|
+
patched = subject.repos(GH_USER, GH_REPO).labels(label["name"]).patch(:color => "000000", :name => "patched label")
|
66
|
+
patched["color"].should == "000000"
|
67
|
+
patched["url"].should include "labels/patched"
|
68
|
+
patched["name"].should == "patched label"
|
69
|
+
|
70
|
+
subject.repos(GH_USER, GH_REPO).labels(patched["name"]).destroy.should be_true
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should create a label" do
|
75
|
+
VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).labels.create") do
|
76
|
+
label = subject.repos(GH_USER, GH_REPO).labels.create(:color => "efefef", :name => "created label")
|
77
|
+
label["color"].should == "efefef"
|
78
|
+
label["url"].should include "labels/created"
|
79
|
+
label["name"].should == "created label"
|
80
|
+
subject.repos(GH_USER, GH_REPO).labels(label["name"]).destroy.should be_true
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#user" do
|
87
|
+
describe "#repos" do
|
88
|
+
it "should return users repos" do
|
89
|
+
VCR.use_cassette('users(login).repos') do
|
90
|
+
repos = subject.users(GH_USER).repos
|
91
|
+
repos.size.should > 0
|
92
|
+
should_be_a_repo(repos.first)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "#repo" do
|
98
|
+
it "should return a repo" do
|
99
|
+
VCR.use_cassette("user.repos(#{GH_REPO})") do
|
100
|
+
repo = subject.user.repos(GH_REPO)
|
101
|
+
repo.connection.should_not be_nil
|
102
|
+
repo.path_prefix.should == "/repos/#{GH_USER}/#{GH_REPO}"
|
103
|
+
should_be_a_repo(repo)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#milestones" do
|
108
|
+
it "should return milestones for repo" do
|
109
|
+
VCR.use_cassette("user.repos(#{GH_REPO}).milestones") do
|
110
|
+
milestones = subject.user.repos(GH_REPO).milestones
|
111
|
+
milestones.should be_instance_of(Array)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "#issues" do
|
117
|
+
it "should return issues for repo" do
|
118
|
+
VCR.use_cassette("user.repos(#{GH_REPO}).issues") do
|
119
|
+
issues = subject.user.repos(GH_REPO).issues
|
120
|
+
issues.should be_instance_of(Array)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|