nelumba 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.travis.yml +9 -0
- data/Gemfile +20 -0
- data/README.md +242 -0
- data/Rakefile +7 -0
- data/assets/lotus_logo_purple.png +0 -0
- data/assets/lotus_logo_purple.svg +262 -0
- data/lib/nelumba.rb +47 -0
- data/lib/nelumba/activity.rb +250 -0
- data/lib/nelumba/application.rb +11 -0
- data/lib/nelumba/article.rb +11 -0
- data/lib/nelumba/atom/account.rb +50 -0
- data/lib/nelumba/atom/address.rb +56 -0
- data/lib/nelumba/atom/author.rb +176 -0
- data/lib/nelumba/atom/category.rb +41 -0
- data/lib/nelumba/atom/comment.rb +96 -0
- data/lib/nelumba/atom/entry.rb +216 -0
- data/lib/nelumba/atom/feed.rb +198 -0
- data/lib/nelumba/atom/generator.rb +40 -0
- data/lib/nelumba/atom/link.rb +79 -0
- data/lib/nelumba/atom/name.rb +57 -0
- data/lib/nelumba/atom/organization.rb +62 -0
- data/lib/nelumba/atom/person.rb +179 -0
- data/lib/nelumba/atom/portable_contacts.rb +117 -0
- data/lib/nelumba/atom/source.rb +179 -0
- data/lib/nelumba/atom/thread.rb +60 -0
- data/lib/nelumba/audio.rb +39 -0
- data/lib/nelumba/badge.rb +11 -0
- data/lib/nelumba/binary.rb +52 -0
- data/lib/nelumba/bookmark.rb +30 -0
- data/lib/nelumba/category.rb +49 -0
- data/lib/nelumba/collection.rb +34 -0
- data/lib/nelumba/comment.rb +47 -0
- data/lib/nelumba/crypto.rb +144 -0
- data/lib/nelumba/device.rb +11 -0
- data/lib/nelumba/discover.rb +362 -0
- data/lib/nelumba/event.rb +57 -0
- data/lib/nelumba/feed.rb +173 -0
- data/lib/nelumba/file.rb +43 -0
- data/lib/nelumba/generator.rb +53 -0
- data/lib/nelumba/group.rb +11 -0
- data/lib/nelumba/identity.rb +63 -0
- data/lib/nelumba/image.rb +30 -0
- data/lib/nelumba/link.rb +56 -0
- data/lib/nelumba/note.rb +34 -0
- data/lib/nelumba/notification.rb +229 -0
- data/lib/nelumba/object.rb +251 -0
- data/lib/nelumba/person.rb +306 -0
- data/lib/nelumba/place.rb +34 -0
- data/lib/nelumba/product.rb +30 -0
- data/lib/nelumba/publisher.rb +44 -0
- data/lib/nelumba/question.rb +30 -0
- data/lib/nelumba/review.rb +30 -0
- data/lib/nelumba/service.rb +11 -0
- data/lib/nelumba/subscription.rb +117 -0
- data/lib/nelumba/version.rb +3 -0
- data/lib/nelumba/video.rb +43 -0
- data/nelumba.gemspec +28 -0
- data/spec/activity_spec.rb +116 -0
- data/spec/application_spec.rb +136 -0
- data/spec/article_spec.rb +136 -0
- data/spec/atom/comment_spec.rb +455 -0
- data/spec/atom/feed_spec.rb +684 -0
- data/spec/audio_spec.rb +164 -0
- data/spec/badge_spec.rb +136 -0
- data/spec/binary_spec.rb +218 -0
- data/spec/bookmark.rb +150 -0
- data/spec/collection_spec.rb +152 -0
- data/spec/comment_spec.rb +128 -0
- data/spec/crypto_spec.rb +126 -0
- data/spec/device_spec.rb +136 -0
- data/spec/event_spec.rb +239 -0
- data/spec/feed_spec.rb +252 -0
- data/spec/file_spec.rb +190 -0
- data/spec/group_spec.rb +136 -0
- data/spec/helper.rb +10 -0
- data/spec/identity_spec.rb +67 -0
- data/spec/image_spec.rb +150 -0
- data/spec/link_spec.rb +30 -0
- data/spec/note_spec.rb +163 -0
- data/spec/notification_spec.rb +89 -0
- data/spec/person_spec.rb +244 -0
- data/spec/place_spec.rb +162 -0
- data/spec/product_spec.rb +150 -0
- data/spec/question_spec.rb +156 -0
- data/spec/review_spec.rb +149 -0
- data/spec/service_spec.rb +136 -0
- data/spec/video_spec.rb +164 -0
- data/test/example_feed.atom +393 -0
- data/test/example_feed_empty_author.atom +336 -0
- data/test/example_feed_false_connected.atom +359 -0
- data/test/example_feed_link_without_href.atom +134 -0
- data/test/example_page.html +4 -0
- data/test/mime_type_bug_feed.atom +874 -0
- metadata +288 -0
data/spec/device_spec.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require_relative '../lib/nelumba/device.rb'
|
3
|
+
|
4
|
+
describe Nelumba::Device do
|
5
|
+
describe "#initialize" do
|
6
|
+
it "should store an author" do
|
7
|
+
author = mock('author')
|
8
|
+
Nelumba::Device.new(:author => author).author.must_equal author
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should store content" do
|
12
|
+
Nelumba::Device.new(:content => "txt").content.must_equal "txt"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should store the published date" do
|
16
|
+
time = mock('date')
|
17
|
+
Nelumba::Device.new(:published => time).published.must_equal time
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should store the updated date" do
|
21
|
+
time = mock('date')
|
22
|
+
Nelumba::Device.new(:updated => time).updated.must_equal time
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should store a display name" do
|
26
|
+
Nelumba::Device.new(:display_name => "url")
|
27
|
+
.display_name.must_equal "url"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should store a summary" do
|
31
|
+
Nelumba::Device.new(:summary => "url").summary.must_equal "url"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should store a url" do
|
35
|
+
Nelumba::Device.new(:url => "url").url.must_equal "url"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should store an id" do
|
39
|
+
Nelumba::Device.new(:uid => "id").uid.must_equal "id"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#to_hash" do
|
44
|
+
it "should contain the content" do
|
45
|
+
Nelumba::Device.new(:content => "Hello")
|
46
|
+
.to_hash[:content].must_equal "Hello"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should contain the author" do
|
50
|
+
author = mock('Nelumba::Person')
|
51
|
+
Nelumba::Device.new(:author => author).to_hash[:author].must_equal author
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should contain the uid" do
|
55
|
+
Nelumba::Device.new(:uid => "Hello").to_hash[:uid].must_equal "Hello"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should contain the url" do
|
59
|
+
Nelumba::Device.new(:url => "Hello").to_hash[:url].must_equal "Hello"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should contain the summary" do
|
63
|
+
Nelumba::Device.new(:summary=> "Hello")
|
64
|
+
.to_hash[:summary].must_equal "Hello"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should contain the display name" do
|
68
|
+
Nelumba::Device.new(:display_name => "Hello")
|
69
|
+
.to_hash[:display_name].must_equal "Hello"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should contain the published date" do
|
73
|
+
date = mock('Time')
|
74
|
+
Nelumba::Device.new(:published => date).to_hash[:published].must_equal date
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should contain the updated date" do
|
78
|
+
date = mock('Time')
|
79
|
+
Nelumba::Device.new(:updated => date).to_hash[:updated].must_equal date
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#to_json" do
|
84
|
+
before do
|
85
|
+
author = Nelumba::Person.new :display_name => "wilkie"
|
86
|
+
@note = Nelumba::Device.new :content => "Hello",
|
87
|
+
:author => author,
|
88
|
+
:uid => "id",
|
89
|
+
:url => "url",
|
90
|
+
:title => "title",
|
91
|
+
:summary => "foo",
|
92
|
+
:display_name => "meh",
|
93
|
+
:published => Time.now,
|
94
|
+
:updated => Time.now
|
95
|
+
|
96
|
+
@json = @note.to_json
|
97
|
+
@data = JSON.parse(@json)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should contain the embedded json for the author" do
|
101
|
+
@data["author"].must_equal JSON.parse(@note.author.to_json)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should contain a 'device' objectType" do
|
105
|
+
@data["objectType"].must_equal "device"
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should contain the id" do
|
109
|
+
@data["id"].must_equal @note.uid
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should contain the content" do
|
113
|
+
@data["content"].must_equal @note.content
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should contain the url" do
|
117
|
+
@data["url"].must_equal @note.url
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should contain the summary" do
|
121
|
+
@data["summary"].must_equal @note.summary
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should contain the display name" do
|
125
|
+
@data["displayName"].must_equal @note.display_name
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should contain the published date as rfc3339" do
|
129
|
+
@data["published"].must_equal @note.published.to_date.rfc3339 + 'Z'
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should contain the updated date as rfc3339" do
|
133
|
+
@data["updated"].must_equal @note.updated.to_date.rfc3339 + 'Z'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
data/spec/event_spec.rb
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require_relative '../lib/nelumba/event.rb'
|
3
|
+
|
4
|
+
describe Nelumba::Event do
|
5
|
+
describe "#initialize" do
|
6
|
+
it "should store an author" do
|
7
|
+
author = mock('author')
|
8
|
+
Nelumba::Event.new(:author => author).author.must_equal author
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should store content" do
|
12
|
+
Nelumba::Event.new(:content => "txt").content.must_equal "txt"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should store attending array" do
|
16
|
+
Nelumba::Event.new(:attending => ["a","b"])
|
17
|
+
.attending.must_equal ["a","b"]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should store maybe_attending array" do
|
21
|
+
Nelumba::Event.new(:maybe_attending => ["a","b"])
|
22
|
+
.maybe_attending.must_equal ["a","b"]
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should store not_attending array" do
|
26
|
+
Nelumba::Event.new(:not_attending => ["a","b"])
|
27
|
+
.not_attending.must_equal ["a","b"]
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should store start time date" do
|
31
|
+
time = mock('date')
|
32
|
+
Nelumba::Event.new(:start_time => time).start_time.must_equal time
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should store end time date" do
|
36
|
+
time = mock('date')
|
37
|
+
Nelumba::Event.new(:end_time => time).end_time.must_equal time
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should store location" do
|
41
|
+
Nelumba::Event.new(:location => "place").location.must_equal "place"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should store the published date" do
|
45
|
+
time = mock('date')
|
46
|
+
Nelumba::Event.new(:published => time).published.must_equal time
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should store the updated date" do
|
50
|
+
time = mock('date')
|
51
|
+
Nelumba::Event.new(:updated => time).updated.must_equal time
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should store a display name" do
|
55
|
+
Nelumba::Event.new(:display_name => "url")
|
56
|
+
.display_name.must_equal "url"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should store a summary" do
|
60
|
+
Nelumba::Event.new(:summary => "url").summary.must_equal "url"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should store a url" do
|
64
|
+
Nelumba::Event.new(:url => "url").url.must_equal "url"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should store an id" do
|
68
|
+
Nelumba::Event.new(:uid => "id").uid.must_equal "id"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should default attending array to empty array" do
|
72
|
+
Nelumba::Event.new.attending.must_equal []
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should default maybe attending array to empty array" do
|
76
|
+
Nelumba::Event.new.maybe_attending.must_equal []
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should default not attending array to empty array" do
|
80
|
+
Nelumba::Event.new.not_attending.must_equal []
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#to_hash" do
|
85
|
+
it "should contain the content" do
|
86
|
+
Nelumba::Event.new(:content => "Hello")
|
87
|
+
.to_hash[:content].must_equal "Hello"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should contain the author" do
|
91
|
+
author = mock('Nelumba::Person')
|
92
|
+
Nelumba::Event.new(:author => author).to_hash[:author].must_equal author
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should contain the attending array" do
|
96
|
+
Nelumba::Event.new(:attending => ["a","b"])
|
97
|
+
.to_hash[:attending].must_equal ["a","b"]
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should contain the maybe attending array" do
|
101
|
+
Nelumba::Event.new(:maybe_attending => ["a","b"])
|
102
|
+
.to_hash[:maybe_attending].must_equal ["a","b"]
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should contain the not attending array" do
|
106
|
+
Nelumba::Event.new(:not_attending => ["a","b"])
|
107
|
+
.to_hash[:not_attending].must_equal ["a","b"]
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should contain the start time" do
|
111
|
+
date = mock('Time')
|
112
|
+
Nelumba::Event.new(:start_time => date)
|
113
|
+
.to_hash[:start_time].must_equal date
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should contain the end time" do
|
117
|
+
date = mock('Time')
|
118
|
+
Nelumba::Event.new(:end_time => date)
|
119
|
+
.to_hash[:end_time].must_equal date
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should contain the location" do
|
123
|
+
Nelumba::Event.new(:location => "location")
|
124
|
+
.to_hash[:location].must_equal "location"
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should contain the uid" do
|
128
|
+
Nelumba::Event.new(:uid => "Hello").to_hash[:uid].must_equal "Hello"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should contain the url" do
|
132
|
+
Nelumba::Event.new(:url => "Hello").to_hash[:url].must_equal "Hello"
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should contain the summary" do
|
136
|
+
Nelumba::Event.new(:summary=> "Hello")
|
137
|
+
.to_hash[:summary].must_equal "Hello"
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should contain the display name" do
|
141
|
+
Nelumba::Event.new(:display_name => "Hello")
|
142
|
+
.to_hash[:display_name].must_equal "Hello"
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should contain the published date" do
|
146
|
+
date = mock('Time')
|
147
|
+
Nelumba::Event.new(:published => date).to_hash[:published].must_equal date
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should contain the updated date" do
|
151
|
+
date = mock('Time')
|
152
|
+
Nelumba::Event.new(:updated => date).to_hash[:updated].must_equal date
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "#to_json" do
|
157
|
+
before do
|
158
|
+
author = Nelumba::Person.new :display_name => "wilkie"
|
159
|
+
@note = Nelumba::Event.new :content => "Hello",
|
160
|
+
:author => author,
|
161
|
+
:attending => ["a", "b"],
|
162
|
+
:maybe_attending => ["c", "d"],
|
163
|
+
:not_attending => ["e", "f"],
|
164
|
+
:location => "my house",
|
165
|
+
:start_time => Time.now,
|
166
|
+
:end_time => Time.now,
|
167
|
+
:uid => "id",
|
168
|
+
:url => "url",
|
169
|
+
:title => "title",
|
170
|
+
:summary => "foo",
|
171
|
+
:display_name => "meh",
|
172
|
+
:published => Time.now,
|
173
|
+
:updated => Time.now
|
174
|
+
|
175
|
+
@json = @note.to_json
|
176
|
+
@data = JSON.parse(@json)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should contain the embedded json for the author" do
|
180
|
+
@data["author"].must_equal JSON.parse(@note.author.to_json)
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should contain a 'event' objectType" do
|
184
|
+
@data["objectType"].must_equal "event"
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should contain the id" do
|
188
|
+
@data["id"].must_equal @note.uid
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should contain the content" do
|
192
|
+
@data["content"].must_equal @note.content
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should contain the attending array" do
|
196
|
+
@data["attending"].must_equal @note.attending
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should contain the maybe attending array" do
|
200
|
+
@data["maybeAttending"].must_equal @note.maybe_attending
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should contain the not attending array" do
|
204
|
+
@data["notAttending"].must_equal @note.not_attending
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should contain the location" do
|
208
|
+
@data["location"].must_equal @note.location
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should contain the start time as rfc3339" do
|
212
|
+
@data["startTime"].must_equal @note.start_time.to_date.rfc3339 + 'Z'
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should contain the end time as rfc3339" do
|
216
|
+
@data["endTime"].must_equal @note.end_time.to_date.rfc3339 + 'Z'
|
217
|
+
end
|
218
|
+
|
219
|
+
it "should contain the url" do
|
220
|
+
@data["url"].must_equal @note.url
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should contain the summary" do
|
224
|
+
@data["summary"].must_equal @note.summary
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should contain the display name" do
|
228
|
+
@data["displayName"].must_equal @note.display_name
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should contain the published date as rfc3339" do
|
232
|
+
@data["published"].must_equal @note.published.to_date.rfc3339 + 'Z'
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should contain the updated date as rfc3339" do
|
236
|
+
@data["updated"].must_equal @note.updated.to_date.rfc3339 + 'Z'
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
data/spec/feed_spec.rb
ADDED
@@ -0,0 +1,252 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require_relative '../lib/nelumba/feed.rb'
|
3
|
+
|
4
|
+
describe Nelumba::Feed do
|
5
|
+
describe "#initialize" do
|
6
|
+
it "should store a title" do
|
7
|
+
Nelumba::Feed.new(:title => "My Title").title.must_equal "My Title"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should store a title type" do
|
11
|
+
Nelumba::Feed.new(:title_type => "html").title_type.must_equal "html"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should store a subtitle" do
|
15
|
+
Nelumba::Feed.new(:subtitle => "My Title").subtitle.must_equal "My Title"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should store a subtitle type" do
|
19
|
+
Nelumba::Feed.new(:subtitle_type => "html").subtitle_type.must_equal "html"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should store a list of categories" do
|
23
|
+
category = mock('category')
|
24
|
+
Nelumba::Feed.new(:categories => [category]).categories.must_equal [category]
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should store a list of authors" do
|
28
|
+
author = mock('author')
|
29
|
+
Nelumba::Feed.new(:authors => [author]).authors.must_equal [author]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should store a list of contributors" do
|
33
|
+
author = mock('author')
|
34
|
+
Nelumba::Feed.new(:contributors => [author]).contributors.must_equal [author]
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should store a list of items" do
|
38
|
+
entry = mock('entry')
|
39
|
+
Nelumba::Feed.new(:items => [entry]).items.must_equal [entry]
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should store a list of hubs" do
|
43
|
+
Nelumba::Feed.new(:hubs => ["http://hub.example.com"]).hubs
|
44
|
+
.must_equal ["http://hub.example.com"]
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should store the id of the feed" do
|
48
|
+
Nelumba::Feed.new(:uid => "id").uid.must_equal "id"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should store the icon for the feed" do
|
52
|
+
Nelumba::Feed.new(:icon => "url").icon.must_equal "url"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should store the logo for the feed" do
|
56
|
+
Nelumba::Feed.new(:logo => "url").logo.must_equal "url"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should store the rights for the feed" do
|
60
|
+
Nelumba::Feed.new(:rights => "url").rights.must_equal "url"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should store the url for the feed" do
|
64
|
+
Nelumba::Feed.new(:url => "url").url.must_equal "url"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should store the published date" do
|
68
|
+
time = mock('date')
|
69
|
+
Nelumba::Feed.new(:published => time).published.must_equal time
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should store the updated date" do
|
73
|
+
time = mock('date')
|
74
|
+
Nelumba::Feed.new(:updated => time).updated.must_equal time
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should store the salmon url for the feed" do
|
78
|
+
Nelumba::Feed.new(:salmon_url => "url").salmon_url.must_equal "url"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should store the generator for the feed" do
|
82
|
+
Nelumba::Feed.new(:generator => "feedmaker").generator.must_equal "feedmaker"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should yield an empty array for categories by default" do
|
86
|
+
Nelumba::Feed.new.categories.must_equal []
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should yield an empty array for authors by default" do
|
90
|
+
Nelumba::Feed.new.authors.must_equal []
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should yield an empty array for contributors by default" do
|
94
|
+
Nelumba::Feed.new.contributors.must_equal []
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should yield an empty array for items by default" do
|
98
|
+
Nelumba::Feed.new.items.must_equal []
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should yield an empty array for hubs by default" do
|
102
|
+
Nelumba::Feed.new.hubs.must_equal []
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should yield a title of 'Untitled' by default" do
|
106
|
+
Nelumba::Feed.new.title.must_equal "Untitled"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "#to_link" do
|
111
|
+
it "should return a Nelumba::Link" do
|
112
|
+
link = mock('link')
|
113
|
+
Nelumba::Link.stubs(:new).returns(link)
|
114
|
+
Nelumba::Feed.new.to_link.must_equal link
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should by default use the title of the feed" do
|
118
|
+
Nelumba::Link.expects(:new).with(has_entry(:title, "title"))
|
119
|
+
Nelumba::Feed.new(:title => "title").to_link
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should by default use the url of the feed as the href" do
|
123
|
+
Nelumba::Link.expects(:new).with(has_entry(:href, "http://example.com"))
|
124
|
+
Nelumba::Feed.new(:url => "http://example.com").to_link
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should override the title of the feed when given" do
|
128
|
+
Nelumba::Link.expects(:new).with(has_entry(:title, "new title"))
|
129
|
+
Nelumba::Feed.new(:title => "title").to_link(:title => "new title")
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should override the url of the feed when given" do
|
133
|
+
Nelumba::Link.expects(:new).with(has_entry(:url, "http://feeds.example.com"))
|
134
|
+
Nelumba::Feed.new(:url => "http://example.com")
|
135
|
+
.to_link(:url => "http://feeds.example.com")
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should pass through the rel option" do
|
139
|
+
Nelumba::Link.expects(:new).with(has_entry(:rel, "alternate"))
|
140
|
+
Nelumba::Feed.new.to_link(:rel => "alternate")
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should pass through the hreflang option" do
|
144
|
+
Nelumba::Link.expects(:new).with(has_entry(:hreflang, "en_us"))
|
145
|
+
Nelumba::Feed.new.to_link(:hreflang => "en_us")
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should pass through the length option" do
|
149
|
+
Nelumba::Link.expects(:new).with(has_entry(:length, 12345))
|
150
|
+
Nelumba::Feed.new.to_link(:length => 12345)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should pass through the type option" do
|
154
|
+
Nelumba::Link.expects(:new).with(has_entry(:type, "html"))
|
155
|
+
Nelumba::Feed.new.to_link(:type => "html")
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "#to_hash" do
|
160
|
+
it "should return a Hash containing the title" do
|
161
|
+
Nelumba::Feed.new(:title => "My Title").to_hash[:title].must_equal "My Title"
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should return a Hash containing the title type" do
|
165
|
+
Nelumba::Feed.new(:title_type => "html").to_hash[:title_type].must_equal "html"
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should return a Hash containing the subtitle" do
|
169
|
+
Nelumba::Feed.new(:subtitle => "My Title").to_hash[:subtitle].must_equal "My Title"
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should return a Hash containing the subtitle type" do
|
173
|
+
Nelumba::Feed.new(:subtitle_type => "html").to_hash[:subtitle_type].must_equal "html"
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should return a Hash containing a list of categories" do
|
177
|
+
category = mock('category')
|
178
|
+
Nelumba::Feed.new(:categories => [category]).to_hash[:categories].must_equal [category]
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should return a Hash containing a list of authors" do
|
182
|
+
author = mock('author')
|
183
|
+
Nelumba::Feed.new(:authors => [author]).to_hash[:authors].must_equal [author]
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should return a Hash containing a list of contributors" do
|
187
|
+
author = mock('author')
|
188
|
+
Nelumba::Feed.new(:contributors => [author]).to_hash[:contributors].must_equal [author]
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should return a Hash containing a list of items" do
|
192
|
+
entry = mock('entry')
|
193
|
+
Nelumba::Feed.new(:items => [entry]).to_hash[:items].must_equal [entry]
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should return a Hash containing a list of hubs" do
|
197
|
+
Nelumba::Feed.new(:hubs => ["hub1", "hub2"]).to_hash[:hubs]
|
198
|
+
.must_equal ["hub1", "hub2"]
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should return a Hash containing the id of the feed" do
|
202
|
+
Nelumba::Feed.new(:uid => "id").to_hash[:uid].must_equal "id"
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should return a Hash containing the icon for the feed" do
|
206
|
+
Nelumba::Feed.new(:icon => "url").to_hash[:icon].must_equal "url"
|
207
|
+
end
|
208
|
+
|
209
|
+
it "should return a Hash containing the logo for the feed" do
|
210
|
+
Nelumba::Feed.new(:logo => "url").to_hash[:logo].must_equal "url"
|
211
|
+
end
|
212
|
+
|
213
|
+
it "should return a Hash containing the rights for the feed" do
|
214
|
+
Nelumba::Feed.new(:rights => "CC0").to_hash[:rights].must_equal "CC0"
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should return a Hash containing the url for the feed" do
|
218
|
+
Nelumba::Feed.new(:url => "url").to_hash[:url].must_equal "url"
|
219
|
+
end
|
220
|
+
|
221
|
+
it "should return a Hash containing the salmon url for the feed" do
|
222
|
+
Nelumba::Feed.new(:salmon_url => "url").to_hash[:salmon_url].must_equal "url"
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should return a Hash containing the published date" do
|
226
|
+
time = mock('date')
|
227
|
+
Nelumba::Feed.new(:published => time).to_hash[:published].must_equal time
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should return a Hash containing the updated date" do
|
231
|
+
time = mock('date')
|
232
|
+
Nelumba::Feed.new(:updated => time).to_hash[:updated].must_equal time
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should return a Hash containing the generator" do
|
236
|
+
Nelumba::Feed.new(:generator => "feedmaker").to_hash[:generator].must_equal "feedmaker"
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
describe "#to_atom" do
|
241
|
+
it "should relegate Atom generation to Nelumba::Atom::Feed" do
|
242
|
+
atom_entry = mock('atom')
|
243
|
+
atom_entry.expects(:to_xml).returns("ATOM")
|
244
|
+
|
245
|
+
require_relative '../lib/nelumba/atom/feed.rb'
|
246
|
+
|
247
|
+
Nelumba::Atom::Feed.stubs(:new).returns(atom_entry)
|
248
|
+
|
249
|
+
Nelumba::Feed.new(:title => "foo").to_atom.must_equal "ATOM"
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|