ratom-nokogiri 0.10.5 → 0.10.6
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.
- checksums.yaml +4 -4
- data/lib/atom.rb +1 -1
- data/lib/atom/version.rb +1 -1
- data/ratom.gemspec +3 -3
- data/spec/atom/pub_spec.rb +127 -127
- data/spec/atom_spec.rb +274 -269
- data/spec/spec_helper.rb +12 -12
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72fbcb1c4415e77bf437d39782a2e8d80151c028
|
4
|
+
data.tar.gz: cef37e509cd5eff4eeb60a5aee43084e72e34861
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6449836e0109bc5c33eab31cdb2468af0bd26742537f57b60951ffbb458367314d66d2a4661c8371a91e266804d3652abe84eb664c46c0808c0a12b515c16d09
|
7
|
+
data.tar.gz: eb5ce37c1bed1d82ed53a8fae3b4498134e2629e47e24d2e32f3c2fb7336e383138a7e1681789377cd289684187ec068beeae6b9cffad5dd630156ab550beb9b
|
data/lib/atom.rb
CHANGED
data/lib/atom/version.rb
CHANGED
data/ratom.gemspec
CHANGED
@@ -19,10 +19,10 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
s.summary = "Atom Syndication and Publication API"
|
21
21
|
|
22
|
-
s.add_dependency(%q<nokogiri>, [">= 1.5.6", "< 1.
|
22
|
+
s.add_dependency(%q<nokogiri>, [">= 1.5.6", "< 1.9"])
|
23
23
|
s.add_development_dependency(%q<bundler>, ["~> 1.1"])
|
24
|
-
s.add_development_dependency(%q<rspec>, ["~>
|
25
|
-
s.add_development_dependency(%q<rake>, ["~>
|
24
|
+
s.add_development_dependency(%q<rspec>, ["~> 3.6.0"])
|
25
|
+
s.add_development_dependency(%q<rake>, ["~> 12.0"])
|
26
26
|
s.add_development_dependency(%q<byebug>, ["~> 9.0"])
|
27
27
|
end
|
28
28
|
|
data/spec/atom/pub_spec.rb
CHANGED
@@ -14,92 +14,92 @@ require 'net/http'
|
|
14
14
|
|
15
15
|
shared_examples_for 'parser of spec/app/service.xml' do
|
16
16
|
it "should have 2 workspaces" do
|
17
|
-
@service.
|
17
|
+
expect(@service.workspaces.size).to eq(2)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should have a title" do
|
21
|
-
@workspace.title.
|
21
|
+
expect(@workspace.title).to eq("Main Site")
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should have 2 collections" do
|
25
|
-
@workspace.
|
25
|
+
expect(@workspace.collections.size).to eq(2)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should have the right href" do
|
29
|
-
@collection1.href.
|
29
|
+
expect(@collection1.href).to eq('http://example.org/blog/main')
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should have categories" do
|
33
|
-
@collection1.categories.
|
33
|
+
expect(@collection1.categories).not_to be_nil
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should have a href on categories" do
|
37
|
-
@collection1.categories.href.
|
38
|
-
@collection1.categories.fixed
|
37
|
+
expect(@collection1.categories.href).to eq("http://example.org/cats/forMain.cats")
|
38
|
+
expect(@collection1.categories.fixed?).to be_falsey
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should have a title" do
|
42
|
-
@collection1.title.
|
42
|
+
expect(@collection1.title).to eq('My Blog Entries')
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should have a title" do
|
46
|
-
@collection2.title.
|
46
|
+
expect(@collection2.title).to eq('Pictures')
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should have the right href" do
|
50
|
-
@collection2.href.
|
50
|
+
expect(@collection2.href).to eq('http://example.org/blog/pic')
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should not have categories" do
|
54
|
-
@collection2.categories.
|
54
|
+
expect(@collection2.categories).to be_nil
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should have 3 accepts" do
|
58
|
-
@collection2.
|
58
|
+
expect(@collection2.accepts.size).to eq(3)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should accept 'image/png'" do
|
62
|
-
@collection2.accepts.
|
62
|
+
expect(@collection2.accepts).to include('image/png')
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should accept 'image/jpeg'" do
|
66
|
-
@collection2.accepts.
|
66
|
+
expect(@collection2.accepts).to include('image/jpeg')
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should accept 'image/gif'" do
|
70
|
-
@collection2.accepts.
|
70
|
+
expect(@collection2.accepts).to include('image/gif')
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should have a title on workspace 2" do
|
74
|
-
@workspace2.title.
|
74
|
+
expect(@workspace2.title).to eq('Sidebar Blog')
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should have 1 collection on workspace 2" do
|
78
|
-
@workspace2.
|
78
|
+
expect(@workspace2.collections.size).to eq(1)
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should have a title on collection 3" do
|
82
|
-
@collection3.title.
|
82
|
+
expect(@collection3.title).to eq('Remaindered Links')
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should have 1 accept on collection 3" do
|
86
|
-
@collection3.
|
86
|
+
expect(@collection3.accepts.size).to eq(1)
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should accept 'application/atom+xml;type=entry'" do
|
90
|
-
@collection3.accepts.
|
90
|
+
expect(@collection3.accepts).to include('application/atom+xml;type=entry')
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should have categories" do
|
94
|
-
@collection3.categories.
|
94
|
+
expect(@collection3.categories).not_to be_nil
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should have fixed == 'yes' on categories" do
|
98
|
-
@collection3.categories.fixed.
|
98
|
+
expect(@collection3.categories.fixed).to eq("yes")
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should have fixed? == true on categories" do
|
102
|
-
@collection3.categories.fixed
|
102
|
+
expect(@collection3.categories.fixed?).to be_truthy
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -108,18 +108,18 @@ describe Atom::Pub do
|
|
108
108
|
it "should load from a URL" do
|
109
109
|
uri = URI.parse('http://example.com/service.xml')
|
110
110
|
response = Net::HTTPSuccess.new(nil, nil, nil)
|
111
|
-
response.
|
111
|
+
allow(response).to receive(:body).and_return(File.read('spec/app/service.xml'))
|
112
112
|
mock_http_get(uri, response)
|
113
113
|
|
114
|
-
Atom::Pub::Service.load_service(uri).
|
114
|
+
expect(Atom::Pub::Service.load_service(uri)).to be_an_instance_of(Atom::Pub::Service)
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should raise ArgumentError with a non-http URL" do
|
118
|
-
|
118
|
+
expect { Atom::Pub::Service.load_service(URI.parse('file:/tmp')) }.to raise_error(ArgumentError)
|
119
119
|
end
|
120
120
|
|
121
121
|
it "should be able to be created without xml" do
|
122
|
-
|
122
|
+
expect { Atom::Pub::Service.new }.not_to raise_error
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should yield in the initializer" do
|
@@ -128,16 +128,16 @@ describe Atom::Pub do
|
|
128
128
|
yielded = true
|
129
129
|
end
|
130
130
|
|
131
|
-
yielded.
|
131
|
+
expect(yielded).to be_truthy
|
132
132
|
end
|
133
133
|
|
134
134
|
it "should parse it's output" do
|
135
135
|
orig = File.read('spec/app/service.xml')
|
136
136
|
svc = Atom::Pub::Service.load_service(orig)
|
137
137
|
xml = svc.to_xml.to_s
|
138
|
-
|
138
|
+
expect do
|
139
139
|
Atom::Pub::Service.load_service(xml)
|
140
|
-
end.
|
140
|
+
end.not_to raise_error
|
141
141
|
end
|
142
142
|
|
143
143
|
describe "load_service" do
|
@@ -170,7 +170,7 @@ describe Atom::Pub do
|
|
170
170
|
it "should pass credentials to the server" do
|
171
171
|
uri = URI.parse('http://example.com/service.xml')
|
172
172
|
response = Net::HTTPSuccess.new(nil, nil, nil)
|
173
|
-
response.
|
173
|
+
allow(response).to receive(:body).and_return(File.read('spec/app/service.xml'))
|
174
174
|
mock_http_get(uri, response, 'user', 'pass')
|
175
175
|
Atom::Pub::Service.load_service(uri, :user => 'user', :pass => 'pass')
|
176
176
|
end
|
@@ -178,13 +178,13 @@ describe Atom::Pub do
|
|
178
178
|
it "should pass credentials on to the collections" do
|
179
179
|
uri = URI.parse('http://example.com/service.xml')
|
180
180
|
response = Net::HTTPSuccess.new(nil, nil, nil)
|
181
|
-
response.
|
181
|
+
allow(response).to receive(:body).and_return(File.read('spec/app/service.xml'))
|
182
182
|
mock_http_get(uri, response, 'user', 'pass')
|
183
183
|
pub = Atom::Pub::Service.load_service(uri, :user => 'user', :pass => 'pass')
|
184
184
|
|
185
185
|
uri2 = URI.parse('http://example.org/blog/main')
|
186
186
|
response2 = Net::HTTPSuccess.new(nil, nil, nil)
|
187
|
-
response2.
|
187
|
+
allow(response2).to receive(:body).and_return(File.read('spec/fixtures/simple_single_entry.atom'))
|
188
188
|
mock_http_get(uri2, response2, 'user', 'pass')
|
189
189
|
pub.workspaces.first.collections.first.feed(:user => 'user', :pass => 'pass')
|
190
190
|
end
|
@@ -203,7 +203,7 @@ describe Atom::Pub do
|
|
203
203
|
end
|
204
204
|
|
205
205
|
it "should put title in Atom namespace" do
|
206
|
-
@xml.
|
206
|
+
expect(@xml).to match(%r{atom:title})
|
207
207
|
end
|
208
208
|
|
209
209
|
it_should_behave_like 'parser of spec/app/service.xml'
|
@@ -214,23 +214,23 @@ describe Atom::Pub do
|
|
214
214
|
describe '.new' do
|
215
215
|
it "should set the href from the hash" do
|
216
216
|
collection = Atom::Pub::Collection.new(:href => 'http://example.org/blog')
|
217
|
-
collection.href.
|
217
|
+
expect(collection.href).to eq('http://example.org/blog')
|
218
218
|
end
|
219
219
|
|
220
220
|
it "should set the href from a block" do
|
221
221
|
collection = Atom::Pub::Collection.new do |c|
|
222
222
|
c.href = "http://example.org/blog"
|
223
223
|
end
|
224
|
-
collection.href.
|
224
|
+
expect(collection.href).to eq('http://example.org/blog')
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
228
228
|
it "should return the feed" do
|
229
229
|
collection = Atom::Pub::Collection.new(:href => 'http://example.org/blog')
|
230
230
|
response = Net::HTTPSuccess.new(nil, nil, nil)
|
231
|
-
response.
|
231
|
+
allow(response).to receive(:body).and_return(File.read('spec/fixtures/simple_single_entry.atom'))
|
232
232
|
mock_http_get(URI.parse(collection.href), response)
|
233
|
-
collection.feed.
|
233
|
+
expect(collection.feed).to be_an_instance_of(Atom::Feed)
|
234
234
|
end
|
235
235
|
|
236
236
|
describe '#publish' do
|
@@ -247,15 +247,15 @@ describe Atom::Pub do
|
|
247
247
|
|
248
248
|
response = mock_response(Net::HTTPCreated, entry.to_xml.to_s)
|
249
249
|
|
250
|
-
request =
|
251
|
-
Net::HTTP::Post.
|
250
|
+
request = double('request')
|
251
|
+
expect(Net::HTTP::Post).to receive(:new).with('/blog', @request_headers).and_return(request)
|
252
252
|
|
253
|
-
http =
|
254
|
-
http.
|
255
|
-
Net::HTTP.
|
253
|
+
http = double('http')
|
254
|
+
expect(http).to receive(:request).with(request, entry.to_xml.to_s).and_return(response)
|
255
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
256
256
|
|
257
257
|
created = @collection.publish(entry)
|
258
|
-
created.
|
258
|
+
expect(created).to eq(entry)
|
259
259
|
end
|
260
260
|
|
261
261
|
it "should send a POST with basic auth request when an entry is published" do
|
@@ -263,16 +263,16 @@ describe Atom::Pub do
|
|
263
263
|
|
264
264
|
response = mock_response(Net::HTTPCreated, entry.to_xml.to_s)
|
265
265
|
|
266
|
-
request =
|
267
|
-
request.
|
268
|
-
Net::HTTP::Post.
|
266
|
+
request = double('request')
|
267
|
+
expect(request).to receive(:basic_auth).with('user', 'pass')
|
268
|
+
expect(Net::HTTP::Post).to receive(:new).with('/blog', @request_headers).and_return(request)
|
269
269
|
|
270
|
-
http =
|
271
|
-
http.
|
272
|
-
Net::HTTP.
|
270
|
+
http = double('http')
|
271
|
+
expect(http).to receive(:request).with(request, entry.to_xml.to_s).and_return(response)
|
272
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
273
273
|
|
274
274
|
created = @collection.publish(entry, :user => 'user', :pass => 'pass')
|
275
|
-
created.
|
275
|
+
expect(created).to eq(entry)
|
276
276
|
end
|
277
277
|
|
278
278
|
if Atom::Configuration.auth_hmac_enabled?
|
@@ -281,16 +281,16 @@ describe Atom::Pub do
|
|
281
281
|
|
282
282
|
response = mock_response(Net::HTTPCreated, entry.to_xml.to_s)
|
283
283
|
|
284
|
-
http =
|
285
|
-
http.
|
286
|
-
request['Authorization'].
|
284
|
+
http = double('http')
|
285
|
+
expect(http).to receive(:request) do |request, entry_xml|
|
286
|
+
expect(request['Authorization']).to match(/^AuthHMAC access_id:[a-zA-Z0-9\/+]+=*/)
|
287
287
|
response
|
288
288
|
end
|
289
289
|
|
290
|
-
Net::HTTP.
|
290
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
291
291
|
|
292
292
|
created = @collection.publish(entry, :hmac_access_id => 'access_id', :hmac_secret_key => 'secret')
|
293
|
-
created.
|
293
|
+
expect(created).to eq(entry)
|
294
294
|
end
|
295
295
|
else
|
296
296
|
xit "should send a POST with hmac authentication when an entry is published"
|
@@ -301,29 +301,29 @@ describe Atom::Pub do
|
|
301
301
|
|
302
302
|
response = mock_response(Net::HTTPCreated, " ")
|
303
303
|
|
304
|
-
request =
|
305
|
-
Net::HTTP::Post.
|
304
|
+
request = double('request')
|
305
|
+
expect(Net::HTTP::Post).to receive(:new).with('/blog', @request_headers).and_return(request)
|
306
306
|
|
307
|
-
http =
|
308
|
-
http.
|
309
|
-
Net::HTTP.
|
307
|
+
http = double('http')
|
308
|
+
expect(http).to receive(:request).with(request, entry.to_xml.to_s).and_return(response)
|
309
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
310
310
|
|
311
311
|
created = @collection.publish(entry)
|
312
|
-
created.
|
312
|
+
expect(created).to eq(entry)
|
313
313
|
end
|
314
314
|
|
315
315
|
it "should raise error when response is not HTTPCreated" do
|
316
316
|
entry = Atom::Entry.load_entry(File.open('spec/fixtures/entry.atom'))
|
317
317
|
response = mock_response(Net::HTTPPreconditionFailed, "")
|
318
318
|
|
319
|
-
request =
|
320
|
-
Net::HTTP::Post.
|
319
|
+
request = double('request')
|
320
|
+
expect(Net::HTTP::Post).to receive(:new).with('/blog', @request_headers).and_return(request)
|
321
321
|
|
322
|
-
http =
|
323
|
-
http.
|
324
|
-
Net::HTTP.
|
322
|
+
http = double('http')
|
323
|
+
expect(http).to receive(:request).with(request, entry.to_xml.to_s).and_return(response)
|
324
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
325
325
|
|
326
|
-
|
326
|
+
expect { @collection.publish(entry) }.to raise_error(Atom::Pub::ProtocolError)
|
327
327
|
end
|
328
328
|
|
329
329
|
it "should copy Location into edit link of entry" do
|
@@ -331,16 +331,16 @@ describe Atom::Pub do
|
|
331
331
|
|
332
332
|
response = mock_response(Net::HTTPCreated, entry.to_xml.to_s, 'Location' => 'http://example.org/edit/entry1.atom')
|
333
333
|
|
334
|
-
request =
|
335
|
-
Net::HTTP::Post.
|
334
|
+
request = double('request')
|
335
|
+
expect(Net::HTTP::Post).to receive(:new).with('/blog', @request_headers).and_return(request)
|
336
336
|
|
337
|
-
http =
|
338
|
-
http.
|
339
|
-
Net::HTTP.
|
337
|
+
http = double('http')
|
338
|
+
expect(http).to receive(:request).with(request, entry.to_xml.to_s).and_return(response)
|
339
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
340
340
|
|
341
341
|
created = @collection.publish(entry)
|
342
|
-
created.edit_link.
|
343
|
-
created.edit_link.href.
|
342
|
+
expect(created.edit_link).not_to be_nil
|
343
|
+
expect(created.edit_link.href).to eq('http://example.org/edit/entry1.atom')
|
344
344
|
end
|
345
345
|
|
346
346
|
it "should update the entry when response is different" do
|
@@ -348,15 +348,15 @@ describe Atom::Pub do
|
|
348
348
|
response = mock_response(Net::HTTPCreated, File.read('spec/fixtures/created_entry.atom'),
|
349
349
|
'Location' => 'http://example.org/edit/atom')
|
350
350
|
|
351
|
-
request =
|
352
|
-
Net::HTTP::Post.
|
351
|
+
request = double('request')
|
352
|
+
expect(Net::HTTP::Post).to receive(:new).with('/blog', @request_headers).and_return(request)
|
353
353
|
|
354
|
-
http =
|
355
|
-
http.
|
356
|
-
Net::HTTP.
|
354
|
+
http = double('http')
|
355
|
+
expect(http).to receive(:request).with(request, entry.to_xml.to_s).and_return(response)
|
356
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
357
357
|
|
358
358
|
created = @collection.publish(entry)
|
359
|
-
created.
|
359
|
+
expect(created).to eq(Atom::Entry.load_entry(File.open('spec/fixtures/created_entry.atom')))
|
360
360
|
end
|
361
361
|
end
|
362
362
|
end
|
@@ -367,12 +367,12 @@ describe Atom::Pub do
|
|
367
367
|
w.title = "Title"
|
368
368
|
end
|
369
369
|
|
370
|
-
workspace.title.
|
370
|
+
expect(workspace.title).to eq("Title")
|
371
371
|
end
|
372
372
|
|
373
373
|
it "should do the hash initialization thing" do
|
374
374
|
workspace = Atom::Pub::Workspace.new(:title => 'Title')
|
375
|
-
workspace.title.
|
375
|
+
expect(workspace.title).to eq("Title")
|
376
376
|
end
|
377
377
|
end
|
378
378
|
|
@@ -388,12 +388,12 @@ describe Atom::Pub do
|
|
388
388
|
entry = Atom::Entry.load_entry(File.open('spec/app/member_entry.atom'))
|
389
389
|
response = mock_response(Net::HTTPSuccess, nil)
|
390
390
|
|
391
|
-
request =
|
392
|
-
Net::HTTP::Put.
|
391
|
+
request = double('request')
|
392
|
+
expect(Net::HTTP::Put).to receive(:new).with('/member_entry.atom', @request_headers).and_return(request)
|
393
393
|
|
394
|
-
http =
|
395
|
-
http.
|
396
|
-
Net::HTTP.
|
394
|
+
http = double('http')
|
395
|
+
expect(http).to receive(:request).with(request, entry.to_xml.to_s).and_return(response)
|
396
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
397
397
|
|
398
398
|
entry.save!
|
399
399
|
end
|
@@ -402,13 +402,13 @@ describe Atom::Pub do
|
|
402
402
|
entry = Atom::Entry.load_entry(File.open('spec/app/member_entry.atom'))
|
403
403
|
response = mock_response(Net::HTTPSuccess, nil)
|
404
404
|
|
405
|
-
request =
|
406
|
-
request.
|
407
|
-
Net::HTTP::Put.
|
405
|
+
request = double('request')
|
406
|
+
expect(request).to receive(:basic_auth).with('user', 'pass')
|
407
|
+
expect(Net::HTTP::Put).to receive(:new).with('/member_entry.atom', @request_headers).and_return(request)
|
408
408
|
|
409
|
-
http =
|
410
|
-
http.
|
411
|
-
Net::HTTP.
|
409
|
+
http = double('http')
|
410
|
+
expect(http).to receive(:request).with(request, entry.to_xml.to_s).and_return(response)
|
411
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
412
412
|
|
413
413
|
entry.save!(:user => 'user', :pass => 'pass')
|
414
414
|
end
|
@@ -418,13 +418,13 @@ describe Atom::Pub do
|
|
418
418
|
entry = Atom::Entry.load_entry(File.open('spec/app/member_entry.atom'))
|
419
419
|
response = mock_response(Net::HTTPSuccess, nil)
|
420
420
|
|
421
|
-
http =
|
422
|
-
http.
|
423
|
-
request['Authorization'].
|
421
|
+
http = double('http')
|
422
|
+
expect(http).to receive(:request) do |request, entry_xml|
|
423
|
+
expect(request['Authorization']).to match(/^AuthHMAC access_id:[a-zA-Z0-9\/+]+=*$/)
|
424
424
|
response
|
425
425
|
end
|
426
426
|
|
427
|
-
Net::HTTP.
|
427
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
428
428
|
|
429
429
|
entry.save!(:hmac_access_id => 'access_id', :hmac_secret_key => 'secret')
|
430
430
|
end
|
@@ -434,12 +434,12 @@ describe Atom::Pub do
|
|
434
434
|
entry = Atom::Entry.load_entry(File.open('spec/app/member_entry.atom'))
|
435
435
|
response = mock_response(Net::HTTPSuccess, nil)
|
436
436
|
|
437
|
-
request =
|
438
|
-
Net::HTTP::Delete.
|
437
|
+
request = double('request')
|
438
|
+
expect(Net::HTTP::Delete).to receive(:new).with('/member_entry.atom', an_instance_of(Hash)).and_return(request)
|
439
439
|
|
440
|
-
http =
|
441
|
-
http.
|
442
|
-
Net::HTTP.
|
440
|
+
http = double('http')
|
441
|
+
expect(http).to receive(:request).with(request).and_return(response)
|
442
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
443
443
|
|
444
444
|
entry.destroy!
|
445
445
|
end
|
@@ -448,13 +448,13 @@ describe Atom::Pub do
|
|
448
448
|
entry = Atom::Entry.load_entry(File.open('spec/app/member_entry.atom'))
|
449
449
|
response = mock_response(Net::HTTPSuccess, nil)
|
450
450
|
|
451
|
-
request =
|
452
|
-
request.
|
453
|
-
Net::HTTP::Delete.
|
451
|
+
request = double('request')
|
452
|
+
expect(request).to receive(:basic_auth).with('user', 'pass')
|
453
|
+
expect(Net::HTTP::Delete).to receive(:new).with('/member_entry.atom', an_instance_of(Hash)).and_return(request)
|
454
454
|
|
455
|
-
http =
|
456
|
-
http.
|
457
|
-
Net::HTTP.
|
455
|
+
http = double('http')
|
456
|
+
expect(http).to receive(:request).with(request).and_return(response)
|
457
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
458
458
|
|
459
459
|
entry.destroy!(:user => 'user', :pass => 'pass')
|
460
460
|
end
|
@@ -464,13 +464,13 @@ describe Atom::Pub do
|
|
464
464
|
entry = Atom::Entry.load_entry(File.open('spec/app/member_entry.atom'))
|
465
465
|
response = mock_response(Net::HTTPSuccess, nil)
|
466
466
|
|
467
|
-
http =
|
468
|
-
http.
|
469
|
-
request['Authorization'].
|
467
|
+
http = double('http')
|
468
|
+
expect(http).to receive(:request) do |request|
|
469
|
+
expect(request['Authorization']).to match(/^AuthHMAC access_id:[a-zA-Z0-9\/+]+=*$/)
|
470
470
|
response
|
471
471
|
end
|
472
472
|
|
473
|
-
Net::HTTP.
|
473
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
474
474
|
|
475
475
|
entry.destroy!(:hmac_access_id => 'access_id', :hmac_secret_key => 'secret')
|
476
476
|
end
|
@@ -478,40 +478,40 @@ describe Atom::Pub do
|
|
478
478
|
|
479
479
|
it "should raise exception on save! without an edit link" do
|
480
480
|
entry = Atom::Entry.load_entry(File.open('spec/fixtures/entry.atom'))
|
481
|
-
|
481
|
+
expect { entry.save! }.to raise_error(Atom::Pub::NotSupported)
|
482
482
|
end
|
483
483
|
|
484
484
|
it "should raise exception on save failure" do
|
485
485
|
entry = Atom::Entry.load_entry(File.open('spec/app/member_entry.atom'))
|
486
486
|
response = mock_response(Net::HTTPClientError, nil)
|
487
487
|
|
488
|
-
request =
|
489
|
-
Net::HTTP::Put.
|
488
|
+
request = double('request')
|
489
|
+
expect(Net::HTTP::Put).to receive(:new).with('/member_entry.atom', @request_headers).and_return(request)
|
490
490
|
|
491
|
-
http =
|
492
|
-
http.
|
493
|
-
Net::HTTP.
|
491
|
+
http = double('http')
|
492
|
+
expect(http).to receive(:request).with(request, entry.to_xml.to_s).and_return(response)
|
493
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
494
494
|
|
495
|
-
|
495
|
+
expect { entry.save! }.to raise_error(Atom::Pub::ProtocolError)
|
496
496
|
end
|
497
497
|
|
498
498
|
it "should raise exception on destroy! without an edit link" do
|
499
499
|
entry = Atom::Entry.load_entry(File.open('spec/fixtures/entry.atom'))
|
500
|
-
|
500
|
+
expect { entry.destroy! }.to raise_error(Atom::Pub::NotSupported)
|
501
501
|
end
|
502
502
|
|
503
503
|
it "should raise exception on destroy failure" do
|
504
504
|
entry = Atom::Entry.load_entry(File.open('spec/app/member_entry.atom'))
|
505
505
|
response = mock_response(Net::HTTPClientError, nil)
|
506
506
|
|
507
|
-
request =
|
508
|
-
Net::HTTP::Delete.
|
507
|
+
request = double('request')
|
508
|
+
expect(Net::HTTP::Delete).to receive(:new).with('/member_entry.atom', an_instance_of(Hash)).and_return(request)
|
509
509
|
|
510
|
-
http =
|
511
|
-
http.
|
512
|
-
Net::HTTP.
|
510
|
+
http = double('http')
|
511
|
+
expect(http).to receive(:request).with(request).and_return(response)
|
512
|
+
expect(Net::HTTP).to receive(:start).with('example.org', 80).and_yield(http)
|
513
513
|
|
514
|
-
|
514
|
+
expect { entry.destroy! }.to raise_error(Atom::Pub::ProtocolError)
|
515
515
|
end
|
516
516
|
end
|
517
517
|
end
|