ratom 0.7.2 → 0.8.0

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