githu3 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +179 -0
- data/bin/githu3 +7 -0
- data/lib/faraday/response/parse_json.rb +22 -0
- data/lib/githu3/cache/disk.rb +43 -0
- data/lib/githu3/cache/redis.rb +35 -0
- data/lib/githu3/cache.rb +8 -0
- data/lib/githu3/cli.rb +25 -0
- data/lib/githu3/client.rb +46 -30
- data/lib/githu3/comment.rb +15 -0
- data/lib/githu3/commit.rb +13 -0
- data/lib/githu3/connection.rb +47 -0
- data/lib/githu3/core_ext/hash.rb +18 -0
- data/lib/githu3/download.rb +4 -0
- data/lib/githu3/event.rb +6 -0
- data/lib/githu3/git_commit.rb +5 -0
- data/lib/githu3/issue.rb +10 -1
- data/lib/githu3/org.rb +1 -1
- data/lib/githu3/pull.rb +9 -0
- data/lib/githu3/ref.rb +9 -0
- data/lib/githu3/relations.rb +22 -2
- data/lib/githu3/repo.rb +14 -4
- data/lib/githu3/resource.rb +19 -4
- data/lib/githu3/resource_collection.rb +26 -9
- data/lib/githu3/store.rb +2 -2
- data/lib/githu3/team.rb +4 -0
- data/lib/githu3/tree.rb +4 -0
- data/lib/githu3/user.rb +5 -0
- data/lib/githu3/version.rb +1 -1
- data/lib/githu3.rb +23 -1
- metadata +94 -119
- data/.autotest +0 -3
- data/.document +0 -5
- data/.gitignore +0 -22
- data/.rspec +0 -4
- data/.travis.yml +0 -6
- data/Gemfile +0 -16
- data/Rakefile +0 -16
- data/githu3.gemspec +0 -34
- data/spec/fixtures/all_repos.json +0 -54
- data/spec/fixtures/error.json +0 -1
- data/spec/fixtures/issues/comments.json +0 -41
- data/spec/fixtures/issues/event.json +0 -12
- data/spec/fixtures/issues/events.json +0 -14
- data/spec/fixtures/me.json +0 -31
- data/spec/fixtures/orgs/github.json +0 -18
- data/spec/fixtures/orgs/rails.json +0 -18
- data/spec/fixtures/orgs.json +0 -14
- data/spec/fixtures/public_repos.json +0 -132
- data/spec/fixtures/repos/branches.json +0 -23
- data/spec/fixtures/repos/contributors.json +0 -58
- data/spec/fixtures/repos/faraday.json +0 -31
- data/spec/fixtures/repos/issue.json +0 -53
- data/spec/fixtures/repos/issues.json +0 -55
- data/spec/fixtures/repos/label.json +0 -5
- data/spec/fixtures/repos/labels.json +0 -7
- data/spec/fixtures/repos/milestone.json +0 -17
- data/spec/fixtures/repos/milestones.json +0 -19
- data/spec/fixtures/repos/tags.json +0 -164
- data/spec/fixtures/repos/teams.json +0 -17
- data/spec/fixtures/teams/1.json +0 -8
- data/spec/fixtures/teams/members.json +0 -8
- data/spec/fixtures/teams/repos.json +0 -28
- data/spec/fixtures/users/followers.json +0 -80
- data/spec/fixtures/users/following.json +0 -182
- data/spec/fixtures/users/orgs.json +0 -8
- data/spec/fixtures/users/repos.json +0 -132
- data/spec/fixtures/users/sbellity.json +0 -20
- data/spec/githu3/client_spec.rb +0 -66
- data/spec/githu3/error_spec.rb +0 -0
- data/spec/githu3/issue_spec.rb +0 -54
- data/spec/githu3/org_spec.rb +0 -79
- data/spec/githu3/repo_spec.rb +0 -100
- data/spec/githu3/resource_collection_spec.rb +0 -64
- data/spec/githu3/team_spec.rb +0 -47
- data/spec/githu3/user_spec.rb +0 -47
- data/spec/githu3_spec.rb +0 -7
- data/spec/helper.rb +0 -21
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"type": "User",
|
3
|
-
"url": "https://api.github.com/users/sbellity",
|
4
|
-
"avatar_url": "https://secure.gravatar.com/avatar/9abf3d284748357bb044d3386796ecd6?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
5
|
-
"login": "sbellity",
|
6
|
-
"blog": null,
|
7
|
-
"hireable": false,
|
8
|
-
"following": 53,
|
9
|
-
"created_at": "2008-04-02T18:24:06Z",
|
10
|
-
"email": "sbellity@gmail.com",
|
11
|
-
"public_gists": 3,
|
12
|
-
"followers": 13,
|
13
|
-
"html_url": "https://github.com/sbellity",
|
14
|
-
"name": "Stephane Bellity",
|
15
|
-
"company": null,
|
16
|
-
"bio": null,
|
17
|
-
"location": "Paris, France",
|
18
|
-
"id": 4250,
|
19
|
-
"public_repos": 19
|
20
|
-
}
|
data/spec/githu3/client_spec.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Githu3::Client do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@client = Githu3::Client.new("myvalidtoken")
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "Getting my stuff..." do
|
10
|
-
it "should be true if method exists" do
|
11
|
-
defined?(Githu3::VERSION).should be_true
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
it 'should be oauthed as me...' do
|
16
|
-
stub_get "/user", "me"
|
17
|
-
@client.me.login.should == 'sbellity'
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should retreive rails org' do
|
21
|
-
stub_get "/orgs/rails", "orgs/rails"
|
22
|
-
@client.org('rails').login.should == 'rails'
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should retreive my orgs' do
|
26
|
-
stub_get "/user/orgs", "orgs"
|
27
|
-
@client.orgs.length.should == 2
|
28
|
-
@client.orgs.first.login.should == "nuvoli"
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should retrieve all my repos' do
|
32
|
-
stub_get "/user/repos", "all_repos"
|
33
|
-
@client.repos.length.should == 2
|
34
|
-
@client.repos.first.name.should == "brm-ruby-logger"
|
35
|
-
@client.repos.first.private.should == true
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should retrieve all my public repos' do
|
39
|
-
stub_get "/user/repos?type=public", "public_repos"
|
40
|
-
@client.repos(:type => "public").length.should == 5
|
41
|
-
@client.repos(:type => "public").first.name.should == "futon4mongo"
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should tell me if i am following someone else...' do
|
45
|
-
stub_request(:get, "#{Githu3::Client::BaseUrl}/user/following/billevans").to_return(:status => 204)
|
46
|
-
@client.following?('billevans').should be_true
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should tell me if i am NOT following someone else...' do
|
50
|
-
stub_request(:get, "#{Githu3::Client::BaseUrl}/user/following/mildesdavis").to_return(:status => 404)
|
51
|
-
@client.following?('mildesdavis').should be_false
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should list my followers" do
|
55
|
-
stub_get "/user/followers", "users/followers"
|
56
|
-
@client.followers.length.should == 13
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should list my following" do
|
60
|
-
stub_get "/user/following", "users/following"
|
61
|
-
@client.following.length.should == 30
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
data/spec/githu3/error_spec.rb
DELETED
File without changes
|
data/spec/githu3/issue_spec.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Githu3::Issue do
|
4
|
-
|
5
|
-
def repo
|
6
|
-
stub_get "/repos/technoweenie/faraday", "repos/faraday"
|
7
|
-
@client.repo("technoweenie/faraday")
|
8
|
-
end
|
9
|
-
|
10
|
-
def issue
|
11
|
-
stub_get "/repos/technoweenie/faraday/issues/1", "repos/issue"
|
12
|
-
repo.issues("1")
|
13
|
-
end
|
14
|
-
|
15
|
-
before do
|
16
|
-
@client = Githu3::Client.new("myvalidtoken")
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
describe "Issue Events" do
|
21
|
-
it "should fetch an issue's events" do
|
22
|
-
stub_get "/repos/technoweenie/faraday/issues/1/events", "issues/events"
|
23
|
-
issue.events.length.should == 1
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should Get a single event' do
|
27
|
-
stub_get "/repos/technoweenie/faraday/issues/1/events/1", "issues/event"
|
28
|
-
issue.events('1').event.should == "closed"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "Issue Comments" do
|
33
|
-
it "should get a comments list for the issue" do
|
34
|
-
stub_get "/repos/technoweenie/faraday/issues/1/comments", "issues/comments"
|
35
|
-
issue.comments.length.should == 3
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should get a single comment" do
|
39
|
-
# TODO... check if github updates the route...
|
40
|
-
pending("Waiting for a relpy's from github's team on the route...")
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "Issue labels" do
|
45
|
-
it "should list its labels" do
|
46
|
-
stub_get "/repos/technoweenie/faraday/issues/1/labels", "repos/labels"
|
47
|
-
issue.labels.length.should == 1
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
end
|
data/spec/githu3/org_spec.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Githu3::Org do
|
4
|
-
|
5
|
-
def github
|
6
|
-
stub_get "/orgs/github", "/orgs/github"
|
7
|
-
@client.org "github"
|
8
|
-
end
|
9
|
-
|
10
|
-
before do
|
11
|
-
@client = Githu3::Client.new("myvalidtoken")
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should get its name right" do
|
15
|
-
github.name.should == "GitHub"
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "Getting an org's members..." do
|
19
|
-
|
20
|
-
it "should get its members" do
|
21
|
-
stub_get "/orgs/github/members", "teams/members"
|
22
|
-
github.members.length.should == 1
|
23
|
-
github.members.first.login.should == "octocat"
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should tell me if a user IS a member of the team' do
|
27
|
-
stub_request(:get, "#{Githu3::Client::BaseUrl}/orgs/github/members/octocat").to_return(:status => 204)
|
28
|
-
github.member?('octocat').should be_true
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should tell me if a user IS NOT a member of the org' do
|
32
|
-
stub_request(:get, "#{Githu3::Client::BaseUrl}/orgs/github/members/billevans").to_return(:status => 404)
|
33
|
-
github.member?('billevans').should be_false
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should get its teams" do
|
37
|
-
stub_get "/orgs/github/teams", "repos/teams"
|
38
|
-
github.teams.length.should == 3
|
39
|
-
github.teams.first.name.should == "Developers"
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "Getting an org's public_members..." do
|
45
|
-
|
46
|
-
it "should get its public_members" do
|
47
|
-
stub_get "/orgs/github/public_members", "teams/members"
|
48
|
-
github.public_members.length.should == 1
|
49
|
-
github.public_members.first.login.should == "octocat"
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should tell me if a user IS a public_member of the team' do
|
53
|
-
stub_request(:get, "#{Githu3::Client::BaseUrl}/orgs/github/public_members/octocat").to_return(:status => 204)
|
54
|
-
github.public_member?('octocat').should be_true
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should tell me if a user IS NOT a public_member of the team' do
|
58
|
-
stub_request(:get, "#{Githu3::Client::BaseUrl}/orgs/github/public_members/billevans").to_return(:status => 404)
|
59
|
-
github.public_member?('billevans').should be_false
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "Getting the org's repos" do
|
64
|
-
|
65
|
-
it "should get its repos" do
|
66
|
-
stub_get "/orgs/github/repos", "all_repos"
|
67
|
-
github.repos.length.should == 2
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should get its public repos" do
|
71
|
-
stub_get "/orgs/github/repos?type=public", "public_repos"
|
72
|
-
github.repos(:type => "public").length.should == 5
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
end
|
data/spec/githu3/repo_spec.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Githu3::Repo do
|
4
|
-
|
5
|
-
def faraday
|
6
|
-
stub_get "/repos/technoweenie/faraday", "repos/faraday"
|
7
|
-
@client.repo("technoweenie/faraday")
|
8
|
-
end
|
9
|
-
|
10
|
-
before do
|
11
|
-
@client = Githu3::Client.new("myvalidtoken")
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "Getting a repo's stuff..." do
|
15
|
-
|
16
|
-
it "should get the repo infos" do
|
17
|
-
faraday.name.should == "faraday"
|
18
|
-
faraday.owner['login'].should == "technoweenie"
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should fetch its contributors" do
|
22
|
-
stub_get "/repos/technoweenie/faraday/contributors", "repos/contributors"
|
23
|
-
faraday.contributors.length.should == 8
|
24
|
-
faraday.contributors.first.login.should == "technoweenie"
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should fetch its teams" do
|
28
|
-
stub_get "/repos/technoweenie/faraday/teams", "repos/teams"
|
29
|
-
teams = faraday.teams
|
30
|
-
teams.length.should == 3
|
31
|
-
teams.first.name.should == "Developers"
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "Getting a repo's refs" do
|
37
|
-
|
38
|
-
it "should fetch its tags" do
|
39
|
-
stub_get "/repos/technoweenie/faraday/tags", "repos/tags"
|
40
|
-
tags = faraday.tags
|
41
|
-
tags.length.should == 18
|
42
|
-
tags.first.name.should == "v0.5.6"
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should fetch its branches" do
|
46
|
-
stub_get "/repos/technoweenie/faraday/branches", "repos/branches"
|
47
|
-
branches = faraday.branches
|
48
|
-
branches.length.should == 3
|
49
|
-
branches.first.name.should == "master"
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "Wokring with its issues..." do
|
55
|
-
|
56
|
-
it "should list its issues" do
|
57
|
-
stub_get "/repos/technoweenie/faraday/issues", "repos/issues"
|
58
|
-
faraday.issues.length.should == 1
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should filter its issues" do
|
62
|
-
stub_get "/repos/technoweenie/faraday/issues?state=open&labels=bug,feature", "repos/issues"
|
63
|
-
faraday.issues(:state => "open", :labels => "bug,feature").length.should == 1
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should fetch a single issue" do
|
67
|
-
stub_get "/repos/technoweenie/faraday/issues/1", "repos/issue"
|
68
|
-
faraday.issues("1").state.should == "open"
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should list its issues" do
|
72
|
-
stub_get "/repos/technoweenie/faraday/issues/events", "issues/events"
|
73
|
-
faraday.events.length.should == 1
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should list its labels" do
|
77
|
-
stub_get "/repos/technoweenie/faraday/labels", "repos/labels"
|
78
|
-
faraday.labels.length.should == 1
|
79
|
-
faraday.labels.first.name.should == "bug"
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should get a single labels" do
|
83
|
-
stub_get "/repos/technoweenie/faraday/labels/bug", "repos/label"
|
84
|
-
faraday.labels("bug").name.should == "bug"
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should list its milestones" do
|
88
|
-
stub_get "/repos/technoweenie/faraday/milestones", "repos/milestones"
|
89
|
-
faraday.milestones.length.should == 1
|
90
|
-
faraday.milestones.first.title.should == "v1.0"
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should get a single milestone" do
|
94
|
-
stub_get "/repos/technoweenie/faraday/milestones/1", "repos/milestone"
|
95
|
-
faraday.milestones("1").title.should == "v1.0"
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Githu3::ResourceCollection do
|
4
|
-
|
5
|
-
def collection
|
6
|
-
stub_get "/user/orgs", "orgs"
|
7
|
-
Githu3::ResourceCollection.new(@client, Githu3::Org, "/user/orgs")
|
8
|
-
end
|
9
|
-
|
10
|
-
before do
|
11
|
-
@client = Githu3::Client.new("myvalidtoken")
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "Enumerable behaviour" do
|
15
|
-
|
16
|
-
it "sould forward enumerable methods to @resource" do
|
17
|
-
collection.length.should == 2
|
18
|
-
collection.map { |o| o.login }.sort.should == ['nuvoli', 'sixdegrees']
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "Pagination" do
|
24
|
-
|
25
|
-
it "should paginate correctly" do
|
26
|
-
stub_get "/user/repos?type=public", "public_repos"
|
27
|
-
public_repos = Githu3::ResourceCollection.new(@client, Githu3::Org, "/user/repos", :type => "public")
|
28
|
-
public_repos.length.should == 5
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should set pagination options correctly" do
|
32
|
-
stub_get "/user/repos?per_page=5&type=public", "public_repos"
|
33
|
-
paginated = Githu3::ResourceCollection.new(@client, Githu3::Org, "/user/repos", :type => "public", :per_page => 5)
|
34
|
-
paginated.length.should == 5
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should correctly set pagination info" do
|
38
|
-
link_header = <<-EOL
|
39
|
-
<https://api.github.com/resource?page=2>; rel="next",
|
40
|
-
<https://api.github.com/resource?page=5>; rel="last"
|
41
|
-
EOL
|
42
|
-
|
43
|
-
stub_request(:get, "https://api.github.com/user/repos?page=1&per_page=5&type=public").
|
44
|
-
to_return(:headers => { "Link" => link_header })
|
45
|
-
|
46
|
-
paginated = Githu3::ResourceCollection.new(@client, Githu3::Org, "/user/repos", :type => "public", :per_page => 5, :page => 1)
|
47
|
-
paginated.pagination["next"].should == 2
|
48
|
-
paginated.pagination["last"].should == 5
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "Error Handling" do
|
54
|
-
|
55
|
-
it "should record an error... it one occurs" do
|
56
|
-
stub_request(:get, "#{Githu3::Client::BaseUrl}/user/repos").to_return(:status => 401, :body => fixture('error.json'))
|
57
|
-
lambda {
|
58
|
-
Githu3::ResourceCollection.new(@client, Githu3::Org, "/user/repos")
|
59
|
-
}.should raise_error(Githu3::Unauthorized)
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
data/spec/githu3/team_spec.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Githu3::Team do
|
4
|
-
|
5
|
-
def team
|
6
|
-
stub_get "/teams/1", "teams/1"
|
7
|
-
@client.team "1"
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
before do
|
12
|
-
@client = Githu3::Client.new("myvalidtoken")
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should get its name right" do
|
16
|
-
team.name.should == "Owners"
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "Getting the team's members..." do
|
20
|
-
|
21
|
-
it "should get its members" do
|
22
|
-
stub_get "/teams/1/members", "teams/members"
|
23
|
-
team.members.length.should == 1
|
24
|
-
team.members.first.login.should == "octocat"
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should tell me if a user IS a member of the team' do
|
28
|
-
stub_request(:get, "#{Githu3::Client::BaseUrl}/teams/1/members/octocat").to_return(:status => 204)
|
29
|
-
team.member?('octocat').should be_true
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should tell me if a user IS NOT a member of the team' do
|
33
|
-
stub_request(:get, "#{Githu3::Client::BaseUrl}/teams/1/members/billevans").to_return(:status => 404)
|
34
|
-
team.member?('billevans').should be_false
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "Getting the team's repos..." do
|
39
|
-
|
40
|
-
it "should list the team's repos" do
|
41
|
-
stub_get "/teams/1/repos", "teams/repos"
|
42
|
-
team.repos.length.should == 1
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
data/spec/githu3/user_spec.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Githu3::User do
|
4
|
-
|
5
|
-
def sbellity
|
6
|
-
stub_get "/users/sbellity", "users/sbellity"
|
7
|
-
@client.user("sbellity")
|
8
|
-
end
|
9
|
-
|
10
|
-
before do
|
11
|
-
@client = Githu3::Client.new("myvalidtoken")
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "Getting a users's stuff..." do
|
15
|
-
|
16
|
-
it "should get a user's infos" do
|
17
|
-
sbellity.login.should == "sbellity"
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should get the user's public repos" do
|
21
|
-
stub_get "/users/sbellity/repos", "users/repos"
|
22
|
-
sbellity.repos.length.should == 5
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should get the user's member repos" do
|
26
|
-
stub_get "/users/sbellity/repos?type=member", "users/repos"
|
27
|
-
sbellity.repos(:type => 'member').length.should == 5
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should get the user's public orgs" do
|
31
|
-
stub_get "/users/sbellity/orgs", "users/orgs"
|
32
|
-
sbellity.orgs.length.should == 1
|
33
|
-
sbellity.orgs.first.login.should == "sixdegrees"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should get the user's followers" do
|
37
|
-
stub_get "/users/sbellity/followers", "users/followers"
|
38
|
-
sbellity.followers.length.should == 13
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should get the user's following" do
|
42
|
-
stub_get "/users/sbellity/following", "users/following"
|
43
|
-
sbellity.following.length.should == 30
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
data/spec/githu3_spec.rb
DELETED
data/spec/helper.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
$:.unshift File.expand_path('..', __FILE__)
|
2
|
-
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
-
require 'simplecov'
|
4
|
-
SimpleCov.start
|
5
|
-
require 'githu3'
|
6
|
-
require 'rspec'
|
7
|
-
require 'webmock/rspec'
|
8
|
-
|
9
|
-
def fixture_path
|
10
|
-
File.expand_path("../fixtures", __FILE__)
|
11
|
-
end
|
12
|
-
|
13
|
-
def fixture(file)
|
14
|
-
File.new(fixture_path + '/' + file)
|
15
|
-
end
|
16
|
-
|
17
|
-
def stub_get url, fixture_name, headers={ 'Authorization'=>'token myvalidtoken' }
|
18
|
-
stub_request(:get, "#{Githu3::Client::BaseUrl}#{url}").
|
19
|
-
with(:headers => headers).
|
20
|
-
to_return(:status => 200, :body => fixture("#{fixture_name}.json"))
|
21
|
-
end
|