ratom-nokogiri 0.10.5 → 0.10.6
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/spec/atom_spec.rb
CHANGED
@@ -13,163 +13,163 @@ require 'property'
|
|
13
13
|
|
14
14
|
shared_examples_for 'simple_single_entry.atom attributes' do
|
15
15
|
it "should parse title" do
|
16
|
-
@feed.title.
|
16
|
+
expect(@feed.title).to eq('Example Feed')
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should parse updated" do
|
20
|
-
@feed.updated.
|
20
|
+
expect(@feed.updated).to eq(Time.parse('2003-12-13T18:30:02Z'))
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should parse id" do
|
24
|
-
@feed.id.
|
24
|
+
expect(@feed.id).to eq('urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6')
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should have an entries array" do
|
28
|
-
@feed.entries.
|
28
|
+
expect(@feed.entries).to be_an_instance_of(Array)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should have one element in the entries array" do
|
32
|
-
@feed.entries.size.
|
32
|
+
expect(@feed.entries.size).to eq(1)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should have an alternate" do
|
36
|
-
@feed.alternate.
|
36
|
+
expect(@feed.alternate).not_to be_nil
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should have an Atom::Link as the alternate" do
|
40
|
-
@feed.alternate.
|
40
|
+
expect(@feed.alternate).to be_an_instance_of(Atom::Link)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should have the correct href in the alternate" do
|
44
|
-
@feed.alternate.href.
|
44
|
+
expect(@feed.alternate.href).to eq('http://example.org/')
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should have 1 author" do
|
48
|
-
@feed.
|
48
|
+
expect(@feed.authors.size).to eq(1)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should have 'John Doe' as the author's name" do
|
52
|
-
@feed.authors.first.name.
|
52
|
+
expect(@feed.authors.first.name).to eq("John Doe")
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should parse title" do
|
56
|
-
@entry.title.
|
56
|
+
expect(@entry.title).to eq('Atom-Powered Robots Run Amok')
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should have an alternate" do
|
60
|
-
@entry.alternate.
|
60
|
+
expect(@entry.alternate).not_to be_nil
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should have an Atom::Link as the alternate" do
|
64
|
-
@entry.alternate.
|
64
|
+
expect(@entry.alternate).to be_an_instance_of(Atom::Link)
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should have the correct href on the alternate" do
|
68
|
-
@entry.alternate.href.
|
68
|
+
expect(@entry.alternate.href).to eq('http://example.org/2003/12/13/atom03')
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should parse id" do
|
72
|
-
@entry.id.
|
72
|
+
expect(@entry.id).to eq('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a')
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should parse updated" do
|
76
|
-
@entry.updated.
|
76
|
+
expect(@entry.updated).to eq(Time.parse('2003-12-13T18:30:02Z'))
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should parse summary" do
|
80
|
-
@entry.summary.
|
80
|
+
expect(@entry.summary).to eq('Some text.')
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should parse content" do
|
84
|
-
@entry.content.
|
84
|
+
expect(@entry.content).to eq('This <em>is</em> html.')
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should parse content type" do
|
88
|
-
@entry.content.type.
|
88
|
+
expect(@entry.content.type).to eq('html')
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
describe Atom do
|
93
93
|
describe "Atom::Feed.load_feed" do
|
94
94
|
it "should accept an IO" do
|
95
|
-
|
95
|
+
expect { Atom::Feed.load_feed(File.open('spec/fixtures/simple_single_entry.atom')) }.not_to raise_error
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should raise ArgumentError with something other than IO or URI" do
|
99
|
-
|
99
|
+
expect { Atom::Feed.load_feed(nil) }.to raise_error(ArgumentError)
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should accept a String" do
|
103
|
-
Atom::Feed.load_feed(File.read('spec/fixtures/simple_single_entry.atom')).
|
103
|
+
expect(Atom::Feed.load_feed(File.read('spec/fixtures/simple_single_entry.atom'))).to be_an_instance_of(Atom::Feed)
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should accept a URI" do
|
107
107
|
uri = URI.parse('http://example.com/feed.atom')
|
108
108
|
response = Net::HTTPSuccess.new(nil, nil, nil)
|
109
|
-
response.
|
109
|
+
allow(response).to receive(:body).and_return(File.read('spec/fixtures/simple_single_entry.atom'))
|
110
110
|
mock_http_get(uri, response)
|
111
111
|
|
112
|
-
Atom::Feed.load_feed(uri).
|
112
|
+
expect(Atom::Feed.load_feed(uri)).to be_an_instance_of(Atom::Feed)
|
113
113
|
end
|
114
114
|
|
115
115
|
it "should accept a URI with query parameters" do
|
116
116
|
uri = URI.parse('http://example.com/feed.atom?page=2')
|
117
117
|
response = Net::HTTPSuccess.new(nil, nil, nil)
|
118
|
-
response.
|
118
|
+
allow(response).to receive(:body).and_return(File.read('spec/fixtures/simple_single_entry.atom'))
|
119
119
|
mock_http_get(uri, response)
|
120
120
|
|
121
|
-
Atom::Feed.load_feed(uri).
|
121
|
+
expect(Atom::Feed.load_feed(uri)).to be_an_instance_of(Atom::Feed)
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should raise ArgumentError with non-http uri" do
|
125
125
|
uri = URI.parse('file:/tmp')
|
126
|
-
|
126
|
+
expect { Atom::Feed.load_feed(uri) }.to raise_error(ArgumentError)
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should return an Atom::Feed" do
|
130
130
|
feed = Atom::Feed.load_feed(File.open('spec/fixtures/simple_single_entry.atom'))
|
131
|
-
feed.
|
131
|
+
expect(feed).to be_an_instance_of(Atom::Feed)
|
132
132
|
end
|
133
133
|
|
134
134
|
it "should not raise an error with a String and basic-auth credentials" do
|
135
|
-
|
135
|
+
expect { Atom::Feed.load_feed(File.read('spec/fixtures/simple_single_entry.atom'), :user => 'user', :pass => 'pass') }.not_to raise_error
|
136
136
|
end
|
137
137
|
|
138
138
|
it "should not raise an error with a URI with basic-auth credentials" do
|
139
139
|
uri = URI.parse('http://example.com/feed.atom')
|
140
140
|
|
141
141
|
response = Net::HTTPSuccess.new(nil, nil, nil)
|
142
|
-
response.
|
142
|
+
allow(response).to receive(:body).and_return(File.read('spec/fixtures/simple_single_entry.atom'))
|
143
143
|
mock_http_get(uri, response, 'user', 'pass')
|
144
144
|
|
145
|
-
|
145
|
+
expect { Atom::Feed.load_feed(uri, :user => 'user', :pass => 'pass') }.not_to raise_error
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
149
|
describe 'Atom::Entry.load_entry' do
|
150
150
|
it "should accept an IO" do
|
151
|
-
Atom::Entry.load_entry(File.open('spec/fixtures/entry.atom')).
|
151
|
+
expect(Atom::Entry.load_entry(File.open('spec/fixtures/entry.atom'))).to be_an_instance_of(Atom::Entry)
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should accept a URI" do
|
155
155
|
uri = URI.parse('http://example.org/entry.atom')
|
156
156
|
response = Net::HTTPSuccess.new(nil, nil, nil)
|
157
|
-
response.
|
157
|
+
allow(response).to receive(:body).and_return(File.read('spec/fixtures/entry.atom'))
|
158
158
|
mock_http_get(uri, response)
|
159
159
|
|
160
|
-
Atom::Entry.load_entry(uri).
|
160
|
+
expect(Atom::Entry.load_entry(uri)).to be_an_instance_of(Atom::Entry)
|
161
161
|
end
|
162
162
|
|
163
163
|
it "should accept a String" do
|
164
|
-
Atom::Entry.load_entry(File.read('spec/fixtures/entry.atom')).
|
164
|
+
expect(Atom::Entry.load_entry(File.read('spec/fixtures/entry.atom'))).to be_an_instance_of(Atom::Entry)
|
165
165
|
end
|
166
166
|
|
167
167
|
it "should raise ArgumentError with something other than IO, String or URI" do
|
168
|
-
|
168
|
+
expect { Atom::Entry.load_entry(nil) }.to raise_error(ArgumentError)
|
169
169
|
end
|
170
170
|
|
171
171
|
it "should raise ArgumentError with non-http uri" do
|
172
|
-
|
172
|
+
expect { Atom::Entry.load_entry(URI.parse('file:/tmp')) }.to raise_error(ArgumentError)
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
@@ -184,13 +184,13 @@ describe Atom do
|
|
184
184
|
|
185
185
|
describe 'FeedWithStyleSheet' do
|
186
186
|
it "should load without failure" do
|
187
|
-
|
187
|
+
expect { feed = Atom::Feed.load_feed(File.open('spec/fixtures/with_stylesheet.atom')) }.not_to raise_error
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
191
|
describe Atom::Feed do
|
192
192
|
it "raises ArgumentError on missing feed tag" do
|
193
|
-
|
193
|
+
expect { Atom::Feed.load_feed("<other>hai</other>") }.to raise_error(ArgumentError, /missing atom:feed/)
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
@@ -200,80 +200,80 @@ describe Atom do
|
|
200
200
|
end
|
201
201
|
|
202
202
|
it "should include an xml declaration" do
|
203
|
-
@feed.to_xml.to_s.
|
203
|
+
expect(@feed.to_xml.to_s).to(match %r{<\?xml version="1.0" encoding="UTF-8"\?>})
|
204
204
|
end
|
205
205
|
|
206
206
|
describe Atom::Feed do
|
207
207
|
it "should have a title" do
|
208
|
-
@feed.title.
|
208
|
+
expect(@feed.title).to eq('dive into mark')
|
209
209
|
end
|
210
210
|
|
211
211
|
it "should have type on the title" do
|
212
|
-
@feed.title.type.
|
212
|
+
expect(@feed.title.type).to eq('text')
|
213
213
|
end
|
214
214
|
|
215
215
|
it "should have a subtitle" do
|
216
|
-
@feed.subtitle.
|
216
|
+
expect(@feed.subtitle).to eq('A <em>lot</em> of effort went into making this effortless')
|
217
217
|
end
|
218
218
|
|
219
219
|
it "should have a type for the subtitle" do
|
220
|
-
@feed.subtitle.type.
|
220
|
+
expect(@feed.subtitle.type).to eq('html')
|
221
221
|
end
|
222
222
|
|
223
223
|
it "should have an updated date" do
|
224
|
-
@feed.updated.
|
224
|
+
expect(@feed.updated).to eq(Time.parse('2005-07-31T12:29:29Z'))
|
225
225
|
end
|
226
226
|
|
227
227
|
it "should have an id" do
|
228
|
-
@feed.id.
|
228
|
+
expect(@feed.id).to eq('tag:example.org,2003:3')
|
229
229
|
end
|
230
230
|
|
231
231
|
it "should have 2 links" do
|
232
|
-
@feed.
|
232
|
+
expect(@feed.links.size).to eq(2)
|
233
233
|
end
|
234
234
|
|
235
235
|
it "should have an alternate link" do
|
236
|
-
@feed.alternate.
|
236
|
+
expect(@feed.alternate).not_to be_nil
|
237
237
|
end
|
238
238
|
|
239
239
|
it "should have the right url for the alternate" do
|
240
|
-
@feed.alternate.to_s.
|
240
|
+
expect(@feed.alternate.to_s).to eq('http://example.org/')
|
241
241
|
end
|
242
242
|
|
243
243
|
it "should have a self link" do
|
244
|
-
@feed.self.
|
244
|
+
expect(@feed.self).not_to be_nil
|
245
245
|
end
|
246
246
|
|
247
247
|
it "should have the right url for self" do
|
248
|
-
@feed.self.to_s.
|
248
|
+
expect(@feed.self.to_s).to eq('http://example.org/feed.atom')
|
249
249
|
end
|
250
250
|
|
251
251
|
it "should have rights" do
|
252
|
-
@feed.rights.
|
252
|
+
expect(@feed.rights).to eq('Copyright (c) 2003, Mark Pilgrim')
|
253
253
|
end
|
254
254
|
|
255
255
|
it "should have a generator" do
|
256
|
-
@feed.generator.
|
256
|
+
expect(@feed.generator).not_to be_nil
|
257
257
|
end
|
258
258
|
|
259
259
|
it "should have a generator uri" do
|
260
|
-
@feed.generator.uri.
|
260
|
+
expect(@feed.generator.uri).to eq('http://www.example.com/')
|
261
261
|
end
|
262
262
|
|
263
263
|
it "should have a generator version" do
|
264
|
-
@feed.generator.version.
|
264
|
+
expect(@feed.generator.version).to eq('1.0')
|
265
265
|
end
|
266
266
|
|
267
267
|
it "should have a generator name" do
|
268
|
-
@feed.generator.name.
|
268
|
+
expect(@feed.generator.name).to eq('Example Toolkit')
|
269
269
|
end
|
270
270
|
|
271
271
|
it "should have an entry" do
|
272
|
-
@feed.
|
272
|
+
expect(@feed.entries.size).to eq(1)
|
273
273
|
end
|
274
274
|
|
275
275
|
it "should have a category" do
|
276
|
-
@feed.
|
276
|
+
expect(@feed.categories.size).to eq(1)
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
@@ -284,17 +284,22 @@ describe Atom do
|
|
284
284
|
|
285
285
|
subject { @feed }
|
286
286
|
|
287
|
-
|
288
|
-
|
287
|
+
describe '#title' do
|
288
|
+
subject { super().title }
|
289
|
+
it { is_expected.to eq("xml:base support tests") }
|
290
|
+
end
|
291
|
+
it 'has 16 entries' do
|
292
|
+
expect(subject.entries.size).to eq(16)
|
293
|
+
end
|
289
294
|
|
290
295
|
it "should resolve all alternate links to the same location" do
|
291
296
|
@feed.entries.each do |entry|
|
292
|
-
entry.links.first.href.
|
297
|
+
expect(entry.links.first.href).to eq("http://example.org/tests/base/result.html")
|
293
298
|
end
|
294
299
|
end
|
295
300
|
|
296
301
|
it "should resolve all links in content to what their label says" do
|
297
|
-
|
302
|
+
skip "support xml:base in content XHTML"
|
298
303
|
end
|
299
304
|
end
|
300
305
|
|
@@ -304,52 +309,52 @@ describe Atom do
|
|
304
309
|
end
|
305
310
|
|
306
311
|
it "should have a title" do
|
307
|
-
@entry.title.
|
312
|
+
expect(@entry.title).to eq('Atom draft-07 snapshot')
|
308
313
|
end
|
309
314
|
|
310
315
|
it "should have an id" do
|
311
|
-
@entry.id.
|
316
|
+
expect(@entry.id).to eq('tag:example.org,2003:3.2397')
|
312
317
|
end
|
313
318
|
|
314
319
|
it "should have an updated date" do
|
315
|
-
@entry.updated.
|
320
|
+
expect(@entry.updated).to eq(Time.parse('2005-07-31T12:29:29Z'))
|
316
321
|
end
|
317
322
|
|
318
323
|
it "should have a published date" do
|
319
|
-
@entry.published.
|
324
|
+
expect(@entry.published).to eq(Time.parse('2003-12-13T08:29:29-04:00'))
|
320
325
|
end
|
321
326
|
|
322
327
|
it "should have an author" do
|
323
|
-
@entry.
|
328
|
+
expect(@entry.authors.size).to eq(1)
|
324
329
|
end
|
325
330
|
|
326
331
|
it "should have two links" do
|
327
|
-
@entry.
|
332
|
+
expect(@entry.links.size).to eq(2)
|
328
333
|
end
|
329
334
|
|
330
335
|
it "should have one alternate link" do
|
331
|
-
@entry.
|
336
|
+
expect(@entry.alternates.size).to eq(1)
|
332
337
|
end
|
333
338
|
|
334
339
|
it "should have one enclosure link" do
|
335
|
-
@entry.
|
340
|
+
expect(@entry.enclosures.size).to eq(1)
|
336
341
|
end
|
337
342
|
|
338
343
|
it "should have 2 contributors" do
|
339
|
-
@entry.
|
344
|
+
expect(@entry.contributors.size).to eq(2)
|
340
345
|
end
|
341
346
|
|
342
347
|
it "should have names for the contributors" do
|
343
|
-
@entry.contributors[0].name.
|
344
|
-
@entry.contributors[1].name.
|
348
|
+
expect(@entry.contributors[0].name).to eq('Sam Ruby')
|
349
|
+
expect(@entry.contributors[1].name).to eq('Joe Gregorio')
|
345
350
|
end
|
346
351
|
|
347
352
|
it "should have content" do
|
348
|
-
@entry.content.
|
353
|
+
expect(@entry.content).not_to be_nil
|
349
354
|
end
|
350
355
|
|
351
356
|
it "should have 2 categories" do
|
352
|
-
@entry.
|
357
|
+
expect(@entry.categories.size).to eq(2)
|
353
358
|
end
|
354
359
|
end
|
355
360
|
|
@@ -360,15 +365,15 @@ describe Atom do
|
|
360
365
|
end
|
361
366
|
|
362
367
|
it "should have a term" do
|
363
|
-
@category.term.
|
368
|
+
expect(@category.term).to eq("atom")
|
364
369
|
end
|
365
370
|
|
366
371
|
it "should have a scheme" do
|
367
|
-
@category.scheme.
|
372
|
+
expect(@category.scheme).to eq("http://example.org")
|
368
373
|
end
|
369
374
|
|
370
375
|
it "should have a label" do
|
371
|
-
@category.label.
|
376
|
+
expect(@category.label).to eq("Atom")
|
372
377
|
end
|
373
378
|
end
|
374
379
|
|
@@ -378,15 +383,15 @@ describe Atom do
|
|
378
383
|
end
|
379
384
|
|
380
385
|
it "should have a term" do
|
381
|
-
@category.term.
|
386
|
+
expect(@category.term).to eq("drafts")
|
382
387
|
end
|
383
388
|
|
384
389
|
it "should have a scheme" do
|
385
|
-
@category.scheme.
|
390
|
+
expect(@category.scheme).to eq("http://example2.org")
|
386
391
|
end
|
387
392
|
|
388
393
|
it "should have a label" do
|
389
|
-
@category.label.
|
394
|
+
expect(@category.label).to eq("Drafts")
|
390
395
|
end
|
391
396
|
end
|
392
397
|
end
|
@@ -399,23 +404,23 @@ describe Atom do
|
|
399
404
|
end
|
400
405
|
|
401
406
|
it "should have text/html type" do
|
402
|
-
@link.type.
|
407
|
+
expect(@link.type).to eq('text/html')
|
403
408
|
end
|
404
409
|
|
405
410
|
it "should have alternate rel" do
|
406
|
-
@link.rel.
|
411
|
+
expect(@link.rel).to eq('alternate')
|
407
412
|
end
|
408
413
|
|
409
414
|
it "should have href 'http://example.org/2005/04/02/atom'" do
|
410
|
-
@link.href.
|
415
|
+
expect(@link.href).to eq('http://example.org/2005/04/02/atom')
|
411
416
|
end
|
412
417
|
|
413
418
|
it "should have 'http://example.org/2005/04/02/atom' string representation" do
|
414
|
-
@link.to_s.
|
419
|
+
expect(@link.to_s).to eq('http://example.org/2005/04/02/atom')
|
415
420
|
end
|
416
421
|
|
417
422
|
it "should have title 'Alternate link'" do
|
418
|
-
@link.title.
|
423
|
+
expect(@link.title).to eq("Alternate link")
|
419
424
|
end
|
420
425
|
end
|
421
426
|
|
@@ -426,23 +431,23 @@ describe Atom do
|
|
426
431
|
end
|
427
432
|
|
428
433
|
it "should have audio/mpeg type" do
|
429
|
-
@link.type.
|
434
|
+
expect(@link.type).to eq('audio/mpeg')
|
430
435
|
end
|
431
436
|
|
432
437
|
it "should have enclosure rel" do
|
433
|
-
@link.rel.
|
438
|
+
expect(@link.rel).to eq('enclosure')
|
434
439
|
end
|
435
440
|
|
436
441
|
it "should have length 1337" do
|
437
|
-
@link.length.
|
442
|
+
expect(@link.length).to eq(1337)
|
438
443
|
end
|
439
444
|
|
440
445
|
it "should have href 'http://example.org/audio/ph34r_my_podcast.mp3'" do
|
441
|
-
@link.href.
|
446
|
+
expect(@link.href).to eq('http://example.org/audio/ph34r_my_podcast.mp3')
|
442
447
|
end
|
443
448
|
|
444
449
|
it "should have 'http://example.org/audio/ph34r_my_podcast.mp3' string representation" do
|
445
|
-
@link.to_s.
|
450
|
+
expect(@link.to_s).to eq('http://example.org/audio/ph34r_my_podcast.mp3')
|
446
451
|
end
|
447
452
|
end
|
448
453
|
end
|
@@ -454,15 +459,15 @@ describe Atom do
|
|
454
459
|
end
|
455
460
|
|
456
461
|
it "should have a name" do
|
457
|
-
@person.name.
|
462
|
+
expect(@person.name).to eq('Mark Pilgrim')
|
458
463
|
end
|
459
464
|
|
460
465
|
it "should have a uri" do
|
461
|
-
@person.uri.
|
466
|
+
expect(@person.uri).to eq('http://example.org/')
|
462
467
|
end
|
463
468
|
|
464
469
|
it "should have an email address" do
|
465
|
-
@person.email.
|
470
|
+
expect(@person.email).to eq('f8dy@example.com')
|
466
471
|
end
|
467
472
|
end
|
468
473
|
|
@@ -473,15 +478,15 @@ describe Atom do
|
|
473
478
|
end
|
474
479
|
|
475
480
|
it "should have 'xhtml' type" do
|
476
|
-
@content.type.
|
481
|
+
expect(@content.type).to eq('xhtml')
|
477
482
|
end
|
478
483
|
|
479
484
|
it "should have 'en' language" do
|
480
|
-
@content.xml_lang.
|
485
|
+
expect(@content.xml_lang).to eq('en')
|
481
486
|
end
|
482
487
|
|
483
488
|
it "should have the content as the string representation" do
|
484
|
-
@content.
|
489
|
+
expect(@content).to eq('<p xmlns="http://www.w3.org/1999/xhtml"><i>[Update: The Atom draft is finished.]</i></p>')
|
485
490
|
end
|
486
491
|
end
|
487
492
|
end
|
@@ -493,11 +498,11 @@ describe Atom do
|
|
493
498
|
end
|
494
499
|
|
495
500
|
it "should have a title" do
|
496
|
-
@feed.title.
|
501
|
+
expect(@feed.title).to eq('Non-default namespace test')
|
497
502
|
end
|
498
503
|
|
499
504
|
it "should have 1 entry" do
|
500
|
-
@feed.
|
505
|
+
expect(@feed.entries.size).to eq(1)
|
501
506
|
end
|
502
507
|
|
503
508
|
describe Atom::Entry do
|
@@ -506,28 +511,28 @@ describe Atom do
|
|
506
511
|
end
|
507
512
|
|
508
513
|
it "should have a title" do
|
509
|
-
@entry.title.
|
514
|
+
expect(@entry.title).to eq('If you can read the content of this entry, your aggregator works fine.')
|
510
515
|
end
|
511
516
|
|
512
517
|
it "should have content" do
|
513
|
-
@entry.content.
|
518
|
+
expect(@entry.content).not_to be_nil
|
514
519
|
end
|
515
520
|
|
516
521
|
it "should have 'xhtml' for the type of the content" do
|
517
|
-
@entry.content.type.
|
522
|
+
expect(@entry.content.type).to eq('xhtml')
|
518
523
|
end
|
519
524
|
|
520
525
|
it "should strip the outer div of the content" do
|
521
|
-
@entry.content.
|
526
|
+
expect(@entry.content).not_to match(/div/)
|
522
527
|
end
|
523
528
|
|
524
529
|
it "should keep inner xhtml of content" do
|
525
|
-
@entry.content.
|
530
|
+
expect(@entry.content).to eq('<p xmlns="http://www.w3.org/1999/xhtml">For information, see:</p> ' +
|
526
531
|
'<ul xmlns="http://www.w3.org/1999/xhtml"> ' +
|
527
532
|
'<li><a href="http://plasmasturm.org/log/376/">Who knows an <abbr title="Extensible Markup Language">XML</abbr> document from a hole in the ground?</a></li> ' +
|
528
533
|
'<li><a href="http://plasmasturm.org/log/377/">More on Atom aggregator <abbr title="Extensible Markup Language">XML</abbr> namespace conformance tests</a></li> ' +
|
529
534
|
'<li><a href="http://www.intertwingly.net/wiki/pie/XmlNamespaceConformanceTests"><abbr title="Extensible Markup Language">XML</abbr> Namespace Conformance Tests</a></li> ' +
|
530
|
-
'</ul>'
|
535
|
+
'</ul>')
|
531
536
|
end
|
532
537
|
end
|
533
538
|
end
|
@@ -540,20 +545,20 @@ describe Atom do
|
|
540
545
|
end
|
541
546
|
|
542
547
|
it "should have content" do
|
543
|
-
@content.
|
548
|
+
expect(@content).not_to be_nil
|
544
549
|
end
|
545
550
|
|
546
551
|
it "should strip surrounding div" do
|
547
|
-
@content.
|
552
|
+
expect(@content).not_to match(/div/)
|
548
553
|
end
|
549
554
|
|
550
555
|
it "should keep inner lists" do
|
551
|
-
@content.
|
552
|
-
@content.
|
556
|
+
expect(@content).to match(/<h:ul/)
|
557
|
+
expect(@content).to match(/<ul/)
|
553
558
|
end
|
554
559
|
|
555
560
|
it "should have xhtml type" do
|
556
|
-
@content.type.
|
561
|
+
expect(@content.type).to eq('xhtml')
|
557
562
|
end
|
558
563
|
end
|
559
564
|
|
@@ -569,7 +574,7 @@ describe Atom do
|
|
569
574
|
end
|
570
575
|
|
571
576
|
it "should pick single alternate link without rel" do
|
572
|
-
@entry.alternate.href.
|
577
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/linktests/alternate')
|
573
578
|
end
|
574
579
|
end
|
575
580
|
|
@@ -579,11 +584,11 @@ describe Atom do
|
|
579
584
|
end
|
580
585
|
|
581
586
|
it "should be picky about case of alternate rel" do
|
582
|
-
@entry.alternate.href.
|
587
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/linktests/alternate')
|
583
588
|
end
|
584
589
|
|
585
590
|
it "should be picky when picking the alternate by type" do
|
586
|
-
@entry.alternate('text/plain').href.
|
591
|
+
expect(@entry.alternate('text/plain').href).to eq('http://www.snellspace.com/public/linktests/alternate2')
|
587
592
|
end
|
588
593
|
end
|
589
594
|
|
@@ -593,11 +598,11 @@ describe Atom do
|
|
593
598
|
end
|
594
599
|
|
595
600
|
it "should parse all links" do
|
596
|
-
@entry.
|
601
|
+
expect(@entry.links.size).to eq(5)
|
597
602
|
end
|
598
603
|
|
599
604
|
it "should pick the alternate from a full list of core types" do
|
600
|
-
@entry.alternate.href.
|
605
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/linktests/alternate')
|
601
606
|
end
|
602
607
|
end
|
603
608
|
|
@@ -607,15 +612,15 @@ describe Atom do
|
|
607
612
|
end
|
608
613
|
|
609
614
|
it "should parse all links" do
|
610
|
-
@entry.
|
615
|
+
expect(@entry.links.size).to eq(6)
|
611
616
|
end
|
612
617
|
|
613
618
|
it "should pick the first alternate from a full list of core types with an extra alternate" do
|
614
|
-
@entry.alternate.href.
|
619
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/linktests/alternate')
|
615
620
|
end
|
616
621
|
|
617
622
|
it "should pick the alternate by type from a full list of core types with an extra alternate" do
|
618
|
-
@entry.alternate('text/plain').href.
|
623
|
+
expect(@entry.alternate('text/plain').href).to eq('http://www.snellspace.com/public/linktests/alternate2')
|
619
624
|
end
|
620
625
|
end
|
621
626
|
|
@@ -625,15 +630,15 @@ describe Atom do
|
|
625
630
|
end
|
626
631
|
|
627
632
|
it "should parse all links" do
|
628
|
-
@entry.
|
633
|
+
expect(@entry.links.size).to eq(2)
|
629
634
|
end
|
630
635
|
|
631
636
|
it "should pick the alternate without choking on a non-core type" do
|
632
|
-
@entry.alternate.href.
|
637
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/linktests/alternate')
|
633
638
|
end
|
634
639
|
|
635
640
|
it "should include the non-core type in the list of links" do
|
636
|
-
@entry.links.map{|l| l.href }.
|
641
|
+
expect(@entry.links.map{|l| l.href }).to include('http://www.snellspace.com/public/linktests/license')
|
637
642
|
end
|
638
643
|
end
|
639
644
|
|
@@ -643,15 +648,15 @@ describe Atom do
|
|
643
648
|
end
|
644
649
|
|
645
650
|
it "should parse all links" do
|
646
|
-
@entry.
|
651
|
+
expect(@entry.links.size).to eq(2)
|
647
652
|
end
|
648
653
|
|
649
654
|
it "should pick the alternate without choking on a non-core type identified by a uri" do
|
650
|
-
@entry.alternate.href.
|
655
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/linktests/alternate')
|
651
656
|
end
|
652
657
|
|
653
658
|
it "should include the non-core type in the list of links identified by a uri" do
|
654
|
-
@entry.links.map{|l| l.href }.
|
659
|
+
expect(@entry.links.map{|l| l.href }).to include('http://www.snellspace.com/public/linktests/example')
|
655
660
|
end
|
656
661
|
end
|
657
662
|
|
@@ -661,15 +666,15 @@ describe Atom do
|
|
661
666
|
end
|
662
667
|
|
663
668
|
it "should parse all links" do
|
664
|
-
@entry.
|
669
|
+
expect(@entry.links.size).to eq(2)
|
665
670
|
end
|
666
671
|
|
667
672
|
it "should pick the alternate without choking on a non-core type" do
|
668
|
-
@entry.alternate.href.
|
673
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/linktests/alternate')
|
669
674
|
end
|
670
675
|
|
671
676
|
it "should include the non-core type in the list of links" do
|
672
|
-
@entry.links.map{|l| l.href }.
|
677
|
+
expect(@entry.links.map{|l| l.href }).to include('http://www.snellspace.com/public/linktests/license')
|
673
678
|
end
|
674
679
|
end
|
675
680
|
|
@@ -679,15 +684,15 @@ describe Atom do
|
|
679
684
|
end
|
680
685
|
|
681
686
|
it "should parse all links" do
|
682
|
-
@entry.
|
687
|
+
expect(@entry.links.size).to eq(2)
|
683
688
|
end
|
684
689
|
|
685
690
|
it "should pick the alternate without choking on a non-core type identified by a uri" do
|
686
|
-
@entry.alternate.href.
|
691
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/linktests/alternate')
|
687
692
|
end
|
688
693
|
|
689
694
|
it "should include the non-core type in the list of links identified by a uri" do
|
690
|
-
@entry.links.map{|l| l.href }.
|
695
|
+
expect(@entry.links.map{|l| l.href }).to include('http://www.snellspace.com/public/linktests/example')
|
691
696
|
end
|
692
697
|
end
|
693
698
|
|
@@ -697,11 +702,11 @@ describe Atom do
|
|
697
702
|
end
|
698
703
|
|
699
704
|
it "should parse all links" do
|
700
|
-
@entry.
|
705
|
+
expect(@entry.links.size).to eq(3)
|
701
706
|
end
|
702
707
|
|
703
708
|
it "should pick the alternate without hreflang" do
|
704
|
-
@entry.alternate.href.
|
709
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/linktests/alternate')
|
705
710
|
end
|
706
711
|
end
|
707
712
|
end
|
@@ -712,7 +717,7 @@ describe Atom do
|
|
712
717
|
end
|
713
718
|
|
714
719
|
it 'should have 9 entries' do
|
715
|
-
@feed.
|
720
|
+
expect(@feed.entries.size).to eq(9)
|
716
721
|
end
|
717
722
|
|
718
723
|
describe 'ordertest1' do
|
@@ -721,7 +726,7 @@ describe Atom do
|
|
721
726
|
end
|
722
727
|
|
723
728
|
it "should have the correct title" do
|
724
|
-
@entry.title.
|
729
|
+
expect(@entry.title).to eq('Simple order, nothing fancy')
|
725
730
|
end
|
726
731
|
end
|
727
732
|
|
@@ -731,7 +736,7 @@ describe Atom do
|
|
731
736
|
end
|
732
737
|
|
733
738
|
it "should have the correct title" do
|
734
|
-
@entry.title.
|
739
|
+
expect(@entry.title).to eq('Same as the first, only mixed up a bit')
|
735
740
|
end
|
736
741
|
end
|
737
742
|
|
@@ -741,11 +746,11 @@ describe Atom do
|
|
741
746
|
end
|
742
747
|
|
743
748
|
it "should have the correct title" do
|
744
|
-
@entry.title.
|
749
|
+
expect(@entry.title).to eq('Multiple alt link elements, which one does your reader show?')
|
745
750
|
end
|
746
751
|
|
747
752
|
it "should pick the first alternate" do
|
748
|
-
@entry.alternate.href.
|
753
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/alternate')
|
749
754
|
end
|
750
755
|
end
|
751
756
|
|
@@ -755,11 +760,11 @@ describe Atom do
|
|
755
760
|
end
|
756
761
|
|
757
762
|
it "should have the correct title" do
|
758
|
-
@entry.title.
|
763
|
+
expect(@entry.title).to eq('Multiple link elements, does your feed reader show the "alternate" correctly?')
|
759
764
|
end
|
760
765
|
|
761
766
|
it "should pick the right link" do
|
762
|
-
@entry.alternate.href.
|
767
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/alternate')
|
763
768
|
end
|
764
769
|
end
|
765
770
|
|
@@ -769,19 +774,19 @@ describe Atom do
|
|
769
774
|
end
|
770
775
|
|
771
776
|
it "should have a source" do
|
772
|
-
@entry.source.
|
777
|
+
expect(@entry.source).not_to be_nil
|
773
778
|
end
|
774
779
|
|
775
780
|
it "should have the correct title" do
|
776
|
-
@entry.title.
|
781
|
+
expect(@entry.title).to eq('Entry with a source first')
|
777
782
|
end
|
778
783
|
|
779
784
|
it "should have the correct updated" do
|
780
|
-
@entry.updated.
|
785
|
+
expect(@entry.updated).to eq(Time.parse('2006-01-26T09:20:05Z'))
|
781
786
|
end
|
782
787
|
|
783
788
|
it "should have the correct alt link" do
|
784
|
-
@entry.alternate.href.
|
789
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/alternate')
|
785
790
|
end
|
786
791
|
|
787
792
|
describe Atom::Source do
|
@@ -790,39 +795,39 @@ describe Atom do
|
|
790
795
|
end
|
791
796
|
|
792
797
|
it "should have an id" do
|
793
|
-
@source.id.
|
798
|
+
expect(@source.id).to eq('tag:example.org,2006:atom/conformance/element_order')
|
794
799
|
end
|
795
800
|
|
796
801
|
it "should have a title" do
|
797
|
-
@source.title.
|
802
|
+
expect(@source.title).to eq('Order Matters')
|
798
803
|
end
|
799
804
|
|
800
805
|
it "should have a subtitle" do
|
801
|
-
@source.subtitle.
|
806
|
+
expect(@source.subtitle).to eq('Testing how feed readers handle the order of entry elements')
|
802
807
|
end
|
803
808
|
|
804
809
|
it "should have a updated" do
|
805
|
-
@source.updated.
|
810
|
+
expect(@source.updated).to eq(Time.parse('2006-01-26T09:16:00Z'))
|
806
811
|
end
|
807
812
|
|
808
813
|
it "should have an author" do
|
809
|
-
@source.
|
814
|
+
expect(@source.authors.size).to eq(1)
|
810
815
|
end
|
811
816
|
|
812
817
|
it "should have the right name for the author" do
|
813
|
-
@source.authors.first.name.
|
818
|
+
expect(@source.authors.first.name).to eq('James Snell')
|
814
819
|
end
|
815
820
|
|
816
821
|
it "should have 2 links" do
|
817
|
-
@source.
|
822
|
+
expect(@source.links.size).to eq(2)
|
818
823
|
end
|
819
824
|
|
820
825
|
it "should have an alternate" do
|
821
|
-
@source.alternate.href.
|
826
|
+
expect(@source.alternate.href).to eq('http://www.snellspace.com/wp/?p=255')
|
822
827
|
end
|
823
828
|
|
824
829
|
it "should have a self" do
|
825
|
-
@source.self.href.
|
830
|
+
expect(@source.self.href).to eq('http://www.snellspace.com/public/ordertest.xml')
|
826
831
|
end
|
827
832
|
end
|
828
833
|
end
|
@@ -833,19 +838,19 @@ describe Atom do
|
|
833
838
|
end
|
834
839
|
|
835
840
|
it "should have a source" do
|
836
|
-
@entry.source.
|
841
|
+
expect(@entry.source).not_to be_nil
|
837
842
|
end
|
838
843
|
|
839
844
|
it "should have the correct title" do
|
840
|
-
@entry.title.
|
845
|
+
expect(@entry.title).to eq('Entry with a source last')
|
841
846
|
end
|
842
847
|
|
843
848
|
it "should have the correct updated" do
|
844
|
-
@entry.updated.
|
849
|
+
expect(@entry.updated).to eq(Time.parse('2006-01-26T09:20:06Z'))
|
845
850
|
end
|
846
851
|
|
847
852
|
it "should have the correct alt link" do
|
848
|
-
@entry.alternate.href.
|
853
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/alternate')
|
849
854
|
end
|
850
855
|
end
|
851
856
|
|
@@ -855,19 +860,19 @@ describe Atom do
|
|
855
860
|
end
|
856
861
|
|
857
862
|
it "should have a source" do
|
858
|
-
@entry.source.
|
863
|
+
expect(@entry.source).not_to be_nil
|
859
864
|
end
|
860
865
|
|
861
866
|
it "should have the correct title" do
|
862
|
-
@entry.title.
|
867
|
+
expect(@entry.title).to eq('Entry with a source in the middle')
|
863
868
|
end
|
864
869
|
|
865
870
|
it "should have the correct updated" do
|
866
|
-
@entry.updated.
|
871
|
+
expect(@entry.updated).to eq(Time.parse('2006-01-26T09:20:07Z'))
|
867
872
|
end
|
868
873
|
|
869
874
|
it "should have the correct alt link" do
|
870
|
-
@entry.alternate.href.
|
875
|
+
expect(@entry.alternate.href).to eq('http://www.snellspace.com/public/alternate')
|
871
876
|
end
|
872
877
|
end
|
873
878
|
|
@@ -877,11 +882,11 @@ describe Atom do
|
|
877
882
|
end
|
878
883
|
|
879
884
|
it "should have the right title" do
|
880
|
-
@entry.title.
|
885
|
+
expect(@entry.title).to eq('Atom elements in an extension element')
|
881
886
|
end
|
882
887
|
|
883
888
|
it "should have right id" do
|
884
|
-
@entry.id.
|
889
|
+
expect(@entry.id).to eq('tag:example.org,2006:atom/conformance/element_order/8')
|
885
890
|
end
|
886
891
|
end
|
887
892
|
|
@@ -891,11 +896,11 @@ describe Atom do
|
|
891
896
|
end
|
892
897
|
|
893
898
|
it "should have the right title" do
|
894
|
-
@entry.title.
|
899
|
+
expect(@entry.title).to eq('Atom elements in an extension element')
|
895
900
|
end
|
896
901
|
|
897
902
|
it 'should have the right id' do
|
898
|
-
@entry.id.
|
903
|
+
expect(@entry.id).to eq('tag:example.org,2006:atom/conformance/element_order/9')
|
899
904
|
end
|
900
905
|
end
|
901
906
|
end
|
@@ -910,7 +915,7 @@ describe Atom do
|
|
910
915
|
end
|
911
916
|
|
912
917
|
def validate_against_atom_rng
|
913
|
-
@schema.validate(Nokogiri::XML(subject.to_xml.to_s)).
|
918
|
+
expect(@schema.validate(Nokogiri::XML(subject.to_xml.to_s))).to eq([])
|
914
919
|
end
|
915
920
|
|
916
921
|
subject do
|
@@ -933,7 +938,7 @@ describe Atom do
|
|
933
938
|
end
|
934
939
|
|
935
940
|
it 'should validate against a feed with simple extensions' do
|
936
|
-
|
941
|
+
skip 'Does not conform yet - see seangeo/ratom#21'
|
937
942
|
# Mark feed as complete
|
938
943
|
subject['http://purl.org/syndication/history/1.0', 'complete'] << ''
|
939
944
|
validate_against_atom_rng
|
@@ -950,27 +955,27 @@ describe Atom do
|
|
950
955
|
end
|
951
956
|
|
952
957
|
it "should be first?" do
|
953
|
-
@feed.
|
958
|
+
expect(@feed).to be_first
|
954
959
|
end
|
955
960
|
|
956
961
|
it "should not be last?" do
|
957
|
-
@feed.
|
962
|
+
expect(@feed).not_to be_last
|
958
963
|
end
|
959
964
|
|
960
965
|
it "should have next" do
|
961
|
-
@feed.next_page.href.
|
966
|
+
expect(@feed.next_page.href).to eq('http://example.org/index.atom?page=2')
|
962
967
|
end
|
963
968
|
|
964
969
|
it "should not have prev" do
|
965
|
-
@feed.prev_page.
|
970
|
+
expect(@feed.prev_page).to be_nil
|
966
971
|
end
|
967
972
|
|
968
973
|
it "should have last" do
|
969
|
-
@feed.last_page.href.
|
974
|
+
expect(@feed.last_page.href).to eq('http://example.org/index.atom?page=10')
|
970
975
|
end
|
971
976
|
|
972
977
|
it "should have first" do
|
973
|
-
@feed.first_page.href.
|
978
|
+
expect(@feed.first_page.href).to eq('http://example.org/index.atom')
|
974
979
|
end
|
975
980
|
end
|
976
981
|
|
@@ -980,27 +985,27 @@ describe Atom do
|
|
980
985
|
end
|
981
986
|
|
982
987
|
it "should not be last?" do
|
983
|
-
@feed.
|
988
|
+
expect(@feed).not_to be_last
|
984
989
|
end
|
985
990
|
|
986
991
|
it "should not be first?" do
|
987
|
-
@feed.
|
992
|
+
expect(@feed).not_to be_first
|
988
993
|
end
|
989
994
|
|
990
995
|
it "should have next_page" do
|
991
|
-
@feed.next_page.href.
|
996
|
+
expect(@feed.next_page.href).to eq('http://example.org/index.atom?page=4')
|
992
997
|
end
|
993
998
|
|
994
999
|
it "should have prev_page" do
|
995
|
-
@feed.prev_page.href.
|
1000
|
+
expect(@feed.prev_page.href).to eq('http://example.org/index.atom?page=2')
|
996
1001
|
end
|
997
1002
|
|
998
1003
|
it "should have last_page" do
|
999
|
-
@feed.last_page.href.
|
1004
|
+
expect(@feed.last_page.href).to eq('http://example.org/index.atom?page=10')
|
1000
1005
|
end
|
1001
1006
|
|
1002
1007
|
it "should have first_page" do
|
1003
|
-
@feed.first_page.href.
|
1008
|
+
expect(@feed.first_page.href).to eq('http://example.org/index.atom')
|
1004
1009
|
end
|
1005
1010
|
end
|
1006
1011
|
|
@@ -1010,27 +1015,27 @@ describe Atom do
|
|
1010
1015
|
end
|
1011
1016
|
|
1012
1017
|
it "should not be first?" do
|
1013
|
-
@feed.
|
1018
|
+
expect(@feed).not_to be_first
|
1014
1019
|
end
|
1015
1020
|
|
1016
1021
|
it "should be last?" do
|
1017
|
-
@feed.
|
1022
|
+
expect(@feed).to be_last
|
1018
1023
|
end
|
1019
1024
|
|
1020
1025
|
it "should have prev_page" do
|
1021
|
-
@feed.prev_page.href.
|
1026
|
+
expect(@feed.prev_page.href).to eq('http://example.org/index.atom?page=9')
|
1022
1027
|
end
|
1023
1028
|
|
1024
1029
|
it "should not have next_page" do
|
1025
|
-
@feed.next_page.
|
1030
|
+
expect(@feed.next_page).to be_nil
|
1026
1031
|
end
|
1027
1032
|
|
1028
1033
|
it "should have first_page" do
|
1029
|
-
@feed.first_page.href.
|
1034
|
+
expect(@feed.first_page.href).to eq('http://example.org/index.atom')
|
1030
1035
|
end
|
1031
1036
|
|
1032
1037
|
it "should have last_page" do
|
1033
|
-
@feed.last_page.href.
|
1038
|
+
expect(@feed.last_page.href).to eq('http://example.org/index.atom?page=10')
|
1034
1039
|
end
|
1035
1040
|
end
|
1036
1041
|
|
@@ -1043,10 +1048,10 @@ describe Atom do
|
|
1043
1048
|
feed1 = Atom::Feed.load_feed(File.read('spec/paging/middle_paged_feed.atom'))
|
1044
1049
|
feed2 = Atom::Feed.load_feed(File.read('spec/paging/last_paged_feed.atom'))
|
1045
1050
|
|
1046
|
-
Atom::Feed.
|
1051
|
+
expect(Atom::Feed).to receive(:load_feed).
|
1047
1052
|
with(URI.parse('http://example.org/index.atom?page=2'), an_instance_of(Hash)).
|
1048
1053
|
and_return(feed1)
|
1049
|
-
Atom::Feed.
|
1054
|
+
expect(Atom::Feed).to receive(:load_feed).
|
1050
1055
|
with(URI.parse('http://example.org/index.atom?page=4'), an_instance_of(Hash)).
|
1051
1056
|
and_return(feed2)
|
1052
1057
|
|
@@ -1055,7 +1060,7 @@ describe Atom do
|
|
1055
1060
|
entry_count += 1
|
1056
1061
|
end
|
1057
1062
|
|
1058
|
-
entry_count.
|
1063
|
+
expect(entry_count).to eq(3)
|
1059
1064
|
end
|
1060
1065
|
|
1061
1066
|
it "should not paginate through each entry when paginate not true" do
|
@@ -1064,12 +1069,12 @@ describe Atom do
|
|
1064
1069
|
entry_count += 1
|
1065
1070
|
end
|
1066
1071
|
|
1067
|
-
entry_count.
|
1072
|
+
expect(entry_count).to eq(1)
|
1068
1073
|
end
|
1069
1074
|
|
1070
1075
|
it "should only paginate up to since" do
|
1071
1076
|
response1 = Net::HTTPSuccess.new(nil, nil, nil)
|
1072
|
-
response1.
|
1077
|
+
allow(response1).to receive(:body).and_return(File.read('spec/paging/middle_paged_feed.atom'))
|
1073
1078
|
mock_http_get(URI.parse('http://example.org/index.atom?page=2'), response1)
|
1074
1079
|
|
1075
1080
|
entry_count = 0
|
@@ -1077,7 +1082,7 @@ describe Atom do
|
|
1077
1082
|
entry_count += 1
|
1078
1083
|
end
|
1079
1084
|
|
1080
|
-
entry_count.
|
1085
|
+
expect(entry_count).to eq(1)
|
1081
1086
|
end
|
1082
1087
|
end
|
1083
1088
|
|
@@ -1088,45 +1093,45 @@ describe Atom do
|
|
1088
1093
|
end
|
1089
1094
|
|
1090
1095
|
it "should load simple extension for feed" do
|
1091
|
-
@feed["http://example.org/example", 'simple1'].
|
1096
|
+
expect(@feed["http://example.org/example", 'simple1']).to eq(['Simple1 Value'])
|
1092
1097
|
end
|
1093
1098
|
|
1094
1099
|
it "should load empty simple extension for feed" do
|
1095
|
-
@feed["http://example.org/example", 'simple-empty'].
|
1100
|
+
expect(@feed["http://example.org/example", 'simple-empty']).to eq([''])
|
1096
1101
|
end
|
1097
1102
|
|
1098
1103
|
it "should load simple extension 1 for entry" do
|
1099
|
-
@entry["http://example.org/example", 'simple1'].
|
1104
|
+
expect(@entry["http://example.org/example", 'simple1']).to eq(['Simple1 Entry Value'])
|
1100
1105
|
end
|
1101
1106
|
|
1102
1107
|
it "should load simple extension 2 for entry" do
|
1103
|
-
@entry["http://example.org/example", 'simple2'].
|
1108
|
+
expect(@entry["http://example.org/example", 'simple2']).to eq(['Simple2', 'Simple2a'])
|
1104
1109
|
end
|
1105
1110
|
|
1106
1111
|
it "should find a simple extension in another namespace" do
|
1107
|
-
@entry["http://example2.org/example2", 'simple1'].
|
1112
|
+
expect(@entry["http://example2.org/example2", 'simple1']).to eq(['Simple Entry Value (NS2)'])
|
1108
1113
|
end
|
1109
1114
|
|
1110
1115
|
it "should load simple extension attribute on a category" do
|
1111
|
-
@entry.categories.first["http://example.org/example", "attribute"].first.
|
1116
|
+
expect(@entry.categories.first["http://example.org/example", "attribute"].first).to eq("extension")
|
1112
1117
|
end
|
1113
1118
|
|
1114
1119
|
it "should write a simple extension attribute as an attribute" do
|
1115
|
-
@entry.categories.first.to_xml.root['ns1:attribute'].
|
1120
|
+
expect(@entry.categories.first.to_xml.root['ns1:attribute']).to eq('extension')
|
1116
1121
|
end
|
1117
1122
|
|
1118
1123
|
it "should read an extension with the same local name as an Atom element" do
|
1119
|
-
@feed['http://example.org/example', 'title'].
|
1124
|
+
expect(@feed['http://example.org/example', 'title']).to eq(['Extension Title'])
|
1120
1125
|
end
|
1121
1126
|
|
1122
1127
|
it "should find simple extension with dashes in the name" do
|
1123
|
-
@entry["http://example.org/example", 'simple-with-dash'].
|
1128
|
+
expect(@entry["http://example.org/example", 'simple-with-dash']).to eq(['Simple with dash Value'])
|
1124
1129
|
end
|
1125
1130
|
|
1126
1131
|
it_should_behave_like 'simple_single_entry.atom attributes'
|
1127
1132
|
|
1128
1133
|
it "should load simple extension 3 xml for entry" do
|
1129
|
-
@entry["http://example.org/example3", 'simple3'].
|
1134
|
+
expect(@entry["http://example.org/example3", 'simple3']).to eq(['<ContinuityOfCareRecord xmlns="urn:astm-org:CCR">Simple Entry Value (NS2)</ContinuityOfCareRecord>'])
|
1130
1135
|
end
|
1131
1136
|
|
1132
1137
|
describe "when only namespace is provided" do
|
@@ -1137,19 +1142,19 @@ describe Atom do
|
|
1137
1142
|
end
|
1138
1143
|
|
1139
1144
|
it "should return namespace elements as a hash" do
|
1140
|
-
@example_elements.
|
1145
|
+
expect(@example_elements).to eq({
|
1141
1146
|
'simple1' => ['Simple1 Entry Value'],
|
1142
1147
|
'simple2' => ['Simple2', 'Simple2a'],
|
1143
1148
|
'simple-with-dash' => ["Simple with dash Value"]
|
1144
|
-
}
|
1149
|
+
})
|
1145
1150
|
|
1146
|
-
@example2_elements.
|
1151
|
+
expect(@example2_elements).to eq({
|
1147
1152
|
'simple1' => ['Simple Entry Value (NS2)']
|
1148
|
-
}
|
1153
|
+
})
|
1149
1154
|
|
1150
|
-
@example3_elements.
|
1155
|
+
expect(@example3_elements).to eq({
|
1151
1156
|
'simple3' => ['<ContinuityOfCareRecord xmlns="urn:astm-org:CCR">Simple Entry Value (NS2)</ContinuityOfCareRecord>']
|
1152
|
-
}
|
1157
|
+
})
|
1153
1158
|
end
|
1154
1159
|
end
|
1155
1160
|
end
|
@@ -1164,7 +1169,7 @@ describe Atom do
|
|
1164
1169
|
end
|
1165
1170
|
|
1166
1171
|
entry2 = Atom::Entry.load_entry(entry.to_xml.to_s)
|
1167
|
-
entry2['http://example.org', 'title'].
|
1172
|
+
expect(entry2['http://example.org', 'title']).to eq(['Example title'])
|
1168
1173
|
end
|
1169
1174
|
end
|
1170
1175
|
end
|
@@ -1178,15 +1183,15 @@ describe Atom do
|
|
1178
1183
|
end
|
1179
1184
|
|
1180
1185
|
it "should_load_custom_extensions_for_entry" do
|
1181
|
-
@entry.ns_alias_property.
|
1186
|
+
expect(@entry.ns_alias_property).not_to eq([])
|
1182
1187
|
end
|
1183
1188
|
|
1184
1189
|
it "should_load_2_custom_extensions_for_entry" do
|
1185
|
-
@entry.ns_alias_property.size.
|
1190
|
+
expect(@entry.ns_alias_property.size).to eq(2)
|
1186
1191
|
end
|
1187
1192
|
|
1188
1193
|
it "should load correct_data_for_custom_extensions_for_entry" do
|
1189
|
-
@entry.ns_alias_property.map { |x| [x.name, x.value] }.
|
1194
|
+
expect(@entry.ns_alias_property.map { |x| [x.name, x.value] }).to eq([['foo', 'bar'], ['baz', 'bat']])
|
1190
1195
|
end
|
1191
1196
|
end
|
1192
1197
|
|
@@ -1197,7 +1202,7 @@ describe Atom do
|
|
1197
1202
|
end
|
1198
1203
|
|
1199
1204
|
it "should parse content by specified content parser" do
|
1200
|
-
@entry.content.
|
1205
|
+
expect(@entry.content).to eq('<changes xmlns="http://www.xxx.com/app"/>')
|
1201
1206
|
end
|
1202
1207
|
end
|
1203
1208
|
|
@@ -1209,12 +1214,12 @@ describe Atom do
|
|
1209
1214
|
end
|
1210
1215
|
|
1211
1216
|
it "should load single custom extensions for entry" do
|
1212
|
-
@entry.custom_singleproperty.
|
1217
|
+
expect(@entry.custom_singleproperty).not_to be_nil
|
1213
1218
|
end
|
1214
1219
|
|
1215
1220
|
it "should load correct data for custom extensions for entry" do
|
1216
|
-
@entry.custom_singleproperty.name.
|
1217
|
-
@entry.custom_singleproperty.value.
|
1221
|
+
expect(@entry.custom_singleproperty.name).to eq('foo')
|
1222
|
+
expect(@entry.custom_singleproperty.value).to eq('bar')
|
1218
1223
|
end
|
1219
1224
|
end
|
1220
1225
|
|
@@ -1228,12 +1233,12 @@ describe Atom do
|
|
1228
1233
|
end
|
1229
1234
|
|
1230
1235
|
it "should_write_custom_extensions_on_to_xml" do
|
1231
|
-
@node.root.children.size.
|
1236
|
+
expect(@node.root.children.size).to eq(2)
|
1232
1237
|
ratom, custom_extensions = @node.root.children
|
1233
|
-
ratom.attributes["name"].value.
|
1234
|
-
ratom.attributes["value"].value.
|
1235
|
-
custom_extensions.attributes["name"].value.
|
1236
|
-
custom_extensions.attributes["value"].value.
|
1238
|
+
expect(ratom.attributes["name"].value).to eq("ratom")
|
1239
|
+
expect(ratom.attributes["value"].value).to eq("rocks")
|
1240
|
+
expect(custom_extensions.attributes["name"].value).to eq("custom extensions")
|
1241
|
+
expect(custom_extensions.attributes["value"].value).to eq("also rock")
|
1237
1242
|
end
|
1238
1243
|
end
|
1239
1244
|
|
@@ -1244,16 +1249,16 @@ describe Atom do
|
|
1244
1249
|
end
|
1245
1250
|
|
1246
1251
|
it "should fetch feed for fetch_next" do
|
1247
|
-
Atom::Feed.
|
1252
|
+
expect(Atom::Feed).to receive(:load_feed).with(URI.parse(@href), an_instance_of(Hash))
|
1248
1253
|
@link.fetch
|
1249
1254
|
end
|
1250
1255
|
|
1251
1256
|
it "should fetch content when response is not xml" do
|
1252
|
-
Atom::Feed.
|
1257
|
+
expect(Atom::Feed).to receive(:load_feed).and_raise(ArgumentError)
|
1253
1258
|
response = Net::HTTPSuccess.new(nil, nil, nil)
|
1254
|
-
response.
|
1255
|
-
Net::HTTP.
|
1256
|
-
@link.fetch.
|
1259
|
+
allow(response).to receive(:body).and_return('some text.')
|
1260
|
+
expect(Net::HTTP).to receive(:get_response).with(URI.parse(@href)).and_return(response)
|
1261
|
+
expect(@link.fetch).to eq('some text.')
|
1257
1262
|
end
|
1258
1263
|
end
|
1259
1264
|
|
@@ -1263,40 +1268,40 @@ describe Atom do
|
|
1263
1268
|
end
|
1264
1269
|
|
1265
1270
|
it "should be == to itself" do
|
1266
|
-
@entry.
|
1271
|
+
expect(@entry).to eq(Atom::Entry.load_entry(File.read('spec/fixtures/entry.atom')))
|
1267
1272
|
end
|
1268
1273
|
|
1269
1274
|
it "should be != if something changes" do
|
1270
1275
|
@other = Atom::Entry.load_entry(File.read('spec/fixtures/entry.atom'))
|
1271
1276
|
@other.title = 'foo'
|
1272
|
-
@entry.
|
1277
|
+
expect(@entry).not_to eq(@other)
|
1273
1278
|
end
|
1274
1279
|
|
1275
1280
|
it "should be != if content changes" do
|
1276
1281
|
@other = Atom::Entry.load_entry(File.read('spec/fixtures/entry.atom'))
|
1277
1282
|
@other.content.type = 'html'
|
1278
|
-
@entry.
|
1283
|
+
expect(@entry).not_to eq(@other)
|
1279
1284
|
end
|
1280
1285
|
|
1281
1286
|
it "should output itself" do
|
1282
1287
|
other = Atom::Entry.load_entry(@entry.to_xml.to_s)
|
1283
|
-
@entry.
|
1288
|
+
expect(@entry).to eq(other)
|
1284
1289
|
end
|
1285
1290
|
|
1286
1291
|
it "should properly escape titles" do
|
1287
1292
|
@entry.title = "Breaking Space"
|
1288
1293
|
other = Atom::Entry.load_entry(@entry.to_xml.to_s)
|
1289
|
-
@entry.
|
1294
|
+
expect(@entry).to eq(other)
|
1290
1295
|
end
|
1291
1296
|
|
1292
1297
|
it "should raise error when to_xml'ing non-utf8 content" do
|
1293
|
-
|
1298
|
+
expect {
|
1294
1299
|
puts(Atom::Entry.new do |entry|
|
1295
1300
|
entry.title = "My entry"
|
1296
1301
|
entry.id = "urn:entry:1"
|
1297
1302
|
entry.content = Atom::Content::Html.new("this is not \227 utf8")
|
1298
1303
|
end.to_xml)
|
1299
|
-
}.
|
1304
|
+
}.to raise_error(Atom::SerializationError)
|
1300
1305
|
end
|
1301
1306
|
|
1302
1307
|
it "should not raise error when to_xml'ing utf8 but non-ascii content" do
|
@@ -1306,99 +1311,99 @@ describe Atom do
|
|
1306
1311
|
entry.content = Atom::Content::Html.new("Žižek is utf8")
|
1307
1312
|
end.to_xml.to_s
|
1308
1313
|
|
1309
|
-
xml.
|
1314
|
+
expect(xml).to match(/Žižek/)
|
1310
1315
|
end
|
1311
1316
|
end
|
1312
1317
|
|
1313
1318
|
describe 'Atom::Feed initializer' do
|
1314
1319
|
it "should create an empty Feed" do
|
1315
|
-
|
1320
|
+
expect { Atom::Feed.new }.not_to raise_error
|
1316
1321
|
end
|
1317
1322
|
|
1318
1323
|
it "should yield to a block" do
|
1319
|
-
|
1324
|
+
expect do
|
1320
1325
|
Atom::Feed.new do |f|
|
1321
|
-
f.
|
1326
|
+
expect(f).to be_an_instance_of(Atom::Feed)
|
1322
1327
|
throw :yielded
|
1323
1328
|
end
|
1324
|
-
end.
|
1329
|
+
end.to throw_symbol(:yielded)
|
1325
1330
|
end
|
1326
1331
|
end
|
1327
1332
|
|
1328
1333
|
describe 'Atom::Entry initializer' do
|
1329
1334
|
it "should create an empty feed" do
|
1330
|
-
|
1335
|
+
expect { Atom::Entry.new }.not_to raise_error
|
1331
1336
|
end
|
1332
1337
|
|
1333
1338
|
it "should yield to a block" do
|
1334
|
-
|
1339
|
+
expect do
|
1335
1340
|
Atom::Entry.new do |f|
|
1336
|
-
f.
|
1341
|
+
expect(f).to be_an_instance_of(Atom::Entry)
|
1337
1342
|
throw :yielded
|
1338
1343
|
end
|
1339
|
-
end.
|
1344
|
+
end.to throw_symbol(:yielded)
|
1340
1345
|
end
|
1341
1346
|
end
|
1342
1347
|
|
1343
1348
|
describe Atom::Content::Html do
|
1344
1349
|
it "should escape ampersands in entities" do
|
1345
|
-
Atom::Content::Html.new(" ").to_xml.to_s.
|
1350
|
+
expect(Atom::Content::Html.new(" ").to_xml.to_s).to eq("<content type=\"html\">&nbsp;</content>")
|
1346
1351
|
end
|
1347
1352
|
end
|
1348
1353
|
|
1349
1354
|
describe Atom::Content::Text do
|
1350
1355
|
it "should be createable from a string" do
|
1351
1356
|
txt = Atom::Content::Text.new("This is some text")
|
1352
|
-
txt.
|
1353
|
-
txt.type.
|
1357
|
+
expect(txt).to eq("This is some text")
|
1358
|
+
expect(txt.type).to eq("text")
|
1354
1359
|
end
|
1355
1360
|
end
|
1356
1361
|
|
1357
1362
|
describe Atom::Content::Xhtml do
|
1358
1363
|
it "should be createable from a string" do
|
1359
1364
|
txt = Atom::Content::Xhtml.new("<p>This is some text</p>")
|
1360
|
-
txt.
|
1361
|
-
txt.type.
|
1365
|
+
expect(txt).to eq("<p>This is some text</p>")
|
1366
|
+
expect(txt.type).to eq("xhtml")
|
1362
1367
|
end
|
1363
1368
|
|
1364
1369
|
it "should be renderable to xml" do
|
1365
1370
|
txt = Atom::Content::Xhtml.new("<p>This is some text</p>")
|
1366
|
-
txt.to_xml.
|
1371
|
+
expect { txt.to_xml }.not_to raise_error
|
1367
1372
|
end
|
1368
1373
|
end
|
1369
1374
|
|
1370
1375
|
describe Atom::Content::External do
|
1371
1376
|
before(:each) do
|
1372
1377
|
feed = nil
|
1373
|
-
|
1378
|
+
expect { feed = Atom::Feed.load_feed(File.open('spec/fixtures/external_content_single_entry.atom')) }.not_to raise_error
|
1374
1379
|
entry = feed.entries.first
|
1375
|
-
entry.content.
|
1380
|
+
expect(entry.content).not_to be_nil
|
1376
1381
|
@content = entry.content
|
1377
|
-
@content.class.
|
1382
|
+
expect(@content.class).to eq(Atom::Content::External)
|
1378
1383
|
end
|
1379
1384
|
|
1380
1385
|
it "should capture the src" do
|
1381
|
-
@content.type.
|
1382
|
-
@content.src.
|
1386
|
+
expect(@content.type).to eq('application/pdf')
|
1387
|
+
expect(@content.src).to eq('http://example.org/pdfs/robots-run-amok.pdf')
|
1383
1388
|
end
|
1384
1389
|
|
1385
1390
|
it "should include type and src in the serialized xml" do
|
1386
1391
|
xml = @content.to_xml
|
1387
|
-
xml['type'].
|
1388
|
-
xml['src'].
|
1392
|
+
expect(xml['type']).to eq('application/pdf')
|
1393
|
+
expect(xml['src']).to eq('http://example.org/pdfs/robots-run-amok.pdf')
|
1389
1394
|
end
|
1390
1395
|
end
|
1391
1396
|
|
1392
1397
|
describe 'Atom::Category initializer' do
|
1393
1398
|
it "should create a empty category" do
|
1394
|
-
|
1399
|
+
expect { Atom::Category.new }.not_to raise_error
|
1395
1400
|
end
|
1396
1401
|
|
1397
1402
|
it "should create from a hash" do
|
1398
1403
|
category = Atom::Category.new(:term => 'term', :scheme => 'scheme', :label => 'label')
|
1399
|
-
category.term.
|
1400
|
-
category.scheme.
|
1401
|
-
category.label.
|
1404
|
+
expect(category.term).to eq('term')
|
1405
|
+
expect(category.scheme).to eq('scheme')
|
1406
|
+
expect(category.label).to eq('label')
|
1402
1407
|
end
|
1403
1408
|
|
1404
1409
|
it "should create from a block" do
|
@@ -1406,19 +1411,19 @@ describe Atom do
|
|
1406
1411
|
cat.term = 'term'
|
1407
1412
|
end
|
1408
1413
|
|
1409
|
-
category.term.
|
1414
|
+
expect(category.term).to eq('term')
|
1410
1415
|
end
|
1411
1416
|
end
|
1412
1417
|
|
1413
1418
|
describe Atom::Source do
|
1414
1419
|
it "should create an empty source" do
|
1415
|
-
|
1420
|
+
expect { Atom::Source.new }.not_to raise_error
|
1416
1421
|
end
|
1417
1422
|
|
1418
1423
|
it "should create from a hash" do
|
1419
1424
|
source = Atom::Source.new(:title => 'title', :id => 'sourceid')
|
1420
|
-
source.title.
|
1421
|
-
source.id.
|
1425
|
+
expect(source.title).to eq('title')
|
1426
|
+
expect(source.id).to eq('sourceid')
|
1422
1427
|
end
|
1423
1428
|
|
1424
1429
|
it "should create from a block" do
|
@@ -1426,20 +1431,20 @@ describe Atom do
|
|
1426
1431
|
source.title = 'title'
|
1427
1432
|
source.id = 'sourceid'
|
1428
1433
|
end
|
1429
|
-
source.title.
|
1430
|
-
source.id.
|
1434
|
+
expect(source.title).to eq('title')
|
1435
|
+
expect(source.id).to eq('sourceid')
|
1431
1436
|
end
|
1432
1437
|
end
|
1433
1438
|
|
1434
1439
|
describe Atom::Generator do
|
1435
1440
|
it "should create an empty generator" do
|
1436
|
-
|
1441
|
+
expect { Atom::Generator.new }.not_to raise_error
|
1437
1442
|
end
|
1438
1443
|
|
1439
1444
|
it "should create from a hash" do
|
1440
1445
|
generator = Atom::Generator.new(:name => 'generator', :uri => 'http://generator')
|
1441
|
-
generator.name.
|
1442
|
-
generator.uri.
|
1446
|
+
expect(generator.name).to eq('generator')
|
1447
|
+
expect(generator.uri).to eq('http://generator')
|
1443
1448
|
end
|
1444
1449
|
|
1445
1450
|
it "should create from a block" do
|
@@ -1447,13 +1452,13 @@ describe Atom do
|
|
1447
1452
|
generator.name = 'generator'
|
1448
1453
|
generator.uri = 'http://generator'
|
1449
1454
|
end
|
1450
|
-
generator.name.
|
1451
|
-
generator.uri.
|
1455
|
+
expect(generator.name).to eq('generator')
|
1456
|
+
expect(generator.uri).to eq('http://generator')
|
1452
1457
|
end
|
1453
1458
|
|
1454
1459
|
it "should output the name as the text of the generator element" do
|
1455
1460
|
generator = Atom::Generator.new({:name => "My Generator"})
|
1456
|
-
generator.to_xml.to_s.
|
1461
|
+
expect(generator.to_xml.to_s).to eq("<generator>My Generator</generator>")
|
1457
1462
|
end
|
1458
1463
|
end
|
1459
1464
|
end
|