github_api 0.4.6 → 0.4.7

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 (97) hide show
  1. data/features/cassettes/errors/repos/create.yml +33 -23
  2. data/features/cassettes/gists/comments/all.yml +116 -106
  3. data/features/cassettes/gists/comments/first.yml +41 -31
  4. data/features/cassettes/gists/gist.yml +61 -50
  5. data/features/cassettes/gists/gists/public_all.yml +31 -58
  6. data/features/cassettes/gists/gists/user_all.yml +44 -34
  7. data/features/cassettes/pagination/repos.yml +161 -287
  8. data/features/cassettes/pagination/repos/commits.yml +174 -299
  9. data/features/cassettes/pagination/repos/commits/next.yml +166 -161
  10. data/features/cassettes/pagination/repos/commits/sha.yml +127 -121
  11. data/features/cassettes/pagination/repos/commits/sha/next.yml +130 -250
  12. data/features/cassettes/pagination/repos/diff.yml +126 -154
  13. data/features/cassettes/pagination/repos/diff/next.yml +123 -246
  14. data/features/cassettes/pagination/repos/next.yml +162 -157
  15. data/features/cassettes/pagination/repos/per_page/each_page.yml +370 -352
  16. data/features/cassettes/pagination/repos/per_page/first.yml +127 -121
  17. data/features/cassettes/repos/branches.yml +38 -65
  18. data/features/cassettes/repos/tags.yml +127 -175
  19. data/features/support/vcr.rb +2 -2
  20. data/lib/github_api/authorization.rb +3 -3
  21. data/lib/github_api/error.rb +3 -0
  22. data/lib/github_api/error/client_error.rb +20 -0
  23. data/lib/github_api/error/invalid_options.rb +18 -0
  24. data/lib/github_api/error/required_params.rb +18 -0
  25. data/lib/github_api/error/service_error.rb +1 -1
  26. data/lib/github_api/error/validations.rb +18 -0
  27. data/lib/github_api/gists.rb +1 -5
  28. data/lib/github_api/gists/comments.rb +2 -8
  29. data/lib/github_api/git_data/blobs.rb +1 -2
  30. data/lib/github_api/git_data/commits.rb +1 -2
  31. data/lib/github_api/git_data/references.rb +2 -4
  32. data/lib/github_api/git_data/trees.rb +1 -1
  33. data/lib/github_api/issues.rb +1 -2
  34. data/lib/github_api/issues/comments.rb +2 -2
  35. data/lib/github_api/issues/labels.rb +2 -4
  36. data/lib/github_api/issues/milestones.rb +2 -4
  37. data/lib/github_api/orgs/teams.rb +3 -4
  38. data/lib/github_api/repos.rb +9 -3
  39. data/lib/github_api/repos/commits.rb +2 -2
  40. data/lib/github_api/repos/downloads.rb +1 -2
  41. data/lib/github_api/repos/hooks.rb +2 -8
  42. data/lib/github_api/repos/keys.rb +2 -3
  43. data/lib/github_api/validation.rb +5 -1
  44. data/lib/github_api/version.rb +1 -1
  45. data/spec/github/api_factory_spec.rb +2 -1
  46. data/spec/github/api_spec.rb +4 -2
  47. data/spec/github/authorization_spec.rb +19 -28
  48. data/spec/github/authorizations_spec.rb +2 -1
  49. data/spec/github/client_spec.rb +4 -1
  50. data/spec/github/deprecation_spec.rb +2 -1
  51. data/spec/github/error/client_error_spec.rb +28 -0
  52. data/spec/github/error/invalid_options_spec.rb +21 -0
  53. data/spec/github/error/required_params_spec.rb +21 -0
  54. data/spec/github/events_spec.rb +4 -4
  55. data/spec/github/filter_spec.rb +2 -2
  56. data/spec/github/gists/comments_spec.rb +8 -4
  57. data/spec/github/gists_spec.rb +19 -14
  58. data/spec/github/git_data/blobs_spec.rb +10 -4
  59. data/spec/github/git_data/commits_spec.rb +13 -6
  60. data/spec/github/git_data/references_spec.rb +13 -8
  61. data/spec/github/git_data/tags_spec.rb +8 -3
  62. data/spec/github/git_data/trees_spec.rb +9 -3
  63. data/spec/github/issues/comments_spec.rb +10 -3
  64. data/spec/github/issues/events_spec.rb +8 -3
  65. data/spec/github/issues/labels_spec.rb +13 -7
  66. data/spec/github/issues/milestones_spec.rb +10 -3
  67. data/spec/github/issues_spec.rb +3 -3
  68. data/spec/github/mime_type_spec.rb +64 -64
  69. data/spec/github/orgs/members_spec.rb +2 -11
  70. data/spec/github/orgs/teams_spec.rb +9 -9
  71. data/spec/github/orgs_spec.rb +22 -8
  72. data/spec/github/page_iterator_spec.rb +2 -1
  73. data/spec/github/page_links_spec.rb +2 -1
  74. data/spec/github/paged_request_spec.rb +2 -1
  75. data/spec/github/pull_requests/comments_spec.rb +9 -3
  76. data/spec/github/pull_requests_spec.rb +6 -2
  77. data/spec/github/repos/collaborators_spec.rb +12 -7
  78. data/spec/github/repos/commits_spec.rb +20 -14
  79. data/spec/github/repos/downloads_spec.rb +19 -8
  80. data/spec/github/repos/forks_spec.rb +6 -3
  81. data/spec/github/repos/hooks_spec.rb +14 -8
  82. data/spec/github/repos/keys_spec.rb +8 -6
  83. data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -11
  84. data/spec/github/repos/watching_spec.rb +15 -38
  85. data/spec/github/repos_spec.rb +35 -39
  86. data/spec/github/request_spec.rb +4 -0
  87. data/spec/github/response/helpers_spec.rb +0 -2
  88. data/spec/github/result_spec.rb +2 -3
  89. data/spec/github/users/followers_spec.rb +6 -8
  90. data/spec/github/users_spec.rb +123 -123
  91. data/spec/github/validation_spec.rb +8 -7
  92. data/spec/github_spec.rb +6 -7
  93. data/spec/spec_helper.rb +2 -2
  94. metadata +36 -21
  95. data/features/cassettes/gists/star.yml +0 -34
  96. data/features/cassettes/pagination/repos/per_page/1.yml +0 -134
  97. data/features/cassettes/repos/teams.yml +0 -38
@@ -1,9 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Github::Repos::Forks, :type => :base do
3
+ describe Github::Repos::Forks do
4
+ let(:github) { Github.new }
5
+ let(:user) { 'peter-murach' }
6
+ let(:repo) { 'github' }
4
7
 
5
- describe "forks" do
8
+ after { github.user, github.repo, github.oauth_token = nil, nil, nil }
6
9
 
10
+ describe "forks" do
7
11
  it { github.repos.should respond_to :forks }
8
12
  it { github.repos.should respond_to :repo_forks }
9
13
  it { github.repos.should respond_to :repository_forks }
@@ -15,7 +19,6 @@ describe Github::Repos::Forks, :type => :base do
15
19
  end
16
20
 
17
21
  it "should fail to get resource without username" do
18
- github.user, github.repo = nil, nil
19
22
  expect { github.repos.forks }.to raise_error(ArgumentError)
20
23
  end
21
24
 
@@ -1,6 +1,13 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
- describe Github::Repos::Hooks, :type => :base do
5
+ describe Github::Repos::Hooks do
6
+ let(:github) { Github.new }
7
+ let(:user) { 'peter-murach' }
8
+ let(:repo) { 'github' }
9
+
10
+ after { github.user, github.repo, github.oauth_token = nil, nil, nil }
4
11
 
5
12
  it { described_class::VALID_HOOK_PARAM_NAMES.should_not be_nil }
6
13
  it { described_class::VALID_HOOK_PARAM_VALUES.should_not be_nil }
@@ -143,13 +150,13 @@ describe Github::Repos::Hooks, :type => :base do
143
150
  it "should fail to create resource if 'name' input is missing" do
144
151
  expect {
145
152
  github.repos.create_hook user, repo, inputs.except(:name)
146
- }.to raise_error(ArgumentError)
153
+ }.to raise_error(Github::Error::RequiredParams)
147
154
  end
148
155
 
149
156
  it "should failt to create resource if 'config' input is missing" do
150
157
  expect {
151
158
  github.repos.create_hook user, repo, inputs.except(:config)
152
- }.to raise_error(ArgumentError)
159
+ }.to raise_error(Github::Error::RequiredParams)
153
160
  end
154
161
 
155
162
  it "should create resource successfully" do
@@ -214,7 +221,7 @@ describe Github::Repos::Hooks, :type => :base do
214
221
  it "should fail to edit resource without 'name' parameter" do
215
222
  expect{
216
223
  github.repos.edit_hook user, repo, inputs.except(:name)
217
- }.to raise_error(ArgumentError)
224
+ }.to raise_error(Github::Error::RequiredParams)
218
225
  end
219
226
 
220
227
  it "should fail to edit resource without 'hook_id'" do
@@ -226,12 +233,13 @@ describe Github::Repos::Hooks, :type => :base do
226
233
  it "should fail to edit resource without 'config' parameter" do
227
234
  expect {
228
235
  github.repos.edit_hook user, repo, hook_id, inputs.except(:config)
229
- }.to raise_error(ArgumentError)
236
+ }.to raise_error(Github::Error::RequiredParams)
230
237
  end
231
238
 
232
239
  it "should edit the resource" do
233
240
  github.repos.edit_hook user, repo, hook_id, inputs
234
- a_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").with(inputs).should have_been_made
241
+ a_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").
242
+ with(inputs).should have_been_made
235
243
  end
236
244
 
237
245
  it "should return resource" do
@@ -243,7 +251,6 @@ describe Github::Repos::Hooks, :type => :base do
243
251
  hook = github.repos.edit_hook user, repo, hook_id, inputs
244
252
  hook.name.should == 'web'
245
253
  end
246
-
247
254
  end
248
255
 
249
256
  context "failed to edit resource" do
@@ -330,7 +337,6 @@ describe Github::Repos::Hooks, :type => :base do
330
337
  before do
331
338
  stub_post("/repos/#{user}/#{repo}/hooks/#{hook_id}/test").
332
339
  to_return(:body => '', :status => 404, :headers => { :content_type => "application/json; charset=utf-8"})
333
-
334
340
  end
335
341
 
336
342
  it "should fail to find resource" do
@@ -1,6 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Github::Repos::Keys, :type => :base do
3
+ describe Github::Repos::Keys do
4
+ let(:github) { Github.new }
5
+ let(:user) { 'peter-murach' }
6
+ let(:repo) { 'github' }
7
+
8
+ after { github.user, github.repo, github.oauth_token = nil, nil, nil }
4
9
 
5
10
  it { described_class::VALID_KEY_PARAM_NAMES.should_not be_nil }
6
11
 
@@ -12,7 +17,6 @@ describe Github::Repos::Keys, :type => :base do
12
17
  end
13
18
 
14
19
  it "should fail to get resource without username" do
15
- github.user, github.repo = nil, nil
16
20
  expect { github.repos.keys }.to raise_error(ArgumentError)
17
21
  end
18
22
 
@@ -45,7 +49,6 @@ describe Github::Repos::Keys, :type => :base do
45
49
  }.to raise_error(Github::Error::NotFound)
46
50
  end
47
51
  end
48
-
49
52
  end
50
53
 
51
54
  describe "get_key" do
@@ -100,13 +103,13 @@ describe Github::Repos::Keys, :type => :base do
100
103
  it "should fail to create resource if 'title' input is missing" do
101
104
  expect {
102
105
  github.repos.create_key(user, repo, :key => 'ssh-rsa AAA...')
103
- }.to raise_error(ArgumentError)
106
+ }.to raise_error(Github::Error::RequiredParams)
104
107
  end
105
108
 
106
109
  it "should fail to create resource if 'key' input is missing" do
107
110
  expect {
108
111
  github.repos.create_key(user, repo, :title => 'octocat@octomac')
109
- }.to raise_error(ArgumentError)
112
+ }.to raise_error(Github::Error::RequiredParams)
110
113
  end
111
114
 
112
115
  it "should create the resource" do
@@ -168,7 +171,6 @@ describe Github::Repos::Keys, :type => :base do
168
171
  }.to raise_error(Github::Error::NotFound)
169
172
  end
170
173
  end
171
-
172
174
  end
173
175
 
174
176
  describe "delete_key" do
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Github::Repos::PubSubHubbub do
4
-
5
4
  let(:github) { Github.new }
6
5
  let(:topic) { "https://github.com/peter-murach/github/events/push"}
7
6
  let(:callback) { "github://campfire?subdomain=github&room=Commits&token=abc123" }
@@ -15,6 +14,8 @@ describe Github::Repos::PubSubHubbub do
15
14
  }
16
15
  }
17
16
 
17
+ after { github.user, github.repo, github.oauth_token = nil, nil, nil }
18
+
18
19
  describe "subscribe" do
19
20
  context "success" do
20
21
  before do
@@ -23,10 +24,6 @@ describe Github::Repos::PubSubHubbub do
23
24
  to_return(:body => '', :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
24
25
  end
25
26
 
26
- after do
27
- github.oauth_token = nil
28
- end
29
-
30
27
  it "should subscribe to hub" do
31
28
  github.repos.subscribe topic, callback
32
29
  a_post("/hub?access_token=#{OAUTH_TOKEN}").with(hub_inputs).should have_been_made
@@ -46,7 +43,7 @@ describe Github::Repos::PubSubHubbub do
46
43
  }.to raise_error(Github::Error::NotFound)
47
44
  end
48
45
  end
49
- end
46
+ end # subscribe
50
47
 
51
48
  describe "unsubscribe" do
52
49
  context "success" do
@@ -56,10 +53,6 @@ describe Github::Repos::PubSubHubbub do
56
53
  to_return(:body => '', :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
57
54
  end
58
55
 
59
- after do
60
- github.oauth_token = nil
61
- end
62
-
63
56
  it "should subscribe to hub" do
64
57
  github.repos.unsubscribe topic, callback
65
58
  a_post("/hub?access_token=#{OAUTH_TOKEN}").with(hub_inputs).should have_been_made
@@ -79,5 +72,5 @@ describe Github::Repos::PubSubHubbub do
79
72
  }.to raise_error(Github::Error::NotFound)
80
73
  end
81
74
  end
82
- end
75
+ end # unsubscribe
83
76
  end # Github::Repos::PubSubHubbub
@@ -2,7 +2,12 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Github::Repos::Watching, :type => :base do
5
+ describe Github::Repos::Watching do
6
+ let(:github) { Github.new }
7
+ let(:user) { 'peter-murach' }
8
+ let(:repo) { 'github' }
9
+
10
+ after { github.user, github.repo, github.oauth_token = nil, nil, nil }
6
11
 
7
12
  describe "watchers" do
8
13
  before do
@@ -12,7 +17,6 @@ describe Github::Repos::Watching, :type => :base do
12
17
  end
13
18
 
14
19
  it "should fail to get resource without username" do
15
- github.user, github.repo = nil, nil
16
20
  expect { github.repos.watchers }.to raise_error(ArgumentError)
17
21
  end
18
22
 
@@ -56,19 +60,14 @@ describe Github::Repos::Watching, :type => :base do
56
60
  end
57
61
  end
58
62
 
59
- describe ":watched:" do
60
-
63
+ describe "#watched" do
61
64
  context "if user unauthenticated" do
62
- before do
63
- github.oauth_token = nil
64
- WebMock.reset!
65
- end
65
+ before { github.oauth_token = nil }
66
66
 
67
67
  it "should fail to get resource without username " do
68
68
  stub_get("/user/watched").
69
69
  to_return(:body => fixture("repos/watched.json"), :status => 401, :headers => {})
70
70
  expect {
71
- github.user = nil
72
71
  github.repos.watched
73
72
  }.to raise_error(Github::Error::Unauthorized)
74
73
  end
@@ -83,15 +82,13 @@ describe Github::Repos::Watching, :type => :base do
83
82
 
84
83
  context "if user authenticated" do
85
84
  before do
86
- github.user = nil
87
85
  github.oauth_token = OAUTH_TOKEN
88
86
  stub_get("/user/watched").
89
87
  with(:query => {:access_token => OAUTH_TOKEN}).
90
88
  to_return(:body => fixture("repos/watched.json"), :status => 200, :headers => {})
91
89
  end
92
- after do
93
- github.oauth_token = nil
94
- end
90
+
91
+ after { github.oauth_token = nil }
95
92
 
96
93
  it "should get the resources" do
97
94
  github.repos.watched
@@ -111,16 +108,12 @@ describe Github::Repos::Watching, :type => :base do
111
108
  watched.first.owner.login.should == 'octocat'
112
109
  end
113
110
  end
114
- end
111
+ end # watched
115
112
 
116
113
  describe "watching?" do
117
-
118
114
  context "with username ane reponame passed" do
119
-
120
115
  context "this repo is being watched by the user"
121
116
  before do
122
- github.oauth_token = nil
123
- github.user = nil
124
117
  stub_get("/user/watched/#{user}/#{repo}").
125
118
  to_return(:body => "", :status => 404, :headers => {:user_agent => github.user_agent})
126
119
  end
@@ -136,7 +129,6 @@ describe Github::Repos::Watching, :type => :base do
136
129
  watching = github.repos.watching? user, repo
137
130
  watching.should be_true
138
131
  end
139
-
140
132
  end
141
133
 
142
134
  context "without username and reponame passed" do
@@ -144,24 +136,19 @@ describe Github::Repos::Watching, :type => :base do
144
136
  expect { github.repos.watching?(nil, nil) }.to raise_error(ArgumentError)
145
137
  end
146
138
  end
147
- end
139
+ end # watching?
148
140
 
149
141
  describe "start_watching" do
150
-
151
142
  context "user authenticated" do
152
-
153
143
  context "with correct information" do
154
144
  before do
155
- github.user, github.repo = nil, nil
156
145
  github.oauth_token = OAUTH_TOKEN
157
146
  stub_put("/user/watched/#{user}/#{repo}").
158
147
  with(:query => {:access_token => OAUTH_TOKEN}).
159
148
  to_return(:body => "", :status => 204, :headers => {})
160
149
  end
161
150
 
162
- after do
163
- github.oauth_token = nil # ensure authentication is reset
164
- end
151
+ after { github.oauth_token = nil }
165
152
 
166
153
  it "should successfully watch a repo" do
167
154
  github.repos.start_watching(user, repo)
@@ -170,10 +157,6 @@ describe Github::Repos::Watching, :type => :base do
170
157
  should have_been_made
171
158
  end
172
159
  end
173
-
174
- context "without correct information" do
175
-
176
- end
177
160
  end
178
161
 
179
162
  context "user unauthenticated" do
@@ -186,12 +169,10 @@ describe Github::Repos::Watching, :type => :base do
186
169
  }.to raise_error(Github::Error::Unauthorized)
187
170
  end
188
171
  end
189
- end
172
+ end # start_watching
190
173
 
191
174
  describe "stop_watching" do
192
-
193
175
  context "user authenticated" do
194
-
195
176
  context "with correct information" do
196
177
  before do
197
178
  github.user, github.repo = nil, nil
@@ -205,10 +186,6 @@ describe Github::Repos::Watching, :type => :base do
205
186
  a_delete("/user/watched/#{user}/#{repo}?access_token=#{OAUTH_TOKEN}").should have_been_made
206
187
  end
207
188
  end
208
-
209
- context "without correct information" do
210
-
211
- end
212
189
  end
213
190
 
214
191
  context "user unauthenticated" do
@@ -221,6 +198,6 @@ describe Github::Repos::Watching, :type => :base do
221
198
  }.to raise_error(Github::Error::Unauthorized)
222
199
  end
223
200
  end
224
- end
201
+ end # stop_watching
225
202
 
226
203
  end # Github::Respos::Watching
@@ -1,25 +1,32 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
- describe Github::Repos, :type => :base do
5
+ describe Github::Repos do
6
+ let(:github) { Github.new }
7
+ let(:user) { 'peter-murach' }
8
+ let(:repo) { 'github' }
9
+
10
+ after { reset_authentication_for github }
4
11
 
5
12
  describe "branches" do
6
13
  context "resource found" do
7
14
  before do
8
15
  stub_get("/repos/#{user}/#{repo}/branches").
9
- to_return(:body => fixture('repos/branches.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
16
+ to_return(:body => fixture('repos/branches.json'),
17
+ :status => 200,
18
+ :headers => {:content_type => "application/json; charset=utf-8"})
10
19
  end
11
20
 
12
21
  it "should raise error when no user/repo parameters" do
13
- github.user, github.repo = nil, nil
14
22
  expect {
15
- github.repos.branches
23
+ github.repos.branches nil, repo
16
24
  }.to raise_error(ArgumentError, /\[user\] parameter cannot be nil/)
17
25
  end
18
26
 
19
27
  it "should raise error when no repository" do
20
- github.user, github.repo = nil, nil
21
28
  expect {
22
- github.repos.branches user
29
+ github.repos.branches user, nil
23
30
  }.to raise_error(ArgumentError, /\[repo\] parameter cannot be nil/)
24
31
  end
25
32
 
@@ -40,8 +47,9 @@ describe Github::Repos, :type => :base do
40
47
  end
41
48
 
42
49
  it "should yield to a block" do
43
- github.repos.should_receive(:branches).with(user, repo).and_yield('web')
44
- github.repos.branches(user, repo) { |param| 'web'}
50
+ block = lambda { |el| repo }
51
+ github.repos.should_receive(:branches).with(user, repo).and_yield repo
52
+ github.repos.branches(user, repo, &block)
45
53
  end
46
54
  end
47
55
 
@@ -68,14 +76,12 @@ describe Github::Repos, :type => :base do
68
76
  end
69
77
 
70
78
  it "should raise error when no user/repo parameters" do
71
- github.user, github.repo = nil, nil
72
79
  expect {
73
80
  github.repos.contributors
74
81
  }.to raise_error(ArgumentError, /\[user\] parameter cannot be nil/)
75
82
  end
76
83
 
77
84
  it "should raise error when no repository" do
78
- github.user, github.repo = nil, nil
79
85
  expect {
80
86
  github.repos.contributors user
81
87
  }.to raise_error(ArgumentError, /\[repo\] parameter cannot be nil/)
@@ -123,20 +129,17 @@ describe Github::Repos, :type => :base do
123
129
 
124
130
  context "resource created successfully for the authenticated user" do
125
131
  before do
126
- github.user = nil
127
132
  github.oauth_token = OAUTH_TOKEN
128
133
  stub_post("/user/repos?access_token=#{OAUTH_TOKEN}").with(inputs).
129
134
  to_return(:body => fixture('repos/repo.json'), :status => 201,:headers => {:content_type => "application/json; charset=utf-8"} )
130
135
  end
131
136
 
132
- after do
133
- github.user, github.oauth_token = nil, nil
134
- end
137
+ after { github.oauth_token = nil }
135
138
 
136
139
  it "should faile to create resource if 'name' inputs is missing" do
137
140
  expect {
138
141
  github.repos.create_repo inputs.except(:name)
139
- }.to raise_error(ArgumentError)
142
+ }.to raise_error(Github::Error::RequiredParams)
140
143
  end
141
144
 
142
145
  it "should create resource" do
@@ -195,7 +198,14 @@ describe Github::Repos, :type => :base do
195
198
  end
196
199
 
197
200
  describe "edit_repo" do
198
- let(:inputs) { {:name => 'web', :description => "This is your first repo", :homepage => "https://github.com", :public => true, :has_issues => true, :has_wiki => true}}
201
+ let(:inputs) do
202
+ { :name => 'web',
203
+ :description => "This is your first repo",
204
+ :homepage => "https://github.com",
205
+ :public => true,
206
+ :has_issues => true,
207
+ :has_wiki => true }
208
+ end
199
209
 
200
210
  context "resource edited successfully" do
201
211
  before do
@@ -204,14 +214,14 @@ describe Github::Repos, :type => :base do
204
214
  end
205
215
 
206
216
  it "should fail to edit without 'user/repo' parameters" do
207
- github.user, github.repo = nil, nil
217
+ # github.user, github.repo = nil, nil
208
218
  expect { github.repos.edit_repo }.to raise_error(ArgumentError)
209
219
  end
210
220
 
211
221
  it "should fail to edit resource without 'name' parameter" do
212
222
  expect{
213
223
  github.repos.edit_hook user, repo, inputs.except(:name)
214
- }.to raise_error(ArgumentError)
224
+ }.to raise_error(Github::Error::RequiredParams)
215
225
  end
216
226
 
217
227
  it "should edit the resource" do
@@ -228,14 +238,12 @@ describe Github::Repos, :type => :base do
228
238
  repository = github.repos.edit_repo user, repo, inputs
229
239
  repository.name.should == 'Hello-World'
230
240
  end
231
-
232
241
  end
233
242
 
234
243
  context "failed to edit resource" do
235
244
  before do
236
245
  stub_patch("/repos/#{user}/#{repo}").with(inputs).
237
246
  to_return(:body => fixture("repos/repo.json"), :status => 404, :headers => { :content_type => "application/json; charset=utf-8"})
238
-
239
247
  end
240
248
 
241
249
  it "should fail to find resource" do
@@ -244,7 +252,6 @@ describe Github::Repos, :type => :base do
244
252
  }.to raise_error(Github::Error::NotFound)
245
253
  end
246
254
  end
247
-
248
255
  end # edit_repo
249
256
 
250
257
  describe "get_repo" do
@@ -295,7 +302,6 @@ describe Github::Repos, :type => :base do
295
302
  github.repos.get_repo user, repo
296
303
  }.to raise_error(Github::Error::NotFound)
297
304
  end
298
-
299
305
  end
300
306
  end # get_repo
301
307
 
@@ -307,14 +313,14 @@ describe Github::Repos, :type => :base do
307
313
  end
308
314
 
309
315
  it "should raise error when no user/repo parameters" do
310
- github.user, github.repo = nil, nil
316
+ # github.user, github.repo = nil, nil
311
317
  expect {
312
318
  github.repos.languages
313
319
  }.to raise_error(ArgumentError, /\[user\] parameter cannot be nil/)
314
320
  end
315
321
 
316
322
  it "should raise error when no repository" do
317
- github.user, github.repo = nil, nil
323
+ # github.user, github.repo = nil, nil
318
324
  expect {
319
325
  github.repos.languages user
320
326
  }.to raise_error(ArgumentError, /\[repo\] parameter cannot be nil/)
@@ -346,7 +352,6 @@ describe Github::Repos, :type => :base do
346
352
  before do
347
353
  stub_get("/repos/#{user}/#{repo}/languages").
348
354
  to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
349
-
350
355
  end
351
356
 
352
357
  it "should fail to get resource" do
@@ -360,7 +365,7 @@ describe Github::Repos, :type => :base do
360
365
  describe "repos" do
361
366
  context "resource found for authenticated user" do
362
367
  before do
363
- github.user = nil
368
+ # github.user = nil
364
369
  github.oauth_token = OAUTH_TOKEN
365
370
  stub_get("/user/repos?access_token=#{OAUTH_TOKEN}").
366
371
  to_return(:body => fixture('repos/repos.json'), :status => 200,:headers => {:content_type => "application/json; charset=utf-8"} )
@@ -368,7 +373,7 @@ describe Github::Repos, :type => :base do
368
373
 
369
374
  after do
370
375
  github.oauth_token = nil
371
- github.user, github.repo = nil, nil
376
+ # github.user, github.repo = nil, nil
372
377
  end
373
378
 
374
379
  it "fails if user is unauthenticated" do
@@ -404,7 +409,7 @@ describe Github::Repos, :type => :base do
404
409
  let(:org) { '37signals' }
405
410
 
406
411
  before do
407
- github.user = nil
412
+ # github.user = nil
408
413
  github.oauth_token = nil
409
414
  stub_get("/orgs/#{org}/repos").
410
415
  to_return(:body => fixture('repos/repos.json'), :status => 200,:headers => {:content_type => "application/json; charset=utf-8"} )
@@ -431,16 +436,13 @@ describe Github::Repos, :type => :base do
431
436
 
432
437
  context "rosource not found for authenticated user" do
433
438
  before do
434
- github.user = nil
439
+ # github.user = nil
435
440
  github.oauth_token = OAUTH_TOKEN
436
441
  stub_get("/user/repos?access_token=#{OAUTH_TOKEN}").
437
442
  to_return(:body => '', :status => 404,:headers => {:content_type => "application/json; charset=utf-8"} )
438
443
  end
439
444
 
440
- after do
441
- github.oauth_token = nil
442
- github.user, github.repo = nil, nil
443
- end
445
+ after { github.oauth_token = nil }
444
446
 
445
447
  it "fail to find resources" do
446
448
  expect { github.repos.repos }.to raise_error(Github::Error::NotFound)
@@ -456,14 +458,12 @@ describe Github::Repos, :type => :base do
456
458
  end
457
459
 
458
460
  it "should raise error when no user/repo parameters" do
459
- github.user, github.repo = nil, nil
460
461
  expect {
461
462
  github.repos.tags
462
463
  }.to raise_error(ArgumentError, /\[user\] parameter cannot be nil/)
463
464
  end
464
465
 
465
466
  it "should raise error when no repository" do
466
- github.user, github.repo = nil, nil
467
467
  expect {
468
468
  github.repos.tags user
469
469
  }.to raise_error(ArgumentError, /\[repo\] parameter cannot be nil/)
@@ -495,7 +495,6 @@ describe Github::Repos, :type => :base do
495
495
  before do
496
496
  stub_get("/repos/#{user}/#{repo}/tags").
497
497
  to_return(:body => fixture('repos/branches.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
498
-
499
498
  end
500
499
 
501
500
  it "should fail to get resource" do
@@ -514,14 +513,12 @@ describe Github::Repos, :type => :base do
514
513
  end
515
514
 
516
515
  it "should raise error when no user/repo parameters" do
517
- github.user, github.repo = nil, nil
518
516
  expect {
519
517
  github.repos.teams
520
518
  }.to raise_error(ArgumentError, /\[user\] parameter cannot be nil/)
521
519
  end
522
520
 
523
521
  it "should raise error when no repository" do
524
- github.user, github.repo = nil, nil
525
522
  expect {
526
523
  github.repos.teams user
527
524
  }.to raise_error(ArgumentError, /\[repo\] parameter cannot be nil/)
@@ -553,7 +550,6 @@ describe Github::Repos, :type => :base do
553
550
  before do
554
551
  stub_get("/repos/#{user}/#{repo}/teams").
555
552
  to_return(:body => fixture('repos/teams.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
556
-
557
553
  end
558
554
 
559
555
  it "should fail to get resource" do