github_api 0.8.1 → 0.8.2

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.
Files changed (99) hide show
  1. data/README.md +2 -1
  2. data/features/README.rdoc +4 -4
  3. data/features/cassettes/gitignore/get.yml +60 -0
  4. data/features/cassettes/gitignore/get_raw.yml +224 -0
  5. data/features/cassettes/gitignore/list.yml +67 -0
  6. data/features/cassettes/issues/comments/get.yml +71 -0
  7. data/features/cassettes/issues/comments/list_issue.yml +82 -0
  8. data/features/cassettes/issues/comments/list_repo.yml +266 -0
  9. data/features/cassettes/pull_requests/comments/get.yml +159 -0
  10. data/features/cassettes/pull_requests/comments/list_pull.yml +54 -0
  11. data/features/cassettes/pull_requests/comments/list_repo.yml +54 -0
  12. data/features/cassettes/repos/list_repos.yml +129 -0
  13. data/features/cassettes/users/all.yml +256 -0
  14. data/features/gitignore.feature +37 -0
  15. data/features/issues/comments.feature +37 -0
  16. data/features/pull_requests/comments.feature +27 -0
  17. data/features/repos.feature +8 -0
  18. data/features/step_definitions/common_steps.rb +2 -0
  19. data/features/users.feature +8 -0
  20. data/lib/github_api.rb +1 -0
  21. data/lib/github_api/client.rb +5 -0
  22. data/lib/github_api/git_data/tags.rb +4 -4
  23. data/lib/github_api/gitignore.rb +56 -0
  24. data/lib/github_api/issues/comments.rb +23 -9
  25. data/lib/github_api/pull_requests/comments.rb +24 -6
  26. data/lib/github_api/repos.rb +14 -1
  27. data/lib/github_api/repos/keys.rb +4 -4
  28. data/lib/github_api/users.rb +21 -0
  29. data/lib/github_api/users/keys.rb +6 -6
  30. data/lib/github_api/version.rb +1 -1
  31. data/spec/fixtures/gitignore/template.json +4 -0
  32. data/spec/fixtures/gitignore/template_raw +1 -0
  33. data/spec/fixtures/gitignore/templates.json +9 -0
  34. data/spec/fixtures/users/users.json +9 -0
  35. data/spec/github/activity/notifications/mark_spec.rb +1 -1
  36. data/spec/github/activity/starring/starring_spec.rb +2 -2
  37. data/spec/github/activity/watching/watching_spec.rb +2 -2
  38. data/spec/github/git_data/commits/create_spec.rb +75 -0
  39. data/spec/github/git_data/commits/get_spec.rb +50 -0
  40. data/spec/github/git_data/commits_spec.rb +1 -126
  41. data/spec/github/git_data/references/create_spec.rb +67 -0
  42. data/spec/github/git_data/references/delete_spec.rb +38 -0
  43. data/spec/github/git_data/references/get_spec.rb +54 -0
  44. data/spec/github/git_data/references/list_spec.rb +77 -0
  45. data/spec/github/git_data/references/update_spec.rb +62 -0
  46. data/spec/github/git_data/references_spec.rb +1 -298
  47. data/spec/github/git_data/tags/create_spec.rb +61 -0
  48. data/spec/github/git_data/tags/get_spec.rb +48 -0
  49. data/spec/github/git_data/tags_spec.rb +0 -108
  50. data/spec/github/git_data/trees/create_spec.rb +62 -0
  51. data/spec/github/git_data/trees/get_spec.rb +69 -0
  52. data/spec/github/git_data/trees_spec.rb +0 -133
  53. data/spec/github/gitignore/get_spec.rb +54 -0
  54. data/spec/github/gitignore/list_spec.rb +42 -0
  55. data/spec/github/issues/comments_spec.rb +46 -11
  56. data/spec/github/pull_requests/comments_spec.rb +46 -11
  57. data/spec/github/pull_requests_spec.rb +3 -3
  58. data/spec/github/repos/contents/archive_spec.rb +26 -0
  59. data/spec/github/repos/contents/get_spec.rb +30 -0
  60. data/spec/github/repos/contents/readme_spec.rb +30 -0
  61. data/spec/github/repos/hooks/create_spec.rb +68 -0
  62. data/spec/github/repos/hooks/delete_spec.rb +40 -0
  63. data/spec/github/repos/hooks/edit_spec.rb +77 -0
  64. data/spec/github/repos/hooks/get_spec.rb +49 -0
  65. data/spec/github/repos/hooks/list_spec.rb +54 -0
  66. data/spec/github/repos/hooks/test_spec.rb +40 -0
  67. data/spec/github/repos/hooks_spec.rb +2 -337
  68. data/spec/github/repos/keys/create_spec.rb +50 -0
  69. data/spec/github/repos/keys/delete_spec.rb +40 -0
  70. data/spec/github/repos/keys/edit_spec.rb +40 -0
  71. data/spec/github/repos/keys/get_spec.rb +43 -0
  72. data/spec/github/repos/keys/list_spec.rb +52 -0
  73. data/spec/github/repos/keys_spec.rb +2 -213
  74. data/spec/github/repos/list_spec.rb +19 -3
  75. data/spec/github/repos/merging/merge_spec.rb +58 -0
  76. data/spec/github/repos/pub_sub_hubbub_spec.rb +16 -14
  77. data/spec/github/repos/statuses/create_spec.rb +54 -0
  78. data/spec/github/repos/statuses/list_spec.rb +53 -0
  79. data/spec/github/repos/statuses_spec.rb +1 -114
  80. data/spec/github/users/emails/add_spec.rb +33 -0
  81. data/spec/github/users/emails/delete_spec.rb +33 -0
  82. data/spec/github/users/emails/list_spec.rb +52 -0
  83. data/spec/github/users/followers/list_spec.rb +68 -0
  84. data/spec/github/users/followers_spec.rb +0 -70
  85. data/spec/github/users/get_spec.rb +66 -0
  86. data/spec/github/users/keys/create_spec.rb +51 -0
  87. data/spec/github/users/keys/delete_spec.rb +37 -0
  88. data/spec/github/users/keys/get_spec.rb +50 -0
  89. data/spec/github/users/keys/list_spec.rb +50 -0
  90. data/spec/github/users/keys/update_spec.rb +56 -0
  91. data/spec/github/users/list_spec.rb +45 -0
  92. data/spec/github/users/update_spec.rb +56 -0
  93. metadata +96 -43
  94. data/spec/github/repos/contents_spec.rb +0 -65
  95. data/spec/github/repos/merging_spec.rb +0 -71
  96. data/spec/github/repos/starring_spec.rb +0 -4
  97. data/spec/github/users/emails_spec.rb +0 -110
  98. data/spec/github/users/keys_spec.rb +0 -256
  99. data/spec/github/users_spec.rb +0 -128
@@ -4,7 +4,7 @@ module Github
4
4
  module VERSION
5
5
  MAJOR = 0
6
6
  MINOR = 8
7
- PATCH = 1
7
+ PATCH = 2
8
8
  BUILD = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.');
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "C",
3
+ "source": "# Object files\n*.o\n\n# Libraries\n*.lib\n*.a\n\n# Shared objects (inc. Windows DLLs)\n*.dll\n*.so\n*.so.*\n*.dylib\n\n# Executables\n*.exe\n*.out\n*.app\n"
4
+ }
@@ -0,0 +1 @@
1
+ "*.gem\n*.rbc\n.bundle\n.config\ncoverage\nInstalledFiles\nlib/bundler/man\npkg\nrdoc\nspec/reports\ntest/tmp\ntest/version_tmp\ntmp\n\n# YARD artifacts\n.yardoc\n_yardoc\ndoc/\n"
@@ -0,0 +1,9 @@
1
+ [
2
+ "Actionscript",
3
+ "Android",
4
+ "AppceleratorTitanium",
5
+ "Autotools",
6
+ "Bancha",
7
+ "C",
8
+ "C++"
9
+ ]
@@ -0,0 +1,9 @@
1
+ [
2
+ {
3
+ "login": "octocat",
4
+ "id": 1,
5
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
6
+ "gravatar_id": "somehexcode",
7
+ "url": "https://api.github.com/users/octocat"
8
+ }
9
+ ]
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Github::Activity::Notifications, '#mark' do
6
- let(:body) { '' }
6
+ let(:body) { '[]' }
7
7
  let(:status) { 205 }
8
8
  let(:inputs) { {
9
9
  :read => true,
@@ -13,7 +13,7 @@ describe Github::Activity::Starring, '#list' do
13
13
  context "this repo is being watched by the user"
14
14
  before do
15
15
  stub_get(request_path).
16
- to_return(:body => "", :status => 404,
16
+ to_return(:body => "[]", :status => 404,
17
17
  :headers => {:user_agent => subject.user_agent})
18
18
  end
19
19
 
@@ -23,7 +23,7 @@ describe Github::Activity::Starring, '#list' do
23
23
  end
24
24
 
25
25
  it "should return true if resoure found" do
26
- stub_get(request_path).to_return(:body => "", :status => 200,
26
+ stub_get(request_path).to_return(:body => "[]", :status => 200,
27
27
  :headers => {:user_agent => subject.user_agent})
28
28
  starring = subject.starring? user, repo
29
29
  starring.should be_true
@@ -13,7 +13,7 @@ describe Github::Activity::Watching, '#list' do
13
13
  context "this repo is being watched by the user"
14
14
  before do
15
15
  stub_get(request_path).
16
- to_return(:body => "", :status => 404,
16
+ to_return(:body => "[]", :status => 404,
17
17
  :headers => {:user_agent => subject.user_agent})
18
18
  end
19
19
 
@@ -24,7 +24,7 @@ describe Github::Activity::Watching, '#list' do
24
24
 
25
25
  it "should return true if resoure found" do
26
26
  stub_get(request_path).
27
- to_return(:body => "", :status => 200,
27
+ to_return(:body => "[]", :status => 200,
28
28
  :headers => {:user_agent => subject.user_agent})
29
29
  watching = subject.watching? user, repo
30
30
  watching.should be_true
@@ -0,0 +1,75 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::GitData::Commits, '#get' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:repo) { 'github' }
8
+ let(:request_path) { "/repos/#{user}/#{repo}/git/commits" }
9
+ let(:inputs) {
10
+ {
11
+ "message" => "my commit message",
12
+ "author" => {
13
+ "name" => "Scott Chacon",
14
+ "email" => "schacon@gmail.com",
15
+ "date" => "2008-07-09T16:13:30+12:00"
16
+ },
17
+ "parents" => [
18
+ "7d1b31e74ee336d15cbd21741bc88a537ed063a0"
19
+ ],
20
+ "tree" => "827efc6d56897b048c772eb4087f854f46256132",
21
+ 'unrelated' => 'giberrish'
22
+ }
23
+ }
24
+
25
+ before {
26
+ stub_post(request_path).with(inputs.except('unrelated')).
27
+ to_return(:body => body, :status => status,
28
+ :headers => {:content_type => "application/json; charset=utf-8"})
29
+ }
30
+
31
+ after { reset_authentication_for subject }
32
+
33
+ context "resouce created" do
34
+ let(:body) { fixture('git_data/commit.json') }
35
+ let(:status) { 201 }
36
+
37
+ it "should fail to create resource if 'message' input is missing" do
38
+ expect {
39
+ subject.create user, repo, inputs.except('message')
40
+ }.to raise_error(Github::Error::RequiredParams)
41
+ end
42
+
43
+ it "should fail to create resource if 'tree' input is missing" do
44
+ expect {
45
+ subject.create user, repo, inputs.except('tree')
46
+ }.to raise_error(Github::Error::RequiredParams)
47
+ end
48
+
49
+ it "should fail to create resource if 'parents' input is missing" do
50
+ expect {
51
+ subject.create user, repo, inputs.except('parents')
52
+ }.to raise_error(Github::Error::RequiredParams)
53
+ end
54
+
55
+ it "should create resource successfully" do
56
+ subject.create user, repo, inputs
57
+ a_post(request_path).with(inputs).should have_been_made
58
+ end
59
+
60
+ it "should return the resource" do
61
+ commit = subject.create user, repo, inputs
62
+ commit.should be_a Hashie::Mash
63
+ end
64
+
65
+ it "should get the commit information" do
66
+ commit = subject.create user, repo, inputs
67
+ commit.author.name.should eql "Scott Chacon"
68
+ end
69
+ end
70
+
71
+ it_should_behave_like 'request failure' do
72
+ let(:requestable) { subject.create user, repo, inputs }
73
+ end
74
+
75
+ end # create
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::GitData::Commits, '#get' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:repo) { 'github' }
8
+ let(:sha) { "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15" }
9
+ let(:request_path) { "/repos/#{user}/#{repo}/git/commits/#{sha}" }
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
+ let(:body) { fixture('git_data/commit.json') }
20
+ let(:status) { 200 }
21
+
22
+ it { should respond_to :find }
23
+
24
+ it "should fail to get resource without sha" do
25
+ expect {
26
+ subject.get user, repo, nil
27
+ }.to raise_error(ArgumentError)
28
+ end
29
+
30
+ it "should get the resource" do
31
+ subject.get user, repo, sha
32
+ a_get(request_path).should have_been_made
33
+ end
34
+
35
+ it "should get commit information" do
36
+ commit = subject.get user, repo, sha
37
+ commit.author.name.should eql "Scott Chacon"
38
+ end
39
+
40
+ it "should return mash" do
41
+ commit = subject.get user, repo, sha
42
+ commit.should be_a Hashie::Mash
43
+ end
44
+ end
45
+
46
+ it_should_behave_like 'request failure' do
47
+ let(:requestable) { subject.get user, repo, sha }
48
+ end
49
+
50
+ end # get
@@ -2,133 +2,8 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Github::GitData::Commits, :type => :base do
6
- let(:github) { Github.new }
7
- let(:user) { 'peter-murach' }
8
- let(:repo) { 'github' }
9
- let(:sha) { "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15" }
10
-
11
- after { github.user, github.repo, github.oauth_token = nil, nil, nil }
5
+ describe Github::GitData::Commits do
12
6
 
13
7
  it { described_class::VALID_COMMIT_PARAM_NAMES.should_not be_nil }
14
8
 
15
- describe "#get" do
16
- it { github.git_data.commits.should respond_to :find }
17
-
18
- context "resource found" do
19
- before do
20
- stub_get("/repos/#{user}/#{repo}/git/commits/#{sha}").
21
- to_return(:body => fixture('git_data/commit.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
22
- end
23
-
24
- it "should fail to get resource without sha" do
25
- expect {
26
- github.git_data.commits.get user, repo, nil
27
- }.to raise_error(ArgumentError)
28
- end
29
-
30
- it "should get the resource" do
31
- github.git_data.commits.get user, repo, sha
32
- a_get("/repos/#{user}/#{repo}/git/commits/#{sha}").should have_been_made
33
- end
34
-
35
- it "should get commit information" do
36
- commit = github.git_data.commits.get user, repo, sha
37
- commit.author.name.should eql "Scott Chacon"
38
- end
39
-
40
- it "should return mash" do
41
- commit = github.git_data.commits.get user, repo, sha
42
- commit.should be_a Hashie::Mash
43
- end
44
- end
45
-
46
- context "resource not found" do
47
- before do
48
- stub_get("/repos/#{user}/#{repo}/git/commits/#{sha}").
49
- to_return(:body => fixture('git_data/commit.json'),
50
- :status => 404,
51
- :headers => {:content_type => "application/json; charset=utf-8"})
52
- end
53
-
54
- it "should fail to retrive resource" do
55
- expect {
56
- github.git_data.commits.get user, repo, sha
57
- }.to raise_error(Github::Error::NotFound)
58
- end
59
- end
60
- end # get
61
-
62
- describe "#create" do
63
- let(:inputs) {
64
- {
65
- "message" => "my commit message",
66
- "author" => {
67
- "name" => "Scott Chacon",
68
- "email" => "schacon@gmail.com",
69
- "date" => "2008-07-09T16:13:30+12:00"
70
- },
71
- "parents" => [
72
- "7d1b31e74ee336d15cbd21741bc88a537ed063a0"
73
- ],
74
- "tree" => "827efc6d56897b048c772eb4087f854f46256132",
75
- 'unrelated' => 'giberrish'
76
- }
77
- }
78
-
79
- context "resouce created" do
80
- before do
81
- stub_post("/repos/#{user}/#{repo}/git/commits").
82
- with(inputs.except('unrelated')).
83
- to_return(:body => fixture('git_data/commit.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
84
- end
85
-
86
- it "should fail to create resource if 'message' input is missing" do
87
- expect {
88
- github.git_data.commits.create user, repo, inputs.except('message')
89
- }.to raise_error(Github::Error::RequiredParams)
90
- end
91
-
92
- it "should fail to create resource if 'tree' input is missing" do
93
- expect {
94
- github.git_data.commits.create user, repo, inputs.except('tree')
95
- }.to raise_error(Github::Error::RequiredParams)
96
- end
97
-
98
- it "should fail to create resource if 'parents' input is missing" do
99
- expect {
100
- github.git_data.commits.create user, repo, inputs.except('parents')
101
- }.to raise_error(Github::Error::RequiredParams)
102
- end
103
-
104
- it "should create resource successfully" do
105
- github.git_data.commits.create user, repo, inputs
106
- a_post("/repos/#{user}/#{repo}/git/commits").with(inputs).should have_been_made
107
- end
108
-
109
- it "should return the resource" do
110
- commit = github.git_data.commits.create user, repo, inputs
111
- commit.should be_a Hashie::Mash
112
- end
113
-
114
- it "should get the commit information" do
115
- commit = github.git_data.commits.create user, repo, inputs
116
- commit.author.name.should eql "Scott Chacon"
117
- end
118
- end
119
-
120
- context "failed to create resource" do
121
- before do
122
- stub_post("/repos/#{user}/#{repo}/git/commits").with(inputs).
123
- to_return(:body => fixture('git_data/commit.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
124
- end
125
-
126
- it "should faile to retrieve resource" do
127
- expect {
128
- github.git_data.commits.create user, repo, inputs
129
- }.to raise_error(Github::Error::NotFound)
130
- end
131
- end
132
- end # create
133
-
134
9
  end # Github::GitData::Commits
@@ -0,0 +1,67 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::GitData::References, '#create' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:repo) { 'github' }
8
+ let(:request_path) { "/repos/#{user}/#{repo}/git/refs" }
9
+ let(:inputs) {
10
+ {
11
+ "ref" => "refs/heads/master",
12
+ "sha" => "827efc6d56897b048c772eb4087f854f46256132",
13
+ "unrelated" => 'giberrish'
14
+ }
15
+ }
16
+
17
+ before {
18
+ stub_post(request_path).with(inputs.except('unrelated')).
19
+ to_return(:body => body, :status => status,
20
+ :headers => {:content_type => "application/json; charset=utf-8"})
21
+ }
22
+
23
+ after { reset_authentication_for(subject) }
24
+
25
+ context "resouce created" do
26
+ let(:body) { fixture('git_data/reference.json') }
27
+ let(:status) { 201 }
28
+
29
+ it "should fail to create resource if 'ref' input is missing" do
30
+ expect {
31
+ subject.create user, repo, inputs.except('ref')
32
+ }.to raise_error(ArgumentError)
33
+ end
34
+
35
+ it "should fail to create resource if 'sha' input is missing" do
36
+ expect {
37
+ subject.create user, repo, inputs.except('sha')
38
+ }.to raise_error(Github::Error::RequiredParams)
39
+ end
40
+
41
+ it "should fail to create resource if 'ref' is wrong" do
42
+ expect {
43
+ subject.create user, repo, :ref => '/heads/master', :sha => '13t2a1r3'
44
+ }.to raise_error(ArgumentError)
45
+ end
46
+
47
+ it "should create resource successfully" do
48
+ subject.create user, repo, inputs
49
+ a_post(request_path).with(inputs).should have_been_made
50
+ end
51
+
52
+ it "should return the resource" do
53
+ reference = subject.create user, repo, inputs
54
+ reference.first.should be_a Hashie::Mash
55
+ end
56
+
57
+ it "should get the reference information" do
58
+ reference = subject.create user, repo, inputs
59
+ reference.first.ref.should eql 'refs/heads/sc/featureA'
60
+ end
61
+ end
62
+
63
+ it_should_behave_like 'request failure' do
64
+ let(:requestable) { subject.create user, repo, inputs }
65
+ end
66
+
67
+ end # create
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::GitData::References, '#delete' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:repo) { 'github' }
8
+ let(:ref) { "heads/master" }
9
+ let(:request_path) { "/repos/#{user}/#{repo}/git/refs/#{ref}" }
10
+
11
+ before {
12
+ stub_delete(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 "resouce delete" do
19
+ let(:body) { '' }
20
+ let(:status) { 204 }
21
+
22
+ it { should respond_to :remove }
23
+
24
+ it "should fail to delete resource if 'ref' input is missing" do
25
+ expect { subject.delete user, repo, nil }.to raise_error(ArgumentError)
26
+ end
27
+
28
+ it "should delete resource successfully" do
29
+ subject.delete user, repo, ref
30
+ a_delete(request_path).should have_been_made
31
+ end
32
+ end
33
+
34
+ it_should_behave_like 'request failure' do
35
+ let(:requestable) { subject.delete user, repo, ref }
36
+ end
37
+
38
+ end # delete