nelumba 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/.gitignore +6 -0
  2. data/.travis.yml +9 -0
  3. data/Gemfile +20 -0
  4. data/README.md +242 -0
  5. data/Rakefile +7 -0
  6. data/assets/lotus_logo_purple.png +0 -0
  7. data/assets/lotus_logo_purple.svg +262 -0
  8. data/lib/nelumba.rb +47 -0
  9. data/lib/nelumba/activity.rb +250 -0
  10. data/lib/nelumba/application.rb +11 -0
  11. data/lib/nelumba/article.rb +11 -0
  12. data/lib/nelumba/atom/account.rb +50 -0
  13. data/lib/nelumba/atom/address.rb +56 -0
  14. data/lib/nelumba/atom/author.rb +176 -0
  15. data/lib/nelumba/atom/category.rb +41 -0
  16. data/lib/nelumba/atom/comment.rb +96 -0
  17. data/lib/nelumba/atom/entry.rb +216 -0
  18. data/lib/nelumba/atom/feed.rb +198 -0
  19. data/lib/nelumba/atom/generator.rb +40 -0
  20. data/lib/nelumba/atom/link.rb +79 -0
  21. data/lib/nelumba/atom/name.rb +57 -0
  22. data/lib/nelumba/atom/organization.rb +62 -0
  23. data/lib/nelumba/atom/person.rb +179 -0
  24. data/lib/nelumba/atom/portable_contacts.rb +117 -0
  25. data/lib/nelumba/atom/source.rb +179 -0
  26. data/lib/nelumba/atom/thread.rb +60 -0
  27. data/lib/nelumba/audio.rb +39 -0
  28. data/lib/nelumba/badge.rb +11 -0
  29. data/lib/nelumba/binary.rb +52 -0
  30. data/lib/nelumba/bookmark.rb +30 -0
  31. data/lib/nelumba/category.rb +49 -0
  32. data/lib/nelumba/collection.rb +34 -0
  33. data/lib/nelumba/comment.rb +47 -0
  34. data/lib/nelumba/crypto.rb +144 -0
  35. data/lib/nelumba/device.rb +11 -0
  36. data/lib/nelumba/discover.rb +362 -0
  37. data/lib/nelumba/event.rb +57 -0
  38. data/lib/nelumba/feed.rb +173 -0
  39. data/lib/nelumba/file.rb +43 -0
  40. data/lib/nelumba/generator.rb +53 -0
  41. data/lib/nelumba/group.rb +11 -0
  42. data/lib/nelumba/identity.rb +63 -0
  43. data/lib/nelumba/image.rb +30 -0
  44. data/lib/nelumba/link.rb +56 -0
  45. data/lib/nelumba/note.rb +34 -0
  46. data/lib/nelumba/notification.rb +229 -0
  47. data/lib/nelumba/object.rb +251 -0
  48. data/lib/nelumba/person.rb +306 -0
  49. data/lib/nelumba/place.rb +34 -0
  50. data/lib/nelumba/product.rb +30 -0
  51. data/lib/nelumba/publisher.rb +44 -0
  52. data/lib/nelumba/question.rb +30 -0
  53. data/lib/nelumba/review.rb +30 -0
  54. data/lib/nelumba/service.rb +11 -0
  55. data/lib/nelumba/subscription.rb +117 -0
  56. data/lib/nelumba/version.rb +3 -0
  57. data/lib/nelumba/video.rb +43 -0
  58. data/nelumba.gemspec +28 -0
  59. data/spec/activity_spec.rb +116 -0
  60. data/spec/application_spec.rb +136 -0
  61. data/spec/article_spec.rb +136 -0
  62. data/spec/atom/comment_spec.rb +455 -0
  63. data/spec/atom/feed_spec.rb +684 -0
  64. data/spec/audio_spec.rb +164 -0
  65. data/spec/badge_spec.rb +136 -0
  66. data/spec/binary_spec.rb +218 -0
  67. data/spec/bookmark.rb +150 -0
  68. data/spec/collection_spec.rb +152 -0
  69. data/spec/comment_spec.rb +128 -0
  70. data/spec/crypto_spec.rb +126 -0
  71. data/spec/device_spec.rb +136 -0
  72. data/spec/event_spec.rb +239 -0
  73. data/spec/feed_spec.rb +252 -0
  74. data/spec/file_spec.rb +190 -0
  75. data/spec/group_spec.rb +136 -0
  76. data/spec/helper.rb +10 -0
  77. data/spec/identity_spec.rb +67 -0
  78. data/spec/image_spec.rb +150 -0
  79. data/spec/link_spec.rb +30 -0
  80. data/spec/note_spec.rb +163 -0
  81. data/spec/notification_spec.rb +89 -0
  82. data/spec/person_spec.rb +244 -0
  83. data/spec/place_spec.rb +162 -0
  84. data/spec/product_spec.rb +150 -0
  85. data/spec/question_spec.rb +156 -0
  86. data/spec/review_spec.rb +149 -0
  87. data/spec/service_spec.rb +136 -0
  88. data/spec/video_spec.rb +164 -0
  89. data/test/example_feed.atom +393 -0
  90. data/test/example_feed_empty_author.atom +336 -0
  91. data/test/example_feed_false_connected.atom +359 -0
  92. data/test/example_feed_link_without_href.atom +134 -0
  93. data/test/example_page.html +4 -0
  94. data/test/mime_type_bug_feed.atom +874 -0
  95. metadata +288 -0
@@ -0,0 +1,684 @@
1
+ require_relative '../helper'
2
+ require_relative '../../lib/nelumba/feed.rb'
3
+ require_relative '../../lib/nelumba/atom/feed.rb'
4
+
5
+ # Sanity checks on atom generation because I don't trust ratom completely.
6
+ #
7
+ # Since I can't be completely sure how to test the implementations since they
8
+ # are patchy inheritance, I'll just do big acceptance tests and overtest.
9
+ # Somehow, these are still really fast.
10
+ describe Nelumba::Atom do
11
+ before do
12
+ author = Nelumba::Person.new(:uri => "http://example.com/users/1",
13
+ :email => "user@example.com",
14
+ :name => "wilkie",
15
+ :uid => "1",
16
+ :nickname => "wilkie",
17
+ :extended_name => {:formatted => "Dave Wilkinson",
18
+ :family_name => "Wilkinson",
19
+ :given_name => "Dave",
20
+ :middle_name => "William",
21
+ :honorific_prefix => "Mr.",
22
+ :honorific_suffix => "II"},
23
+ :address => {:formatted => "123 Cherry Lane\nFoobar, PA, USA\n15206",
24
+ :street_address => "123 Cherry Lane",
25
+ :locality => "Foobar",
26
+ :region => "PA",
27
+ :postal_code => "15206",
28
+ :country => "USA"},
29
+ :organization => {:name => "Hackers of the Severed Hand",
30
+ :department => "Making Shit",
31
+ :title => "Founder",
32
+ :type => "open source",
33
+ :start_date => Date.today,
34
+ :end_date => Date.today,
35
+ :location => "everywhere",
36
+ :description => "I make ostatus work"},
37
+ :account => {:domain => "example.com",
38
+ :username => "wilkie",
39
+ :userid => "1"},
40
+ :gender => "androgynous",
41
+ :note => "cool dude",
42
+ :display_name => "Dave Wilkinson",
43
+ :preferred_username => "wilkie",
44
+ :updated => Time.now,
45
+ :published => Time.now,
46
+ :birthday => Date.today,
47
+ :anniversary => Date.today)
48
+
49
+ source_feed = Nelumba::Feed.new(:title => "moo",
50
+ :authors => [author],
51
+ :rights => "CC")
52
+
53
+ reply_to = Nelumba::Activity.new(:type => :note,
54
+ :actor => author,
55
+ :object => Nelumba::Note.new(
56
+ :title => "My First Entry",
57
+ :html => "Hello"),
58
+ :uid => "54321",
59
+ :url => "http://example.com/entries/1",
60
+ :published => Time.now,
61
+ :updated => Time.now)
62
+
63
+ entry = Nelumba::Activity.new(:actor => author,
64
+ :type => :note,
65
+ :object => Nelumba::Note.new(
66
+ :title => "My Entry",
67
+ :html => "Hello"),
68
+ :source => source_feed,
69
+ :uid => "54321",
70
+ :url => "http://example.com/entries/1",
71
+ :published => Time.now,
72
+ :in_reply_to => reply_to,
73
+ :updated => Time.now)
74
+
75
+ @master = Nelumba::Feed.new(:title => "My Feed",
76
+ :title_type => "html",
77
+ :subtitle => "Subtitle",
78
+ :subtitle_type => "html",
79
+ :url => "http://example.com/feeds/1",
80
+ :rights => "CC0",
81
+ :icon => "http://example.com/icon.png",
82
+ :logo => "http://example.com/logo.png",
83
+ :hubs => ["http://hub.example.com",
84
+ "http://hub2.example.com"],
85
+ :published => Time.now,
86
+ :updated => Time.now,
87
+ :authors => [author],
88
+ :items => [entry],
89
+ :uid => "12345")
90
+ end
91
+
92
+ it "should be able to reform canonical structure using Atom" do
93
+ xml = Nelumba::Atom::Feed.from_canonical(@master).to_xml
94
+ new_feed = Nelumba::Atom::Feed.new(XML::Reader.string(xml)).to_canonical
95
+
96
+ old_hash = @master.to_hash
97
+ new_hash = new_feed.to_hash
98
+
99
+ old_hash[:authors] = old_hash[:authors].map(&:to_hash)
100
+ new_hash[:authors] = new_hash[:authors].map(&:to_hash)
101
+
102
+ old_hash[:items] = old_hash[:items].map(&:to_hash)
103
+ new_hash[:items] = new_hash[:items].map(&:to_hash)
104
+
105
+ old_hash[:items][0][:in_reply_to] = []
106
+ new_hash[:items][0][:in_reply_to] = []
107
+
108
+ old_hash[:items][0][:actor] = old_hash[:items][0][:actor].to_hash
109
+ new_hash[:items][0][:actor] = new_hash[:items][0][:actor].to_hash
110
+
111
+ old_hash[:items][0][:source] = old_hash[:items][0][:source].to_hash
112
+ new_hash[:items][0][:source] = new_hash[:items][0][:source].to_hash
113
+
114
+ old_hash[:items][0][:object] = old_hash[:items][0][:object].to_hash
115
+ new_hash[:items][0][:object] = new_hash[:items][0][:object].to_hash
116
+
117
+ old_hash[:items][0][:source][:authors] = old_hash[:items][0][:source][:authors].map(&:to_hash)
118
+ new_hash[:items][0][:source][:authors] = new_hash[:items][0][:source][:authors].map(&:to_hash)
119
+
120
+ # Flatten all keys to their to_s
121
+ # We want to compare the to_s for all keys
122
+ def flatten_keys!(hash)
123
+ hash.keys.each do |k|
124
+ if hash[k].is_a? Array
125
+ # Go inside arrays (doesn't handle arrays of arrays)
126
+ hash[k].map! do |e|
127
+ if e.is_a? Hash
128
+ flatten_keys! e
129
+ e
130
+ else
131
+ e.to_s
132
+ end
133
+ end
134
+ elsif hash[k].is_a? Hash
135
+ # Go inside hashes
136
+ flatten_keys!(hash[k])
137
+ elsif hash[k].is_a? Time
138
+ # Ensure all Time classes become DateTimes for comparison
139
+ hash[k] = hash[k].to_datetime.to_s
140
+ else
141
+ # Ensure all fields become Strings
142
+ hash[k] = hash[k].to_s
143
+ end
144
+ end
145
+ end
146
+
147
+ flatten_keys!(old_hash)
148
+ flatten_keys!(new_hash)
149
+
150
+ old_hash.must_equal new_hash
151
+ end
152
+
153
+ describe "<xml>" do
154
+ before do
155
+ @xml_str = Nelumba::Atom::Feed.from_canonical(@master).to_xml
156
+ @xml = XML::Parser.string(@xml_str).parse
157
+ end
158
+
159
+ it "should publish a version of 1.0" do
160
+ @xml_str.must_match /^<\?xml[^>]*\sversion="1\.0"/
161
+ end
162
+
163
+ it "should encode in utf-8" do
164
+ @xml_str.must_match /^<\?xml[^>]*\sencoding="UTF-8"/
165
+ end
166
+
167
+ describe "<feed>" do
168
+ before do
169
+ @feed = @xml.root
170
+ end
171
+
172
+ it "should contain the Atom namespace" do
173
+ @feed.namespaces.find_by_href("http://www.w3.org/2005/Atom").to_s
174
+ .must_equal "http://www.w3.org/2005/Atom"
175
+ end
176
+
177
+ it "should contain the PortableContacts namespace" do
178
+ @feed.namespaces.find_by_prefix('poco').to_s
179
+ .must_equal "poco:http://portablecontacts.net/spec/1.0"
180
+ end
181
+
182
+ it "should contain the ActivityStreams namespace" do
183
+ @feed.namespaces.find_by_prefix('activity').to_s
184
+ .must_equal "activity:http://activitystrea.ms/spec/1.0/"
185
+ end
186
+
187
+ describe "<id>" do
188
+ it "should contain the id from Nelumba::Feed" do
189
+ @feed.find_first('xmlns:id', 'xmlns:http://www.w3.org/2005/Atom')
190
+ .content.must_equal @master.uid
191
+ end
192
+ end
193
+
194
+ describe "<rights>" do
195
+ it "should contain the rights from Nelumba::Feed" do
196
+ @feed.find_first('xmlns:rights', 'xmlns:http://www.w3.org/2005/Atom')
197
+ .content.must_equal @master.rights
198
+ end
199
+ end
200
+
201
+ describe "<logo>" do
202
+ it "should contain the logo from Nelumba::Feed" do
203
+ @feed.find_first('xmlns:logo', 'xmlns:http://www.w3.org/2005/Atom')
204
+ .content.must_equal @master.logo
205
+ end
206
+ end
207
+
208
+ describe "<icon>" do
209
+ it "should contain the icon from Nelumba::Feed" do
210
+ @feed.find_first('xmlns:icon', 'xmlns:http://www.w3.org/2005/Atom')
211
+ .content.must_equal @master.icon
212
+ end
213
+ end
214
+
215
+ describe "<published>" do
216
+ it "should contain the time in the published field in Nelumba::Feed" do
217
+ time = @feed.find_first('xmlns:published',
218
+ 'xmlns:http://www.w3.org/2005/Atom').content
219
+ DateTime::rfc3339(time).to_s.must_equal @master.published.to_datetime.to_s
220
+ end
221
+ end
222
+
223
+ describe "<updated>" do
224
+ it "should contain the time in the updated field in Nelumba::Feed" do
225
+ time = @feed.find_first('xmlns:updated',
226
+ 'xmlns:http://www.w3.org/2005/Atom').content
227
+ DateTime::rfc3339(time).to_s.must_equal @master.updated.to_datetime.to_s
228
+ end
229
+ end
230
+
231
+ describe "<link>" do
232
+ it "should contain a link for the hub" do
233
+ @feed.find_first('xmlns:link[@rel="hub"]',
234
+ 'xmlns:http://www.w3.org/2005/Atom').attributes
235
+ .get_attribute('href').value.must_equal(@master.hubs.first)
236
+ end
237
+
238
+ it "should allow a second link for the hub" do
239
+ @feed.find('xmlns:link[@rel="hub"]',
240
+ 'xmlns:http://www.w3.org/2005/Atom')[1].attributes
241
+ .get_attribute('href').value.must_equal(@master.hubs[1])
242
+ end
243
+
244
+ it "should contain a link for self" do
245
+ @feed.find_first('xmlns:link[@rel="self"]',
246
+ 'xmlns:http://www.w3.org/2005/Atom').attributes
247
+ .get_attribute('href').value.must_equal(@master.url)
248
+ end
249
+ end
250
+
251
+ describe "<title>" do
252
+ before do
253
+ @title = @feed.find_first('xmlns:title', 'xmlns:http://www.w3.org/2005/Atom')
254
+ end
255
+
256
+ it "should contain the title from Nelumba::Feed" do
257
+ @title.content.must_equal @master.title
258
+ end
259
+
260
+ it "should contain the type attribute from Nelumba::Feed" do
261
+ @title.attributes.get_attribute('type').value.must_equal @master.title_type
262
+ end
263
+ end
264
+
265
+ describe "<subtitle>" do
266
+ before do
267
+ @subtitle = @feed.find_first('xmlns:subtitle', 'xmlns:http://www.w3.org/2005/Atom')
268
+ end
269
+
270
+ it "should contain the subtitle from Nelumba::Feed" do
271
+ @subtitle.content.must_equal @master.subtitle
272
+ end
273
+
274
+ it "should contain the type attribute from Nelumba::Feed" do
275
+ @subtitle.attributes.get_attribute('type').value.must_equal @master.subtitle_type
276
+ end
277
+ end
278
+
279
+ describe "<author>" do
280
+ before do
281
+ @author = @feed.find_first('xmlns:author', 'xmlns:http://www.w3.org/2005/Atom')
282
+ end
283
+
284
+ describe "<activity:object-type>" do
285
+ it "should identify this tag as a person object" do
286
+ @author.find_first('activity:object-type').content
287
+ .must_equal "http://activitystrea.ms/schema/1.0/person"
288
+ end
289
+ end
290
+
291
+ describe "<email>" do
292
+ it "should list the author's email" do
293
+ @author.find_first('xmlns:email',
294
+ 'xmlns:http://www.w3.org/2005/Atom').content.must_equal @master.authors.first.email
295
+ end
296
+ end
297
+
298
+ describe "<uri>" do
299
+ it "should list the author's uri" do
300
+ @author.find_first('xmlns:uri',
301
+ 'xmlns:http://www.w3.org/2005/Atom').content.must_equal @master.authors.first.uri
302
+ end
303
+ end
304
+
305
+ describe "<name>" do
306
+ it "should list the author's name" do
307
+ @author.find_first('xmlns:name',
308
+ 'xmlns:http://www.w3.org/2005/Atom').content.must_equal @master.authors.first.name
309
+ end
310
+ end
311
+
312
+ describe "<poco:id>" do
313
+ it "should list the author's portable contact id" do
314
+ @author.find_first('poco:id',
315
+ 'http://portablecontacts.net/spec/1.0').content.must_equal @master.authors.first.uid
316
+ end
317
+ end
318
+
319
+ describe "<poco:name>" do
320
+ before do
321
+ @poco_name = @author.find_first('poco:name',
322
+ 'http://portablecontacts.net/spec/1.0')
323
+ end
324
+
325
+ describe "<formatted>" do
326
+ it "should list the author's portable contact formatted name" do
327
+ @poco_name.find_first('xmlns:formatted',
328
+ 'xmlns:http://www.w3.org/2005/Atom')
329
+ .content.must_equal @master.authors.first.extended_name[:formatted]
330
+ end
331
+ end
332
+
333
+ describe "<familyName>" do
334
+ it "should list the author's portable contact family name" do
335
+ @poco_name.find_first('xmlns:familyName',
336
+ 'xmlns:http://www.w3.org/2005/Atom')
337
+ .content.must_equal @master.authors.first.extended_name[:family_name]
338
+ end
339
+ end
340
+
341
+ describe "<givenName>" do
342
+ it "should list the author's portable contact given name" do
343
+ @poco_name.find_first('xmlns:givenName',
344
+ 'xmlns:http://www.w3.org/2005/Atom')
345
+ .content.must_equal @master.authors.first.extended_name[:given_name]
346
+ end
347
+ end
348
+
349
+ describe "<middleName>" do
350
+ it "should list the author's portable contact middle name" do
351
+ @poco_name.find_first('xmlns:middleName',
352
+ 'xmlns:http://www.w3.org/2005/Atom')
353
+ .content.must_equal @master.authors.first.extended_name[:middle_name]
354
+ end
355
+ end
356
+
357
+ describe "<honorificPrefix>" do
358
+ it "should list the author's portable contact honorific prefix" do
359
+ @poco_name.find_first('xmlns:honorificPrefix',
360
+ 'xmlns:http://www.w3.org/2005/Atom')
361
+ .content.must_equal @master.authors.first.extended_name[:honorific_prefix]
362
+ end
363
+ end
364
+
365
+ describe "<honorificSuffix>" do
366
+ it "should list the author's portable contact honorific suffix" do
367
+ @poco_name.find_first('xmlns:honorificSuffix',
368
+ 'xmlns:http://www.w3.org/2005/Atom')
369
+ .content.must_equal @master.authors.first.extended_name[:honorific_suffix]
370
+ end
371
+ end
372
+ end
373
+
374
+ describe "<poco:organization>" do
375
+ before do
376
+ @poco_org = @author.find_first('poco:organization',
377
+ 'http://portablecontacts.net/spec/1.0')
378
+ end
379
+
380
+ describe "<name>" do
381
+ it "should list the author's portable contact organization name" do
382
+ @poco_org.find_first('xmlns:name',
383
+ 'xmlns:http://www.w3.org/2005/Atom')
384
+ .content.must_equal @master.authors.first.organization[:name]
385
+ end
386
+ end
387
+
388
+ describe "<department>" do
389
+ it "should list the author's portable contact organization department" do
390
+ @poco_org.find_first('xmlns:department',
391
+ 'xmlns:http://www.w3.org/2005/Atom')
392
+ .content.must_equal @master.authors.first.organization[:department]
393
+ end
394
+ end
395
+
396
+ describe "<title>" do
397
+ it "should list the author's portable contact organization title" do
398
+ @poco_org.find_first('xmlns:title',
399
+ 'xmlns:http://www.w3.org/2005/Atom')
400
+ .content.must_equal @master.authors.first.organization[:title]
401
+ end
402
+ end
403
+
404
+ describe "<type>" do
405
+ it "should list the author's portable contact organization type" do
406
+ @poco_org.find_first('xmlns:type',
407
+ 'xmlns:http://www.w3.org/2005/Atom')
408
+ .content.must_equal @master.authors.first.organization[:type]
409
+ end
410
+ end
411
+
412
+ describe "<startDate>" do
413
+ it "should list the author's portable contact organization startDate" do
414
+ time = @poco_org.find_first('xmlns:startDate',
415
+ 'xmlns:http://www.w3.org/2005/Atom').content
416
+ DateTime::parse(time).to_s
417
+ .must_equal @master.authors.first.organization[:start_date].to_datetime.to_s
418
+ end
419
+ end
420
+
421
+ describe "<endDate>" do
422
+ it "should list the author's portable contact organization endDate" do
423
+ time = @poco_org.find_first('xmlns:endDate',
424
+ 'xmlns:http://www.w3.org/2005/Atom').content
425
+ DateTime::parse(time).to_s
426
+ .must_equal @master.authors.first.organization[:end_date].to_datetime.to_s
427
+ end
428
+ end
429
+
430
+ describe "<location>" do
431
+ it "should list the author's portable contact organization location" do
432
+ @poco_org.find_first('xmlns:location',
433
+ 'xmlns:http://www.w3.org/2005/Atom')
434
+ .content.must_equal @master.authors.first.organization[:location]
435
+ end
436
+ end
437
+
438
+ describe "<description>" do
439
+ it "should list the author's portable contact organization description" do
440
+ @poco_org.find_first('xmlns:description',
441
+ 'xmlns:http://www.w3.org/2005/Atom')
442
+ .content.must_equal @master.authors.first.organization[:description]
443
+ end
444
+ end
445
+ end
446
+
447
+ describe "<poco:address>" do
448
+ before do
449
+ @poco_address = @author.find_first('poco:address',
450
+ 'http://portablecontacts.net/spec/1.0')
451
+ end
452
+
453
+ describe "<formatted>" do
454
+ it "should list the author's portable contact formatted address" do
455
+ @poco_address.find_first('xmlns:formatted',
456
+ 'xmlns:http://www.w3.org/2005/Atom')
457
+ .content.must_equal @master.authors.first.address[:formatted]
458
+ end
459
+ end
460
+
461
+ describe "<streetAddress>" do
462
+ it "should list the author's portable contact address streetAddress" do
463
+ @poco_address.find_first('xmlns:streetAddress',
464
+ 'xmlns:http://www.w3.org/2005/Atom')
465
+ .content.must_equal @master.authors.first.address[:street_address]
466
+ end
467
+ end
468
+
469
+ describe "<locality>" do
470
+ it "should list the author's portable contact address locality" do
471
+ @poco_address.find_first('xmlns:locality',
472
+ 'xmlns:http://www.w3.org/2005/Atom')
473
+ .content.must_equal @master.authors.first.address[:locality]
474
+ end
475
+ end
476
+
477
+ describe "<region>" do
478
+ it "should list the author's portable contact address region" do
479
+ @poco_address.find_first('xmlns:region',
480
+ 'xmlns:http://www.w3.org/2005/Atom')
481
+ .content.must_equal @master.authors.first.address[:region]
482
+ end
483
+ end
484
+
485
+ describe "<postalCode>" do
486
+ it "should list the author's portable contact address postalCode" do
487
+ @poco_address.find_first('xmlns:postalCode',
488
+ 'xmlns:http://www.w3.org/2005/Atom')
489
+ .content.must_equal @master.authors.first.address[:postal_code]
490
+ end
491
+ end
492
+
493
+ describe "<country>" do
494
+ it "should list the author's portable contact address country" do
495
+ @poco_address.find_first('xmlns:country',
496
+ 'xmlns:http://www.w3.org/2005/Atom')
497
+ .content.must_equal @master.authors.first.address[:country]
498
+ end
499
+ end
500
+ end
501
+
502
+ describe "<poco:account>" do
503
+ before do
504
+ @poco_account = @author.find_first('poco:account',
505
+ 'http://portablecontacts.net/spec/1.0')
506
+ end
507
+
508
+ describe "<domain>" do
509
+ it "should list the author's portable contact account domain" do
510
+ @poco_account.find_first('xmlns:domain',
511
+ 'xmlns:http://www.w3.org/2005/Atom')
512
+ .content.must_equal @master.authors.first.account[:domain]
513
+ end
514
+ end
515
+
516
+ describe "<username>" do
517
+ it "should list the author's portable contact account username" do
518
+ @poco_account.find_first('xmlns:username',
519
+ 'xmlns:http://www.w3.org/2005/Atom')
520
+ .content.must_equal @master.authors.first.account[:username]
521
+ end
522
+ end
523
+
524
+ describe "<userid>" do
525
+ it "should list the author's portable contact account userid" do
526
+ @poco_account.find_first('xmlns:userid',
527
+ 'xmlns:http://www.w3.org/2005/Atom')
528
+ .content.must_equal @master.authors.first.account[:userid]
529
+ end
530
+ end
531
+ end
532
+
533
+ describe "<poco:displayName>" do
534
+ it "should list the author's portable contact display name" do
535
+ @author.find_first('poco:displayName',
536
+ 'http://portablecontacts.net/spec/1.0')
537
+ .content.must_equal @master.authors.first.display_name
538
+ end
539
+ end
540
+
541
+ describe "<poco:nickname>" do
542
+ it "should list the author's portable contact nickname" do
543
+ @author.find_first('poco:nickname',
544
+ 'http://portablecontacts.net/spec/1.0')
545
+ .content.must_equal @master.authors.first.nickname
546
+ end
547
+ end
548
+
549
+ describe "<poco:gender>" do
550
+ it "should list the author's portable contact gender" do
551
+ @author.find_first('poco:gender',
552
+ 'http://portablecontacts.net/spec/1.0')
553
+ .content.must_equal @master.authors.first.gender
554
+ end
555
+ end
556
+
557
+ describe "<poco:note>" do
558
+ it "should list the author's portable contact note" do
559
+ @author.find_first('poco:note',
560
+ 'http://portablecontacts.net/spec/1.0')
561
+ .content.must_equal @master.authors.first.note
562
+ end
563
+ end
564
+
565
+ describe "<poco:preferredUsername>" do
566
+ it "should list the author's portable contact preferred username" do
567
+ @author.find_first('poco:preferredUsername',
568
+ 'http://portablecontacts.net/spec/1.0')
569
+ .content.must_equal @master.authors.first.preferred_username
570
+ end
571
+ end
572
+
573
+ describe "<poco:birthday>" do
574
+ it "should list the author's portable contact birthday" do
575
+ time = @author.find_first('poco:birthday',
576
+ 'http://portablecontacts.net/spec/1.0').content
577
+ DateTime::parse(time).to_s.must_equal @master.authors.first
578
+ .birthday.to_datetime.to_s
579
+ end
580
+ end
581
+
582
+ describe "<poco:anniversary>" do
583
+ it "should list the author's portable contact anniversary" do
584
+ time = @author.find_first('poco:anniversary',
585
+ 'http://portablecontacts.net/spec/1.0').content
586
+ DateTime::parse(time).to_s.must_equal @master.authors.first
587
+ .anniversary.to_datetime.to_s
588
+ end
589
+ end
590
+
591
+ describe "<poco:published>" do
592
+ it "should list the author's portable contact published date" do
593
+ time = @author.find_first('poco:published',
594
+ 'http://portablecontacts.net/spec/1.0').content
595
+ DateTime::parse(time).to_s.must_equal @master.authors.first
596
+ .published.to_datetime.to_s
597
+ end
598
+ end
599
+
600
+ describe "<poco:updated>" do
601
+ it "should list the author's portable contact updated date" do
602
+ time = @author.find_first('poco:updated',
603
+ 'http://portablecontacts.net/spec/1.0').content
604
+ DateTime::parse(time).to_s.must_equal @master.authors.first
605
+ .updated.to_datetime.to_s
606
+ end
607
+ end
608
+ end
609
+
610
+ describe "<entry>" do
611
+ before do
612
+ @entry = @feed.find_first('xmlns:entry', 'xmlns:http://www.w3.org/2005/Atom')
613
+ end
614
+
615
+ it "should have the thread namespace" do
616
+ @entry.namespaces.find_by_prefix('thr').to_s
617
+ .must_equal "thr:http://purl.org/syndication/thread/1.0"
618
+ end
619
+
620
+ it "should have the activity streams namespace" do
621
+ @entry.namespaces.find_by_prefix('activity').to_s
622
+ .must_equal "activity:http://activitystrea.ms/spec/1.0/"
623
+ end
624
+
625
+ describe "<title>" do
626
+ it "should contain the entry title" do
627
+ @entry.find_first('xmlns:title', 'xmlns:http://www.w3.org/2005/Atom')
628
+ .content.must_equal @master.items.first.object.title
629
+ end
630
+ end
631
+
632
+ describe "<id>" do
633
+ it "should contain the entry id" do
634
+ @entry.find_first('xmlns:id', 'xmlns:http://www.w3.org/2005/Atom')
635
+ .content.must_equal @master.items.first.uid
636
+ end
637
+ end
638
+
639
+ describe "<link>" do
640
+ it "should contain a link for self" do
641
+ @entry.find_first('xmlns:link[@rel="self"]',
642
+ 'xmlns:http://www.w3.org/2005/Atom').attributes
643
+ .get_attribute('href').value.must_equal(@master.items.first.url)
644
+ end
645
+ end
646
+
647
+ describe "<updated>" do
648
+ it "should contain the entry updated date" do
649
+ time = @entry.find_first('xmlns:updated',
650
+ 'xmlns:http://www.w3.org/2005/Atom').content
651
+ DateTime.parse(time).to_s.must_equal @master.items.first.updated.to_datetime.to_s
652
+ end
653
+ end
654
+
655
+ describe "<published>" do
656
+ it "should contain the entry published date" do
657
+ time = @entry.find_first('xmlns:published',
658
+ 'xmlns:http://www.w3.org/2005/Atom').content
659
+ DateTime.parse(time).to_s.must_equal @master.items.first.published.to_datetime.to_s
660
+ end
661
+ end
662
+
663
+ describe "<activity:object-type>" do
664
+ it "should reflect the activity for this entry" do
665
+ @entry.find_first('activity:object-type').content
666
+ .must_equal "http://activitystrea.ms/schema/1.0/note"
667
+ end
668
+ end
669
+
670
+ describe "<content>" do
671
+ it "should contain the entry content" do
672
+ @entry.find_first('xmlns:content', 'xmlns:http://www.w3.org/2005/Atom')
673
+ .content.must_equal @master.items.first.object.html
674
+ end
675
+
676
+ it "should have the corresponding type attribute" do
677
+ @entry.find_first('xmlns:content', 'xmlns:http://www.w3.org/2005/Atom')
678
+ .attributes.get_attribute('type').value.must_equal "html"
679
+ end
680
+ end
681
+ end
682
+ end
683
+ end
684
+ end