nelumba 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/file_spec.rb
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require_relative '../lib/nelumba/file.rb'
|
3
|
+
|
4
|
+
describe Nelumba::File do
|
5
|
+
describe "#initialize" do
|
6
|
+
it "should store an author" do
|
7
|
+
author = mock('author')
|
8
|
+
Nelumba::File.new(:author => author).author.must_equal author
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should store content" do
|
12
|
+
Nelumba::File.new(:content => "txt").content.must_equal "txt"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should store the md5" do
|
16
|
+
Nelumba::File.new(:md5 => "txt").md5.must_equal "txt"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should store the file url" do
|
20
|
+
Nelumba::File.new(:file_url => "txt").file_url.must_equal "txt"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should store the mime_type" do
|
24
|
+
Nelumba::File.new(:mime_type => "txt").mime_type.must_equal "txt"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should store the length" do
|
28
|
+
Nelumba::File.new(:length => "txt").length.must_equal "txt"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should store the published date" do
|
32
|
+
time = mock('date')
|
33
|
+
Nelumba::File.new(:published => time).published.must_equal time
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should store the updated date" do
|
37
|
+
time = mock('date')
|
38
|
+
Nelumba::File.new(:updated => time).updated.must_equal time
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should store a display name" do
|
42
|
+
Nelumba::File.new(:display_name => "url")
|
43
|
+
.display_name.must_equal "url"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should store a summary" do
|
47
|
+
Nelumba::File.new(:summary => "url").summary.must_equal "url"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should store a url" do
|
51
|
+
Nelumba::File.new(:url => "url").url.must_equal "url"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should store an id" do
|
55
|
+
Nelumba::File.new(:uid => "id").uid.must_equal "id"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#to_hash" do
|
60
|
+
it "should contain the content" do
|
61
|
+
Nelumba::File.new(:content => "Hello")
|
62
|
+
.to_hash[:content].must_equal "Hello"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should contain the md5" do
|
66
|
+
Nelumba::File.new(:md5 => "txt")
|
67
|
+
.to_hash[:md5].must_equal "txt"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should contain the file url" do
|
71
|
+
Nelumba::File.new(:file_url => "txt")
|
72
|
+
.to_hash[:file_url].must_equal "txt"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should contain the mime_type" do
|
76
|
+
Nelumba::File.new(:mime_type => "txt")
|
77
|
+
.to_hash[:mime_type].must_equal "txt"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should contain the length" do
|
81
|
+
Nelumba::File.new(:length => "txt")
|
82
|
+
.to_hash[:length].must_equal "txt"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should contain the author" do
|
86
|
+
author = mock('Nelumba::Person')
|
87
|
+
Nelumba::File.new(:author => author).to_hash[:author].must_equal author
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should contain the uid" do
|
91
|
+
Nelumba::File.new(:uid => "Hello").to_hash[:uid].must_equal "Hello"
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should contain the url" do
|
95
|
+
Nelumba::File.new(:url => "Hello").to_hash[:url].must_equal "Hello"
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should contain the summary" do
|
99
|
+
Nelumba::File.new(:summary=> "Hello")
|
100
|
+
.to_hash[:summary].must_equal "Hello"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should contain the display name" do
|
104
|
+
Nelumba::File.new(:display_name => "Hello")
|
105
|
+
.to_hash[:display_name].must_equal "Hello"
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should contain the published date" do
|
109
|
+
date = mock('Time')
|
110
|
+
Nelumba::File.new(:published => date).to_hash[:published].must_equal date
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should contain the updated date" do
|
114
|
+
date = mock('Time')
|
115
|
+
Nelumba::File.new(:updated => date).to_hash[:updated].must_equal date
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#to_json" do
|
120
|
+
before do
|
121
|
+
author = Nelumba::Person.new :display_name => "wilkie"
|
122
|
+
@note = Nelumba::File.new :content => "Hello",
|
123
|
+
:author => author,
|
124
|
+
:length => 125,
|
125
|
+
:md5 => "hash",
|
126
|
+
:file_url => "file url",
|
127
|
+
:mime_type => "image/png",
|
128
|
+
:uid => "id",
|
129
|
+
:url => "url",
|
130
|
+
:title => "title",
|
131
|
+
:published => Time.now,
|
132
|
+
:updated => Time.now
|
133
|
+
|
134
|
+
@json = @note.to_json
|
135
|
+
@data = JSON.parse(@json)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should contain the embedded json for the author" do
|
139
|
+
@data["author"].must_equal JSON.parse(@note.author.to_json)
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should contain the md5" do
|
143
|
+
@data["md5"].must_equal @note.md5
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should contain the file_url" do
|
147
|
+
@data["fileUrl"].must_equal @note.file_url
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should contain the mime_type" do
|
151
|
+
@data["mimeType"].must_equal @note.mime_type
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should contain the length" do
|
155
|
+
@data["length"].must_equal @note.length
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should contain a 'file' objectType" do
|
159
|
+
@data["objectType"].must_equal "file"
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should contain the id" do
|
163
|
+
@data["id"].must_equal @note.uid
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should contain the content" do
|
167
|
+
@data["content"].must_equal @note.content
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should contain the url" do
|
171
|
+
@data["url"].must_equal @note.url
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should contain the summary" do
|
175
|
+
@data["summary"].must_equal @note.summary
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should contain the display name" do
|
179
|
+
@data["displayName"].must_equal @note.display_name
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should contain the published date as rfc3339" do
|
183
|
+
@data["published"].must_equal @note.published.to_date.rfc3339 + 'Z'
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should contain the updated date as rfc3339" do
|
187
|
+
@data["updated"].must_equal @note.updated.to_date.rfc3339 + 'Z'
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
data/spec/group_spec.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require_relative '../lib/nelumba/group.rb'
|
3
|
+
|
4
|
+
describe Nelumba::Group do
|
5
|
+
describe "#initialize" do
|
6
|
+
it "should store an author" do
|
7
|
+
author = mock('author')
|
8
|
+
Nelumba::Group.new(:author => author).author.must_equal author
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should store content" do
|
12
|
+
Nelumba::Group.new(:content => "txt").content.must_equal "txt"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should store the published date" do
|
16
|
+
time = mock('date')
|
17
|
+
Nelumba::Group.new(:published => time).published.must_equal time
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should store the updated date" do
|
21
|
+
time = mock('date')
|
22
|
+
Nelumba::Group.new(:updated => time).updated.must_equal time
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should store a display name" do
|
26
|
+
Nelumba::Group.new(:display_name => "url")
|
27
|
+
.display_name.must_equal "url"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should store a summary" do
|
31
|
+
Nelumba::Group.new(:summary => "url").summary.must_equal "url"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should store a url" do
|
35
|
+
Nelumba::Group.new(:url => "url").url.must_equal "url"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should store an id" do
|
39
|
+
Nelumba::Group.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::Group.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::Group.new(:author => author).to_hash[:author].must_equal author
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should contain the uid" do
|
55
|
+
Nelumba::Group.new(:uid => "Hello").to_hash[:uid].must_equal "Hello"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should contain the url" do
|
59
|
+
Nelumba::Group.new(:url => "Hello").to_hash[:url].must_equal "Hello"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should contain the summary" do
|
63
|
+
Nelumba::Group.new(:summary=> "Hello")
|
64
|
+
.to_hash[:summary].must_equal "Hello"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should contain the display name" do
|
68
|
+
Nelumba::Group.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::Group.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::Group.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::Group.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 'group' objectType" do
|
105
|
+
@data["objectType"].must_equal "group"
|
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/helper.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require_relative '../lib/nelumba/identity.rb'
|
3
|
+
|
4
|
+
describe Nelumba::Feed do
|
5
|
+
describe "#initialize" do
|
6
|
+
it "should store a public_key" do
|
7
|
+
Nelumba::Identity.new(:public_key => "key").public_key.must_equal "key"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should store a salmon endpoint" do
|
11
|
+
Nelumba::Identity.new(:salmon_endpoint => "url").salmon_endpoint
|
12
|
+
.must_equal "url"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should store a dialback endpoint" do
|
16
|
+
Nelumba::Identity.new(:dialback_endpoint => "url").dialback_endpoint
|
17
|
+
.must_equal "url"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should store a activity inbox endpoint" do
|
21
|
+
Nelumba::Identity.new(:activity_inbox_endpoint => "url")
|
22
|
+
.activity_inbox_endpoint.must_equal "url"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should store a activity outbox endpoint" do
|
26
|
+
Nelumba::Identity.new(:activity_outbox_endpoint => "url")
|
27
|
+
.activity_outbox_endpoint.must_equal "url"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should store a profile page" do
|
31
|
+
Nelumba::Identity.new(:profile_page => "url").profile_page
|
32
|
+
.must_equal "url"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#to_hash" do
|
37
|
+
it "should return a Hash with the public_key" do
|
38
|
+
Nelumba::Identity.new(:public_key => "key")
|
39
|
+
.to_hash[:public_key].must_equal "key"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return a Hash with the salmon endpoint" do
|
43
|
+
Nelumba::Identity.new(:salmon_endpoint => "url")
|
44
|
+
.to_hash[:salmon_endpoint].must_equal "url"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should return a Hash with the dialback endpoint" do
|
48
|
+
Nelumba::Identity.new(:dialback_endpoint => "url")
|
49
|
+
.to_hash[:dialback_endpoint].must_equal "url"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return a Hash with the activity inbox endpoint" do
|
53
|
+
Nelumba::Identity.new(:activity_inbox_endpoint => "url")
|
54
|
+
.to_hash[:activity_inbox_endpoint].must_equal "url"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should return a Hash with the activity outbox endpoint" do
|
58
|
+
Nelumba::Identity.new(:activity_outbox_endpoint => "url")
|
59
|
+
.to_hash[:activity_outbox_endpoint].must_equal "url"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should return a Hash with the profile page" do
|
63
|
+
Nelumba::Identity.new(:profile_page => "url")
|
64
|
+
.to_hash[:profile_page].must_equal "url"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/spec/image_spec.rb
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require_relative '../lib/nelumba/image.rb'
|
3
|
+
|
4
|
+
describe Nelumba::Image do
|
5
|
+
describe "#initialize" do
|
6
|
+
it "should store an author" do
|
7
|
+
author = mock('author')
|
8
|
+
Nelumba::Image.new(:author => author).author.must_equal author
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should store full_image" do
|
12
|
+
Nelumba::Image.new(:full_image => "txt").full_image.must_equal "txt"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should store content" do
|
16
|
+
Nelumba::Image.new(:content => "txt").content.must_equal "txt"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should store the published date" do
|
20
|
+
time = mock('date')
|
21
|
+
Nelumba::Image.new(:published => time).published.must_equal time
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should store the updated date" do
|
25
|
+
time = mock('date')
|
26
|
+
Nelumba::Image.new(:updated => time).updated.must_equal time
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should store a display name" do
|
30
|
+
Nelumba::Image.new(:display_name => "url")
|
31
|
+
.display_name.must_equal "url"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should store a summary" do
|
35
|
+
Nelumba::Image.new(:summary => "url").summary.must_equal "url"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should store a url" do
|
39
|
+
Nelumba::Image.new(:url => "url").url.must_equal "url"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should store an id" do
|
43
|
+
Nelumba::Image.new(:uid => "id").uid.must_equal "id"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#to_hash" do
|
48
|
+
it "should contain the content" do
|
49
|
+
Nelumba::Image.new(:content => "Hello")
|
50
|
+
.to_hash[:content].must_equal "Hello"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should contain the author" do
|
54
|
+
author = mock('Nelumba::Person')
|
55
|
+
Nelumba::Image.new(:author => author).to_hash[:author].must_equal author
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should contain the full_image" do
|
59
|
+
Nelumba::Image.new(:full_image => "Hello")
|
60
|
+
.to_hash[:full_image].must_equal "Hello"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should contain the uid" do
|
64
|
+
Nelumba::Image.new(:uid => "Hello").to_hash[:uid].must_equal "Hello"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should contain the url" do
|
68
|
+
Nelumba::Image.new(:url => "Hello").to_hash[:url].must_equal "Hello"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should contain the summary" do
|
72
|
+
Nelumba::Image.new(:summary=> "Hello")
|
73
|
+
.to_hash[:summary].must_equal "Hello"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should contain the display name" do
|
77
|
+
Nelumba::Image.new(:display_name => "Hello")
|
78
|
+
.to_hash[:display_name].must_equal "Hello"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should contain the published date" do
|
82
|
+
date = mock('Time')
|
83
|
+
Nelumba::Image.new(:published => date).to_hash[:published].must_equal date
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should contain the updated date" do
|
87
|
+
date = mock('Time')
|
88
|
+
Nelumba::Image.new(:updated => date).to_hash[:updated].must_equal date
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#to_json" do
|
93
|
+
before do
|
94
|
+
author = Nelumba::Person.new :display_name => "wilkie"
|
95
|
+
@note = Nelumba::Image.new :content => "Hello",
|
96
|
+
:author => author,
|
97
|
+
:full_image => "img",
|
98
|
+
:uid => "id",
|
99
|
+
:url => "url",
|
100
|
+
:title => "title",
|
101
|
+
:summary => "foo",
|
102
|
+
:display_name => "meh",
|
103
|
+
:published => Time.now,
|
104
|
+
:updated => Time.now
|
105
|
+
|
106
|
+
@json = @note.to_json
|
107
|
+
@data = JSON.parse(@json)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should contain the embedded json for the author" do
|
111
|
+
@data["author"].must_equal JSON.parse(@note.author.to_json)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should contain a 'image' objectType" do
|
115
|
+
@data["objectType"].must_equal "image"
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should contain the full_image" do
|
119
|
+
@data["fullImage"].must_equal @note.full_image
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should contain the id" do
|
123
|
+
@data["id"].must_equal @note.uid
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should contain the content" do
|
127
|
+
@data["content"].must_equal @note.content
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should contain the url" do
|
131
|
+
@data["url"].must_equal @note.url
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should contain the summary" do
|
135
|
+
@data["summary"].must_equal @note.summary
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should contain the display name" do
|
139
|
+
@data["displayName"].must_equal @note.display_name
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should contain the published date as rfc3339" do
|
143
|
+
@data["published"].must_equal @note.published.to_date.rfc3339 + 'Z'
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should contain the updated date as rfc3339" do
|
147
|
+
@data["updated"].must_equal @note.updated.to_date.rfc3339 + 'Z'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|