gems 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/.travis.yml +6 -4
- data/README.md +97 -68
- data/Rakefile +0 -2
- data/gems.gemspec +6 -6
- data/lib/gems/client.rb +103 -87
- data/lib/gems/version.rb +1 -1
- data/spec/fixtures/most_downloaded_today.yaml +1053 -0
- data/spec/gems/client_spec.rb +171 -178
- data/spec/helper.rb +6 -2
- metadata +61 -29
data/spec/gems/client_spec.rb
CHANGED
@@ -5,12 +5,11 @@ describe Gems::Client do
|
|
5
5
|
Gems.reset
|
6
6
|
end
|
7
7
|
|
8
|
-
describe "
|
8
|
+
describe "#info" do
|
9
9
|
before do
|
10
10
|
stub_get("/api/v1/gems/rails.yaml").
|
11
11
|
to_return(:body => fixture("rails.yaml"))
|
12
12
|
end
|
13
|
-
|
14
13
|
it "should return some basic information about the given gem" do
|
15
14
|
info = Gems.info 'rails'
|
16
15
|
a_get("/api/v1/gems/rails.yaml").
|
@@ -19,13 +18,12 @@ describe Gems::Client do
|
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
|
-
describe "
|
21
|
+
describe "#search" do
|
23
22
|
before do
|
24
23
|
stub_get("/api/v1/search.yaml").
|
25
24
|
with(:query => {"query" => "cucumber"}).
|
26
25
|
to_return(:body => fixture("search.yaml"))
|
27
26
|
end
|
28
|
-
|
29
27
|
it "should return an array of active gems that match the query" do
|
30
28
|
search = Gems.search 'cucumber'
|
31
29
|
a_get("/api/v1/search.yaml").
|
@@ -35,12 +33,117 @@ describe Gems::Client do
|
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
38
|
-
describe "
|
36
|
+
describe "#gems" do
|
37
|
+
context "with no user handle specified" do
|
38
|
+
before do
|
39
|
+
stub_get("/api/v1/gems.yaml").
|
40
|
+
to_return(:body => fixture("gems.yaml"))
|
41
|
+
end
|
42
|
+
it "should list all gems that you own" do
|
43
|
+
gems = Gems.gems
|
44
|
+
a_get("/api/v1/gems.yaml").
|
45
|
+
should have_been_made
|
46
|
+
gems.first['name'].should == "exchb"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
context "with a user handle specified" do
|
50
|
+
before do
|
51
|
+
stub_get("/api/v1/owners/sferik/gems.yaml").
|
52
|
+
to_return(:body => fixture("gems.yaml"))
|
53
|
+
end
|
54
|
+
it "should list all gems that the specified user owns" do
|
55
|
+
gems = Gems.gems("sferik")
|
56
|
+
a_get("/api/v1/owners/sferik/gems.yaml").
|
57
|
+
should have_been_made
|
58
|
+
gems.first['name'].should == "exchb"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#push" do
|
64
|
+
before do
|
65
|
+
stub_post("/api/v1/gems").
|
66
|
+
to_return(:body => fixture("push"))
|
67
|
+
end
|
68
|
+
it "should submit a gem to RubyGems.org" do
|
69
|
+
push = Gems.push(File.new(File.expand_path("../../fixtures/gems-0.0.8.gem", __FILE__), "rb"))
|
70
|
+
a_post("/api/v1/gems").
|
71
|
+
should have_been_made
|
72
|
+
push.should == "Successfully registered gem: gems (0.0.8)"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#yank" do
|
77
|
+
context "with no version specified" do
|
78
|
+
before do
|
79
|
+
stub_get("/api/v1/gems/gems.yaml").
|
80
|
+
to_return(:body => fixture("rails.yaml"))
|
81
|
+
stub_delete("/api/v1/gems/yank").
|
82
|
+
with(:query => {:gem_name => "gems", :version => "3.0.9"}).
|
83
|
+
to_return(:body => fixture("yank"))
|
84
|
+
end
|
85
|
+
it "should remove a gem from RubyGems.org's index" do
|
86
|
+
yank = Gems.yank("gems")
|
87
|
+
a_delete("/api/v1/gems/yank").
|
88
|
+
with(:query => {:gem_name => "gems", :version => "3.0.9"}).
|
89
|
+
should have_been_made
|
90
|
+
yank.should == "Successfully yanked gem: gems (0.0.8)"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
context "with a version specified" do
|
94
|
+
before do
|
95
|
+
stub_delete("/api/v1/gems/yank").
|
96
|
+
with(:query => {:gem_name => "gems", :version => "0.0.8"}).
|
97
|
+
to_return(:body => fixture("yank"))
|
98
|
+
end
|
99
|
+
it "should remove a gem from RubyGems.org's index" do
|
100
|
+
yank = Gems.yank("gems", "0.0.8")
|
101
|
+
a_delete("/api/v1/gems/yank").
|
102
|
+
with(:query => {:gem_name => "gems", :version => "0.0.8"}).
|
103
|
+
should have_been_made
|
104
|
+
yank.should == "Successfully yanked gem: gems (0.0.8)"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "#unyank" do
|
110
|
+
context "with no version specified" do
|
111
|
+
before do
|
112
|
+
stub_get("/api/v1/gems/gems.yaml").
|
113
|
+
to_return(:body => fixture("rails.yaml"))
|
114
|
+
stub_put("/api/v1/gems/unyank").
|
115
|
+
with(:body => {:gem_name => "gems", :version => "3.0.9"}).
|
116
|
+
to_return(:body => fixture("unyank"))
|
117
|
+
end
|
118
|
+
it "should update a previously yanked gem back into RubyGems.org's index" do
|
119
|
+
unyank = Gems.unyank("gems")
|
120
|
+
a_put("/api/v1/gems/unyank").
|
121
|
+
with(:body => {:gem_name => "gems", :version => "3.0.9"}).
|
122
|
+
should have_been_made
|
123
|
+
unyank.should == "Successfully unyanked gem: gems (0.0.8)"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
context "with a version specified" do
|
127
|
+
before do
|
128
|
+
stub_put("/api/v1/gems/unyank").
|
129
|
+
with(:body => {:gem_name => "gems", :version => "0.0.8"}).
|
130
|
+
to_return(:body => fixture("unyank"))
|
131
|
+
end
|
132
|
+
it "should update a previously yanked gem back into RubyGems.org's index" do
|
133
|
+
unyank = Gems.unyank("gems", "0.0.8")
|
134
|
+
a_put("/api/v1/gems/unyank").
|
135
|
+
with(:body => {:gem_name => "gems", :version => "0.0.8"}).
|
136
|
+
should have_been_made
|
137
|
+
unyank.should == "Successfully unyanked gem: gems (0.0.8)"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "#versions" do
|
39
143
|
before do
|
40
144
|
stub_get("/api/v1/versions/script_helpers.yaml").
|
41
145
|
to_return(:body => fixture("script_helpers.yaml"))
|
42
146
|
end
|
43
|
-
|
44
147
|
it "should return an array of gem version details" do
|
45
148
|
versions = Gems.versions 'script_helpers'
|
46
149
|
a_get("/api/v1/versions/script_helpers.yaml").
|
@@ -49,13 +152,12 @@ describe Gems::Client do
|
|
49
152
|
end
|
50
153
|
end
|
51
154
|
|
52
|
-
describe "
|
155
|
+
describe "#total_downloads" do
|
53
156
|
context "with no version or gem name specified" do
|
54
157
|
before do
|
55
158
|
stub_get("/api/v1/downloads.yaml").
|
56
159
|
to_return(:body => fixture("total_downloads.yaml"))
|
57
160
|
end
|
58
|
-
|
59
161
|
it "should return the total number of downloads on RubyGems.org" do
|
60
162
|
downloads = Gems.total_downloads
|
61
163
|
a_get("/api/v1/downloads.yaml").
|
@@ -63,7 +165,6 @@ describe Gems::Client do
|
|
63
165
|
downloads[:total].should == 244368950
|
64
166
|
end
|
65
167
|
end
|
66
|
-
|
67
168
|
context "with no version specified" do
|
68
169
|
before do
|
69
170
|
stub_get("/api/v1/gems/rails_admin.yaml").
|
@@ -71,7 +172,6 @@ describe Gems::Client do
|
|
71
172
|
stub_get("/api/v1/downloads/rails_admin-3.0.9.yaml").
|
72
173
|
to_return(:body => fixture("rails_admin-0.0.0.yaml"))
|
73
174
|
end
|
74
|
-
|
75
175
|
it "should the total number of downloads for the specified gem" do
|
76
176
|
downloads = Gems.total_downloads('rails_admin')
|
77
177
|
a_get("/api/v1/gems/rails_admin.yaml").
|
@@ -82,13 +182,11 @@ describe Gems::Client do
|
|
82
182
|
downloads[:total_downloads].should == 3142
|
83
183
|
end
|
84
184
|
end
|
85
|
-
|
86
185
|
context "with a version specified" do
|
87
186
|
before do
|
88
187
|
stub_get("/api/v1/downloads/rails_admin-0.0.0.yaml").
|
89
188
|
to_return(:body => fixture("rails_admin-0.0.0.yaml"))
|
90
189
|
end
|
91
|
-
|
92
190
|
it "should the total number of downloads for the specified gem" do
|
93
191
|
downloads = Gems.total_downloads('rails_admin', '0.0.0')
|
94
192
|
a_get("/api/v1/downloads/rails_admin-0.0.0.yaml").
|
@@ -97,28 +195,41 @@ describe Gems::Client do
|
|
97
195
|
downloads[:total_downloads].should == 3142
|
98
196
|
end
|
99
197
|
end
|
198
|
+
end
|
100
199
|
|
200
|
+
describe "#most_downloaded_today" do
|
201
|
+
context "with nothing specified" do
|
202
|
+
before do
|
203
|
+
stub_get("/api/v1/downloads/top.yaml").
|
204
|
+
to_return(:body => fixture("most_downloaded_today.yaml"))
|
205
|
+
end
|
206
|
+
it "should return the most downloaded versions today" do
|
207
|
+
most_downloaded = Gems.most_downloaded_today
|
208
|
+
a_get("/api/v1/downloads/top.yaml").
|
209
|
+
should have_been_made
|
210
|
+
most_downloaded.first.first['full_name'].should == "rake-0.9.2.2"
|
211
|
+
most_downloaded.first.last.should == 9801
|
212
|
+
end
|
213
|
+
end
|
101
214
|
end
|
102
215
|
|
103
|
-
describe "
|
216
|
+
describe "#most_downloaded" do
|
104
217
|
context "with nothing specified" do
|
105
218
|
before do
|
106
219
|
stub_get("/api/v1/downloads/all.yaml").
|
107
|
-
|
220
|
+
to_return(:body => fixture("most_downloaded.yaml"))
|
108
221
|
end
|
109
|
-
|
110
222
|
it "should return the most downloaded versions" do
|
111
223
|
most_downloaded = Gems.most_downloaded
|
112
224
|
a_get("/api/v1/downloads/all.yaml").
|
113
225
|
should have_been_made
|
114
|
-
most_downloaded
|
115
|
-
most_downloaded
|
226
|
+
most_downloaded.first.first['full_name'].should == "abstract-1.0.0"
|
227
|
+
most_downloaded.first.last.should == 1
|
116
228
|
end
|
117
229
|
end
|
118
230
|
end
|
119
231
|
|
120
|
-
describe "
|
121
|
-
|
232
|
+
describe "#downloads" do
|
122
233
|
context "with no dates or version specified" do
|
123
234
|
before do
|
124
235
|
stub_get("/api/v1/gems/coulda.yaml").
|
@@ -126,7 +237,6 @@ describe Gems::Client do
|
|
126
237
|
stub_get("/api/v1/versions/coulda-3.0.9/downloads.yaml").
|
127
238
|
to_return(:body => fixture("downloads.yaml"))
|
128
239
|
end
|
129
|
-
|
130
240
|
it "should return the number of downloads by day for a particular gem version" do
|
131
241
|
downloads = Gems.downloads 'coulda'
|
132
242
|
a_get("/api/v1/gems/coulda.yaml").
|
@@ -136,13 +246,11 @@ describe Gems::Client do
|
|
136
246
|
downloads['2011-06-22'].should == 8
|
137
247
|
end
|
138
248
|
end
|
139
|
-
|
140
249
|
context "with no dates specified" do
|
141
250
|
before do
|
142
251
|
stub_get("/api/v1/versions/coulda-0.6.3/downloads.yaml").
|
143
252
|
to_return(:body => fixture("downloads.yaml"))
|
144
253
|
end
|
145
|
-
|
146
254
|
it "should return the number of downloads by day for a particular gem version" do
|
147
255
|
downloads = Gems.downloads 'coulda', '0.6.3'
|
148
256
|
a_get("/api/v1/versions/coulda-0.6.3/downloads.yaml").
|
@@ -150,14 +258,12 @@ describe Gems::Client do
|
|
150
258
|
downloads['2011-06-22'].should == 8
|
151
259
|
end
|
152
260
|
end
|
153
|
-
|
154
261
|
context "with from date specified" do
|
155
262
|
before do
|
156
263
|
stub_get("/api/v1/versions/coulda-0.6.3/downloads/search.yaml").
|
157
264
|
with(:query => {"from" => "2011-01-01", "to" => Date.today.to_s}).
|
158
265
|
to_return(:body => fixture("downloads.yaml"))
|
159
266
|
end
|
160
|
-
|
161
267
|
it "should return the number of downloads by day for a particular gem version" do
|
162
268
|
downloads = Gems.downloads 'coulda', '0.6.3', Date.parse('2011-01-01')
|
163
269
|
a_get("/api/v1/versions/coulda-0.6.3/downloads/search.yaml").
|
@@ -166,14 +272,12 @@ describe Gems::Client do
|
|
166
272
|
downloads['2011-06-22'].should == 8
|
167
273
|
end
|
168
274
|
end
|
169
|
-
|
170
275
|
context "with from and to dates specified" do
|
171
276
|
before do
|
172
277
|
stub_get("/api/v1/versions/coulda-0.6.3/downloads/search.yaml").
|
173
278
|
with(:query => {"from" => "2011-01-01", "to" => "2011-06-28"}).
|
174
279
|
to_return(:body => fixture("downloads.yaml"))
|
175
280
|
end
|
176
|
-
|
177
281
|
it "should return the number of downloads by day for a particular gem version" do
|
178
282
|
downloads = Gems.downloads 'coulda', '0.6.3', Date.parse('2011-01-01'), Date.parse('2011-06-28')
|
179
283
|
a_get("/api/v1/versions/coulda-0.6.3/downloads/search.yaml").
|
@@ -184,60 +288,11 @@ describe Gems::Client do
|
|
184
288
|
end
|
185
289
|
end
|
186
290
|
|
187
|
-
describe "
|
188
|
-
before do
|
189
|
-
stub_get("/api/v1/dependencies").
|
190
|
-
with(:query => {"gems" => "rails,thor"}).
|
191
|
-
to_return(:body => fixture("dependencies"))
|
192
|
-
end
|
193
|
-
|
194
|
-
it "should return an array of hashes for all versions of given gems" do
|
195
|
-
dependencies = Gems.dependencies 'rails', 'thor'
|
196
|
-
a_get("/api/v1/dependencies").
|
197
|
-
with(:query => {"gems" => "rails,thor"}).
|
198
|
-
should have_been_made
|
199
|
-
dependencies.first[:number].should == "3.0.9"
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
describe ".api_key" do
|
204
|
-
before do
|
205
|
-
Gems.configure do |config|
|
206
|
-
config.username = 'nick@gemcutter.org'
|
207
|
-
config.password = 'schwwwwing'
|
208
|
-
end
|
209
|
-
stub_get("https://nick%40gemcutter.org:schwwwwing@rubygems.org/api/v1/api_key").
|
210
|
-
to_return(:body => fixture("api_key"))
|
211
|
-
end
|
212
|
-
|
213
|
-
it "should retrieve an API key" do
|
214
|
-
api_key = Gems.api_key
|
215
|
-
a_get("https://nick%40gemcutter.org:schwwwwing@rubygems.org/api/v1/api_key").
|
216
|
-
should have_been_made
|
217
|
-
api_key.should == "701243f217cdf23b1370c7b66b65ca97"
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
describe ".gems" do
|
222
|
-
before do
|
223
|
-
stub_get("/api/v1/gems.yaml").
|
224
|
-
to_return(:body => fixture("gems.yaml"))
|
225
|
-
end
|
226
|
-
|
227
|
-
it "should list all gems that you own" do
|
228
|
-
gems = Gems.gems
|
229
|
-
a_get("/api/v1/gems.yaml").
|
230
|
-
should have_been_made
|
231
|
-
gems.first['name'].should == "exchb"
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
describe ".owners" do
|
291
|
+
describe "#owners" do
|
236
292
|
before do
|
237
293
|
stub_get("/api/v1/gems/gems/owners.yaml").
|
238
294
|
to_return(:body => fixture("owners.yaml"))
|
239
295
|
end
|
240
|
-
|
241
296
|
it "should list all owners of a gem" do
|
242
297
|
owners = Gems.owners("gems")
|
243
298
|
a_get("/api/v1/gems/gems/owners.yaml").
|
@@ -246,13 +301,12 @@ describe Gems::Client do
|
|
246
301
|
end
|
247
302
|
end
|
248
303
|
|
249
|
-
describe "
|
304
|
+
describe "#add_owner" do
|
250
305
|
before do
|
251
306
|
stub_post("/api/v1/gems/gems/owners").
|
252
307
|
with(:body => {:email => "sferik@gmail.com"}).
|
253
308
|
to_return(:body => fixture("add_owner"))
|
254
309
|
end
|
255
|
-
|
256
310
|
it "should add an owner to a RubyGem" do
|
257
311
|
owner = Gems.add_owner("gems", "sferik@gmail.com")
|
258
312
|
a_post("/api/v1/gems/gems/owners").
|
@@ -262,13 +316,12 @@ describe Gems::Client do
|
|
262
316
|
end
|
263
317
|
end
|
264
318
|
|
265
|
-
describe "
|
319
|
+
describe "#remove_owner" do
|
266
320
|
before do
|
267
321
|
stub_delete("/api/v1/gems/gems/owners").
|
268
322
|
with(:query => {:email => "sferik@gmail.com"}).
|
269
323
|
to_return(:body => fixture("remove_owner"))
|
270
324
|
end
|
271
|
-
|
272
325
|
it "should remove an owner from a RubyGem" do
|
273
326
|
owner = Gems.remove_owner("gems", "sferik@gmail.com")
|
274
327
|
a_delete("/api/v1/gems/gems/owners").
|
@@ -278,12 +331,11 @@ describe Gems::Client do
|
|
278
331
|
end
|
279
332
|
end
|
280
333
|
|
281
|
-
describe "
|
334
|
+
describe "#web_hooks" do
|
282
335
|
before do
|
283
336
|
stub_get("/api/v1/web_hooks.yaml").
|
284
337
|
to_return(:body => fixture("web_hooks.yaml"))
|
285
338
|
end
|
286
|
-
|
287
339
|
it "should list the web hooks registered under your account" do
|
288
340
|
web_hooks = Gems.web_hooks
|
289
341
|
a_get("/api/v1/web_hooks.yaml").
|
@@ -292,13 +344,12 @@ describe Gems::Client do
|
|
292
344
|
end
|
293
345
|
end
|
294
346
|
|
295
|
-
describe "
|
347
|
+
describe "#add_web_hook" do
|
296
348
|
before do
|
297
349
|
stub_post("/api/v1/web_hooks").
|
298
350
|
with(:body => {:gem_name => "*", :url => "http://example.com"}).
|
299
351
|
to_return(:body => fixture("add_web_hook"))
|
300
352
|
end
|
301
|
-
|
302
353
|
it "should add a web hook" do
|
303
354
|
add_web_hook = Gems.add_web_hook("*", "http://example.com")
|
304
355
|
a_post("/api/v1/web_hooks").
|
@@ -308,13 +359,12 @@ describe Gems::Client do
|
|
308
359
|
end
|
309
360
|
end
|
310
361
|
|
311
|
-
describe "
|
362
|
+
describe "#remove_web_hook" do
|
312
363
|
before do
|
313
364
|
stub_delete("/api/v1/web_hooks/remove").
|
314
365
|
with(:query => {:gem_name => "*", :url => "http://example.com"}).
|
315
366
|
to_return(:body => fixture("remove_web_hook"))
|
316
367
|
end
|
317
|
-
|
318
368
|
it "should remove a web hook" do
|
319
369
|
remove_web_hook = Gems.remove_web_hook("*", "http://example.com")
|
320
370
|
a_delete("/api/v1/web_hooks/remove").
|
@@ -324,13 +374,12 @@ describe Gems::Client do
|
|
324
374
|
end
|
325
375
|
end
|
326
376
|
|
327
|
-
describe "
|
377
|
+
describe "#fire_web_hook" do
|
328
378
|
before do
|
329
379
|
stub_post("/api/v1/web_hooks/fire").
|
330
380
|
with(:body => {:gem_name => "*", :url => "http://example.com"}).
|
331
381
|
to_return(:body => fixture("fire_web_hook"))
|
332
382
|
end
|
333
|
-
|
334
383
|
it "should fire a web hook" do
|
335
384
|
fire_web_hook = Gems.fire_web_hook("*", "http://example.com")
|
336
385
|
a_post("/api/v1/web_hooks/fire").
|
@@ -340,98 +389,11 @@ describe Gems::Client do
|
|
340
389
|
end
|
341
390
|
end
|
342
391
|
|
343
|
-
describe "
|
344
|
-
before do
|
345
|
-
stub_post("/api/v1/gems").
|
346
|
-
to_return(:body => fixture("push"))
|
347
|
-
end
|
348
|
-
|
349
|
-
it "should submit a gem to RubyGems.org" do
|
350
|
-
push = Gems.push(File.new(File.expand_path("../../fixtures/gems-0.0.8.gem", __FILE__), "rb"))
|
351
|
-
a_post("/api/v1/gems").
|
352
|
-
should have_been_made
|
353
|
-
push.should == "Successfully registered gem: gems (0.0.8)"
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
describe ".yank" do
|
358
|
-
context "with no version specified" do
|
359
|
-
before do
|
360
|
-
stub_get("/api/v1/gems/gems.yaml").
|
361
|
-
to_return(:body => fixture("rails.yaml"))
|
362
|
-
stub_delete("/api/v1/gems/yank").
|
363
|
-
with(:query => {:gem_name => "gems", :version => "3.0.9"}).
|
364
|
-
to_return(:body => fixture("yank"))
|
365
|
-
end
|
366
|
-
|
367
|
-
it "should remove a gem from RubyGems.org's index" do
|
368
|
-
yank = Gems.yank("gems")
|
369
|
-
a_delete("/api/v1/gems/yank").
|
370
|
-
with(:query => {:gem_name => "gems", :version => "3.0.9"}).
|
371
|
-
should have_been_made
|
372
|
-
yank.should == "Successfully yanked gem: gems (0.0.8)"
|
373
|
-
end
|
374
|
-
end
|
375
|
-
|
376
|
-
context "with a version specified" do
|
377
|
-
before do
|
378
|
-
stub_delete("/api/v1/gems/yank").
|
379
|
-
with(:query => {:gem_name => "gems", :version => "0.0.8"}).
|
380
|
-
to_return(:body => fixture("yank"))
|
381
|
-
end
|
382
|
-
|
383
|
-
it "should remove a gem from RubyGems.org's index" do
|
384
|
-
yank = Gems.yank("gems", "0.0.8")
|
385
|
-
a_delete("/api/v1/gems/yank").
|
386
|
-
with(:query => {:gem_name => "gems", :version => "0.0.8"}).
|
387
|
-
should have_been_made
|
388
|
-
yank.should == "Successfully yanked gem: gems (0.0.8)"
|
389
|
-
end
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
describe ".unyank" do
|
394
|
-
context "with no version specified" do
|
395
|
-
before do
|
396
|
-
stub_get("/api/v1/gems/gems.yaml").
|
397
|
-
to_return(:body => fixture("rails.yaml"))
|
398
|
-
stub_put("/api/v1/gems/unyank").
|
399
|
-
with(:body => {:gem_name => "gems", :version => "3.0.9"}).
|
400
|
-
to_return(:body => fixture("unyank"))
|
401
|
-
end
|
402
|
-
|
403
|
-
it "should update a previously yanked gem back into RubyGems.org's index" do
|
404
|
-
unyank = Gems.unyank("gems")
|
405
|
-
a_put("/api/v1/gems/unyank").
|
406
|
-
with(:body => {:gem_name => "gems", :version => "3.0.9"}).
|
407
|
-
should have_been_made
|
408
|
-
unyank.should == "Successfully unyanked gem: gems (0.0.8)"
|
409
|
-
end
|
410
|
-
end
|
411
|
-
|
412
|
-
context "with a version specified" do
|
413
|
-
before do
|
414
|
-
stub_put("/api/v1/gems/unyank").
|
415
|
-
with(:body => {:gem_name => "gems", :version => "0.0.8"}).
|
416
|
-
to_return(:body => fixture("unyank"))
|
417
|
-
end
|
418
|
-
|
419
|
-
it "should update a previously yanked gem back into RubyGems.org's index" do
|
420
|
-
unyank = Gems.unyank("gems", "0.0.8")
|
421
|
-
a_put("/api/v1/gems/unyank").
|
422
|
-
with(:body => {:gem_name => "gems", :version => "0.0.8"}).
|
423
|
-
should have_been_made
|
424
|
-
unyank.should == "Successfully unyanked gem: gems (0.0.8)"
|
425
|
-
end
|
426
|
-
end
|
427
|
-
end
|
428
|
-
|
429
|
-
describe ".latest" do
|
392
|
+
describe "#latest" do
|
430
393
|
before do
|
431
394
|
stub_get("/api/v1/activity/latest.yaml").
|
432
395
|
to_return(:body => fixture("latest.yaml"))
|
433
396
|
end
|
434
|
-
|
435
397
|
it "should return some basic information about the given gem" do
|
436
398
|
latest = Gems.latest
|
437
399
|
a_get("/api/v1/activity/latest.yaml").
|
@@ -440,12 +402,11 @@ describe Gems::Client do
|
|
440
402
|
end
|
441
403
|
end
|
442
404
|
|
443
|
-
describe "
|
405
|
+
describe "#just_updated" do
|
444
406
|
before do
|
445
407
|
stub_get("/api/v1/activity/just_updated.yaml").
|
446
408
|
to_return(:body => fixture("just_updated.yaml"))
|
447
409
|
end
|
448
|
-
|
449
410
|
it "should return some basic information about the given gem" do
|
450
411
|
just_updated = Gems.just_updated
|
451
412
|
a_get("/api/v1/activity/just_updated.yaml").
|
@@ -454,4 +415,36 @@ describe Gems::Client do
|
|
454
415
|
end
|
455
416
|
end
|
456
417
|
|
418
|
+
describe "#api_key" do
|
419
|
+
before do
|
420
|
+
Gems.configure do |config|
|
421
|
+
config.username = 'nick@gemcutter.org'
|
422
|
+
config.password = 'schwwwwing'
|
423
|
+
end
|
424
|
+
stub_get("https://nick%40gemcutter.org:schwwwwing@rubygems.org/api/v1/api_key").
|
425
|
+
to_return(:body => fixture("api_key"))
|
426
|
+
end
|
427
|
+
it "should retrieve an API key" do
|
428
|
+
api_key = Gems.api_key
|
429
|
+
a_get("https://nick%40gemcutter.org:schwwwwing@rubygems.org/api/v1/api_key").
|
430
|
+
should have_been_made
|
431
|
+
api_key.should == "701243f217cdf23b1370c7b66b65ca97"
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
describe "#dependencies" do
|
436
|
+
before do
|
437
|
+
stub_get("/api/v1/dependencies").
|
438
|
+
with(:query => {"gems" => "rails,thor"}).
|
439
|
+
to_return(:body => fixture("dependencies"))
|
440
|
+
end
|
441
|
+
it "should return an array of hashes for all versions of given gems" do
|
442
|
+
dependencies = Gems.dependencies 'rails', 'thor'
|
443
|
+
a_get("/api/v1/dependencies").
|
444
|
+
with(:query => {"gems" => "rails,thor"}).
|
445
|
+
should have_been_made
|
446
|
+
dependencies.first[:number].should == "3.0.9"
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
457
450
|
end
|