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/link_spec.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require_relative '../lib/nelumba/link.rb'
|
3
|
+
|
4
|
+
describe Nelumba::Link do
|
5
|
+
describe "#initialize" do
|
6
|
+
it "should store an href" do
|
7
|
+
Nelumba::Link.new(:href => "object").href.must_equal "object"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should store an type" do
|
11
|
+
Nelumba::Link.new(:type => "html").type.must_equal "html"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should store a hreflang" do
|
15
|
+
Nelumba::Link.new(:hreflang => :follow).hreflang.must_equal :follow
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should store a title" do
|
19
|
+
Nelumba::Link.new(:title => "Title").title.must_equal "Title"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should store a rel" do
|
23
|
+
Nelumba::Link.new(:rel => "alternate").rel.must_equal "alternate"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should store a length" do
|
27
|
+
Nelumba::Link.new(:length => 12345).length.must_equal 12345
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/note_spec.rb
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require_relative '../lib/nelumba/note.rb'
|
3
|
+
|
4
|
+
describe Nelumba::Note do
|
5
|
+
describe "#initialize" do
|
6
|
+
it "should store a title" do
|
7
|
+
Nelumba::Note.new(:title => "My Title").title.must_equal "My Title"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should store an author" do
|
11
|
+
author = mock('author')
|
12
|
+
Nelumba::Note.new(:author => author).author.must_equal author
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should store text" do
|
16
|
+
Nelumba::Note.new(:text => "Hello").text.must_equal "Hello"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should store html" do
|
20
|
+
Nelumba::Note.new(:html => "txt").html.must_equal "txt"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should store the published date" do
|
24
|
+
time = mock('date')
|
25
|
+
Nelumba::Note.new(:published => time).published.must_equal time
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should store the updated date" do
|
29
|
+
time = mock('date')
|
30
|
+
Nelumba::Note.new(:updated => time).updated.must_equal time
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should store a summary" do
|
34
|
+
Nelumba::Note.new(:summary => "url").summary.must_equal "url"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should store a display name" do
|
38
|
+
Nelumba::Note.new(:display_name => "url")
|
39
|
+
.display_name.must_equal "url"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should store a url" do
|
43
|
+
Nelumba::Note.new(:url => "url").url.must_equal "url"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should store an id" do
|
47
|
+
Nelumba::Note.new(:uid => "id").uid.must_equal "id"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should default the text to '' if not given" do
|
51
|
+
Nelumba::Note.new.text.must_equal ''
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should default the title to 'Untitled' if not given" do
|
55
|
+
Nelumba::Note.new.title.must_equal "Untitled"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#to_hash" do
|
60
|
+
it "should contain the text" do
|
61
|
+
Nelumba::Note.new(:text => "Hello").to_hash[:text].must_equal "Hello"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should contain the html" do
|
65
|
+
Nelumba::Note.new(:html => "Hello").to_hash[:html].must_equal "Hello"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should contain the title" do
|
69
|
+
Nelumba::Note.new(:title => "Hello").to_hash[:title].must_equal "Hello"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should contain the author" do
|
73
|
+
author = mock('Nelumba::Person')
|
74
|
+
Nelumba::Note.new(:author => author).to_hash[:author].must_equal author
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should contain the uid" do
|
78
|
+
Nelumba::Note.new(:uid => "Hello").to_hash[:uid].must_equal "Hello"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should contain the url" do
|
82
|
+
Nelumba::Note.new(:url => "Hello").to_hash[:url].must_equal "Hello"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should contain the summary" do
|
86
|
+
Nelumba::Note.new(:summary => "Hello")
|
87
|
+
.to_hash[:summary].must_equal "Hello"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should contain the display name" do
|
91
|
+
Nelumba::Note.new(:display_name => "Hello")
|
92
|
+
.to_hash[:display_name].must_equal "Hello"
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should contain the published date" do
|
96
|
+
date = mock('Time')
|
97
|
+
Nelumba::Note.new(:published => date).to_hash[:published].must_equal date
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should contain the updated date" do
|
101
|
+
date = mock('Time')
|
102
|
+
Nelumba::Note.new(:updated => date).to_hash[:updated].must_equal date
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "#to_json" do
|
107
|
+
before do
|
108
|
+
author = Nelumba::Person.new :display_name => "wilkie"
|
109
|
+
@note = Nelumba::Note.new :text => "Hello",
|
110
|
+
:author => author,
|
111
|
+
:uid => "id",
|
112
|
+
:url => "url",
|
113
|
+
:title => "title",
|
114
|
+
:summary => "foo",
|
115
|
+
:display_name => "meh",
|
116
|
+
:published => Time.now,
|
117
|
+
:updated => Time.now
|
118
|
+
|
119
|
+
@json = @note.to_json
|
120
|
+
@data = JSON.parse(@json)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should contain the embedded json for the author" do
|
124
|
+
@data["author"].must_equal JSON.parse(@note.author.to_json)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should contain a 'note' objectType" do
|
128
|
+
@data["objectType"].must_equal "note"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should contain the id" do
|
132
|
+
@data["id"].must_equal @note.uid
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should contain the content as the html" do
|
136
|
+
@data["content"].must_equal @note.html
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should contain the title" do
|
140
|
+
@data["title"].must_equal @note.title
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should contain the url" do
|
144
|
+
@data["url"].must_equal @note.url
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should contain the summary" do
|
148
|
+
@data["summary"].must_equal @note.summary
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should contain the display_name" do
|
152
|
+
@data["displayName"].must_equal @note.display_name
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should contain the published date as rfc3339" do
|
156
|
+
@data["published"].must_equal @note.published.to_date.rfc3339 + 'Z'
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should contain the updated date as rfc3339" do
|
160
|
+
@data["updated"].must_equal @note.updated.to_date.rfc3339 + 'Z'
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require_relative '../lib/nelumba/notification.rb'
|
3
|
+
|
4
|
+
describe Nelumba::Notification do
|
5
|
+
describe "from_xml" do
|
6
|
+
it "should return nil if source is empty string" do
|
7
|
+
Nelumba::Notification.from_xml("").must_equal(nil)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return nil if source is nil" do
|
11
|
+
Nelumba::Notification.from_xml(nil).must_equal(nil)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "from_data" do
|
16
|
+
it "should relegate for xml mime types" do
|
17
|
+
Nelumba::Notification.expects(:from_xml).times(5)
|
18
|
+
Nelumba::Notification.from_data("content", "xml")
|
19
|
+
Nelumba::Notification.from_data("content", "magic-envelope+xml")
|
20
|
+
Nelumba::Notification.from_data("content", "application/xml")
|
21
|
+
Nelumba::Notification.from_data("content", "application/text+xml")
|
22
|
+
Nelumba::Notification.from_data("content", "application/magic-envelope+xml")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should relegate for json mime types" do
|
26
|
+
Nelumba::Notification.expects(:from_json).times(5)
|
27
|
+
Nelumba::Notification.from_data("content", "json")
|
28
|
+
Nelumba::Notification.from_data("content", "magic-envelope+json")
|
29
|
+
Nelumba::Notification.from_data("content", "application/json")
|
30
|
+
Nelumba::Notification.from_data("content", "application/text+json")
|
31
|
+
Nelumba::Notification.from_data("content", "application/magic-envelope+json")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "from_unfollow" do
|
36
|
+
before do
|
37
|
+
@user = Nelumba::Person.new(:name => "wilkie")
|
38
|
+
@follow = Nelumba::Person.new(:name => "wilkie")
|
39
|
+
@salmon = Nelumba::Notification.from_unfollow(@user, @follow)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should create a new Notification representing the given user author" do
|
43
|
+
@salmon.activity.actor.must_equal @user
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should create a new Notification representing the given user author" do
|
47
|
+
@salmon.activity.object.must_equal @follow
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "from_follow" do
|
52
|
+
before do
|
53
|
+
@user = Nelumba::Person.new(:name => "wilkie")
|
54
|
+
@follow = Nelumba::Person.new(:name => "wilkie")
|
55
|
+
@salmon = Nelumba::Notification.from_follow(@user, @follow)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should create a new Notification representing the given user author" do
|
59
|
+
@salmon.activity.actor.must_equal @user
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should create a new Notification representing the given user author" do
|
63
|
+
@salmon.activity.object.must_equal @follow
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "from_profile_update" do
|
68
|
+
before do
|
69
|
+
@user = Nelumba::Person.new(:name => "wilkie")
|
70
|
+
@salmon = Nelumba::Notification.from_profile_update(@user)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should create a new Notification representing the given user author" do
|
74
|
+
@salmon.activity.actor.must_equal @user
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "account" do
|
79
|
+
before do
|
80
|
+
@user = Nelumba::Person.new(:name => "wilkie", :uri => "acct:wilkie@rstat.us")
|
81
|
+
@follow = Nelumba::Person.new(:name => "wilkie")
|
82
|
+
@salmon = Nelumba::Notification.from_follow(@user, @follow)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should provide the uri of the actor when the uri is an account" do
|
86
|
+
@salmon.account.must_equal @salmon.activity.actor.uri
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/spec/person_spec.rb
ADDED
@@ -0,0 +1,244 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require_relative '../lib/nelumba/person.rb'
|
3
|
+
|
4
|
+
describe Nelumba::Person do
|
5
|
+
describe "#initialize" do
|
6
|
+
it "should store an uri" do
|
7
|
+
Nelumba::Person.new(:uri => "http://example.com/1").uri.must_equal "http://example.com/1"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should store a name" do
|
11
|
+
Nelumba::Person.new(:name => "foo").name.must_equal "foo"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should store a email" do
|
15
|
+
Nelumba::Person.new(:email => "foo@example.com").email.must_equal "foo@example.com"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should store a id" do
|
19
|
+
Nelumba::Person.new(:uid => "1").uid.must_equal "1"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should store a gender" do
|
23
|
+
Nelumba::Person.new(:gender => "androgynous").gender.must_equal "androgynous"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should store nickname" do
|
27
|
+
Nelumba::Person.new(:nickname => "foobar").nickname.must_equal "foobar"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should store the display name" do
|
31
|
+
Nelumba::Person.new(:display_name => "foobar").display_name.must_equal "foobar"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should store the preferred username" do
|
35
|
+
Nelumba::Person.new(:preferred_username => "foobar")
|
36
|
+
.preferred_username.must_equal "foobar"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should store the pronoun" do
|
40
|
+
pronoun = mock('hash')
|
41
|
+
Nelumba::Person.new(:pronoun => pronoun).pronoun.must_equal pronoun
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should store the birthday" do
|
45
|
+
time = mock('datetime')
|
46
|
+
Nelumba::Person.new(:birthday => time).birthday.must_equal time
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should store the anniversary" do
|
50
|
+
time = mock('datetime')
|
51
|
+
Nelumba::Person.new(:anniversary => time).anniversary.must_equal time
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should store the note" do
|
55
|
+
Nelumba::Person.new(:note => "note").note.must_equal "note"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should store the published date" do
|
59
|
+
time = mock('datetime')
|
60
|
+
Nelumba::Person.new(:published => time).published.must_equal time
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should store the updated date" do
|
64
|
+
time = mock('datetime')
|
65
|
+
Nelumba::Person.new(:updated => time).updated.must_equal time
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should store an address hash" do
|
69
|
+
address = mock('hash')
|
70
|
+
Nelumba::Person.new(:address => address).address.must_equal address
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should store an organization hash" do
|
74
|
+
organization = mock('hash')
|
75
|
+
Nelumba::Person.new(:organization => organization).organization.must_equal organization
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should store an extended name hash" do
|
79
|
+
name = mock('hash')
|
80
|
+
Nelumba::Person.new(:extended_name => name).extended_name.must_equal name
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should store an account hash" do
|
84
|
+
account = mock('hash')
|
85
|
+
Nelumba::Person.new(:account => account).account.must_equal account
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#to_hash" do
|
90
|
+
it "should return a Hash containing the uid" do
|
91
|
+
Nelumba::Person.new(:uid => "1").to_hash[:uid].must_equal "1"
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should return a Hash containing the gender" do
|
95
|
+
Nelumba::Person.new(:gender => "androgynous").to_hash[:gender].must_equal "androgynous"
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should return a Hash containing nickname" do
|
99
|
+
Nelumba::Person.new(:nickname => "foobar").to_hash[:nickname].must_equal "foobar"
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should return a Hash containing the display name" do
|
103
|
+
Nelumba::Person.new(:display_name => "foobar").display_name.must_equal "foobar"
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should return a Hash containing the preferred username" do
|
107
|
+
Nelumba::Person.new(:preferred_username => "foobar")
|
108
|
+
.preferred_username.must_equal "foobar"
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should return a Hash containing the preferred username" do
|
112
|
+
pronoun = mock('hash')
|
113
|
+
Nelumba::Person.new(:pronoun => pronoun).to_hash[:pronoun].must_equal pronoun
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should return a Hash containing the birthday" do
|
117
|
+
time = mock('datetime')
|
118
|
+
Nelumba::Person.new(:birthday => time).to_hash[:birthday].must_equal time
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should return a Hash containing the anniversary" do
|
122
|
+
time = mock('datetime')
|
123
|
+
Nelumba::Person.new(:anniversary => time).to_hash[:anniversary].must_equal time
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should return a Hash containing the note" do
|
127
|
+
Nelumba::Person.new(:note => "note").to_hash[:note].must_equal "note"
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should return a Hash containing the published date" do
|
131
|
+
time = mock('datetime')
|
132
|
+
Nelumba::Person.new(:published => time).to_hash[:published].must_equal time
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should return a Hash containing the updated date" do
|
136
|
+
time = mock('datetime')
|
137
|
+
Nelumba::Person.new(:updated => time).to_hash[:updated].must_equal time
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should return a Hash containing the address hash" do
|
141
|
+
address = mock('hash')
|
142
|
+
Nelumba::Person.new(:address => address).to_hash[:address].must_equal address
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should return a Hash containing the organization hash" do
|
146
|
+
organization = mock('hash')
|
147
|
+
Nelumba::Person.new(:organization => organization).to_hash[:organization].must_equal organization
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should return a Hash containing the extended name hash" do
|
151
|
+
name = mock('hash')
|
152
|
+
Nelumba::Person.new(:extended_name => name).to_hash[:extended_name].must_equal name
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should return a Hash containing the account hash" do
|
156
|
+
account = mock('hash')
|
157
|
+
Nelumba::Person.new(:account => account).to_hash[:account].must_equal account
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe "#preferred_display_name" do
|
162
|
+
it "should use display_name over all else" do
|
163
|
+
author = Nelumba::Person.new(:display_name => "display",
|
164
|
+
:name => "name",
|
165
|
+
:preferred_username => "preferred",
|
166
|
+
:nickname => "nickname",
|
167
|
+
:uid => "unique")
|
168
|
+
|
169
|
+
author.preferred_display_name.must_equal "display"
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should use name over all else when display name doesn't exist" do
|
173
|
+
author = Nelumba::Person.new(:name => "name",
|
174
|
+
:preferred_username => "preferred",
|
175
|
+
:nickname => "nickname",
|
176
|
+
:uid => "unique")
|
177
|
+
|
178
|
+
author.preferred_display_name.must_equal "name"
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should use preferred_username when name and display_name don't exist" do
|
182
|
+
author = Nelumba::Person.new(:preferred_username => "preferred",
|
183
|
+
:nickname => "nickname",
|
184
|
+
:uid => "unique")
|
185
|
+
|
186
|
+
author.preferred_display_name.must_equal "preferred"
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should use nickname when it exists and others do not" do
|
190
|
+
author = Nelumba::Person.new(:nickname => "nickname",
|
191
|
+
:uid => "unique")
|
192
|
+
|
193
|
+
author.preferred_display_name.must_equal "nickname"
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should use uid when all else fails" do
|
197
|
+
author = Nelumba::Person.new(:uid => "unique")
|
198
|
+
|
199
|
+
author.preferred_display_name.must_equal "unique"
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe "#preferred_short_name" do
|
204
|
+
it "should use preferred_username over all else" do
|
205
|
+
author = Nelumba::Person.new(:display_name => "display",
|
206
|
+
:name => "name",
|
207
|
+
:preferred_username => "preferred",
|
208
|
+
:nickname => "nickname",
|
209
|
+
:uid => "unique")
|
210
|
+
|
211
|
+
author.preferred_short_name.must_equal "preferred"
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should use nickname over all else when preferred_username name doesn't exist" do
|
215
|
+
author = Nelumba::Person.new(:name => "name",
|
216
|
+
:display_name => "display",
|
217
|
+
:nickname => "nickname",
|
218
|
+
:uid => "unique")
|
219
|
+
|
220
|
+
author.preferred_short_name.must_equal "nickname"
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should use display_name when nickname and preferred_username don't exist" do
|
224
|
+
author = Nelumba::Person.new(:name => "name",
|
225
|
+
:display_name => "display",
|
226
|
+
:uid => "unique")
|
227
|
+
|
228
|
+
author.preferred_short_name.must_equal "display"
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should use name when it exists and others do not" do
|
232
|
+
author = Nelumba::Person.new(:name => "name",
|
233
|
+
:uid => "unique")
|
234
|
+
|
235
|
+
author.preferred_short_name.must_equal "name"
|
236
|
+
end
|
237
|
+
|
238
|
+
it "should use uid when all else fails" do
|
239
|
+
author = Nelumba::Person.new(:uid => "unique")
|
240
|
+
|
241
|
+
author.preferred_short_name.must_equal "unique"
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|