|
6 | 6 | end
|
7 | 7 |
|
8 | 8 | describe '#entry' do
|
9 |
| - pending |
| 9 | + it 'creates an entry' do |
| 10 | + expect(used_in_builder { |xml| helper.entry(xml) }).to match '<entry/>' |
| 11 | + end |
10 | 12 | end
|
11 | 13 |
|
12 | 14 | describe '#feed' do
|
13 |
| - pending |
| 15 | + it 'creates a feed' do |
| 16 | + expect(used_in_builder { |xml| helper.feed(xml) }).to match '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:media="http://purl.org/syndication/atommedia"/>' |
| 17 | + end |
14 | 18 | end
|
15 | 19 |
|
16 | 20 | describe '#unique_id' do
|
17 |
| - pending |
| 21 | + it 'creates an id' do |
| 22 | + time = Time.now |
| 23 | + expect(used_in_builder { |xml| helper.unique_id(xml, time, 1, 'Status') }).to match "<id>#{helper.unique_tag(time, 1, 'Status')}</id>" |
| 24 | + end |
18 | 25 | end
|
19 | 26 |
|
20 | 27 | describe '#simple_id' do
|
21 |
| - pending |
| 28 | + it 'creates an id' do |
| 29 | + expect(used_in_builder { |xml| helper.simple_id(xml, 1) }).to match '<id>1</id>' |
| 30 | + end |
22 | 31 | end
|
23 | 32 |
|
24 | 33 | describe '#published_at' do
|
25 |
| - pending |
| 34 | + it 'creates a published tag' do |
| 35 | + time = Time.now |
| 36 | + expect(used_in_builder { |xml| helper.published_at(xml, time) }).to match "<published>#{time.iso8601}</published>" |
| 37 | + end |
26 | 38 | end
|
27 | 39 |
|
28 | 40 | describe '#updated_at' do
|
29 |
| - pending |
| 41 | + it 'creates an updated tag' do |
| 42 | + time = Time.now |
| 43 | + expect(used_in_builder { |xml| helper.updated_at(xml, time) }).to match "<updated>#{time.iso8601}</updated>" |
| 44 | + end |
30 | 45 | end
|
31 | 46 |
|
32 | 47 | describe '#verb' do
|
33 |
| - pending |
| 48 | + it 'creates an entry' do |
| 49 | + expect(used_with_namespaces { |xml| helper.verb(xml, 'verb') }).to match '<activity:verb>http://activitystrea.ms/schema/1.0/verb</activity:verb>' |
| 50 | + end |
34 | 51 | end
|
35 | 52 |
|
36 | 53 | describe '#content' do
|
37 |
| - pending |
| 54 | + it 'creates a content' do |
| 55 | + expect(used_in_builder { |xml| helper.content(xml, 'foo') }).to match '<content type="html">foo</content>' |
| 56 | + end |
38 | 57 | end
|
39 | 58 |
|
40 | 59 | describe '#title' do
|
41 |
| - pending |
| 60 | + it 'creates a title' do |
| 61 | + expect(used_in_builder { |xml| helper.title(xml, 'foo') }).to match '<title>foo</title>' |
| 62 | + end |
42 | 63 | end
|
43 | 64 |
|
44 | 65 | describe '#author' do
|
45 |
| - pending |
| 66 | + it 'creates an author' do |
| 67 | + expect(used_in_builder { |xml| helper.author(xml) }).to match '<author/>' |
| 68 | + end |
46 | 69 | end
|
47 | 70 |
|
48 | 71 | describe '#target' do
|
49 |
| - pending |
| 72 | + it 'creates a target' do |
| 73 | + expect(used_with_namespaces { |xml| helper.target(xml) }).to match '<activity:object/>' |
| 74 | + end |
50 | 75 | end
|
51 | 76 |
|
52 | 77 | describe '#object_type' do
|
53 |
| - pending |
| 78 | + it 'creates an object type' do |
| 79 | + expect(used_with_namespaces { |xml| helper.object_type(xml, 'test') }).to match '<activity:object-type>http://activitystrea.ms/schema/1.0/test</activity:object-type>' |
| 80 | + end |
54 | 81 | end
|
55 | 82 |
|
56 | 83 | describe '#uri' do
|
57 |
| - pending |
| 84 | + it 'creates a uri' do |
| 85 | + expect(used_in_builder { |xml| helper.uri(xml, 1) }).to match '<uri>1</uri>' |
| 86 | + end |
58 | 87 | end
|
59 | 88 |
|
60 | 89 | describe '#name' do
|
61 |
| - pending |
| 90 | + it 'creates a name' do |
| 91 | + expect(used_in_builder { |xml| helper.name(xml, 1) }).to match '<name>1</name>' |
| 92 | + end |
62 | 93 | end
|
63 | 94 |
|
64 | 95 | describe '#summary' do
|
65 |
| - pending |
| 96 | + it 'creates a summary' do |
| 97 | + expect(used_in_builder { |xml| helper.summary(xml, 1) }).to match '<summary>1</summary>' |
| 98 | + end |
66 | 99 | end
|
67 | 100 |
|
68 | 101 | describe '#subtitle' do
|
69 |
| - pending |
| 102 | + it 'creates a subtitle' do |
| 103 | + expect(used_in_builder { |xml| helper.subtitle(xml, 1) }).to match '<subtitle>1</subtitle>' |
| 104 | + end |
70 | 105 | end
|
71 | 106 |
|
72 | 107 | describe '#link_alternate' do
|
73 |
| - pending |
| 108 | + it 'creates a link' do |
| 109 | + expect(used_in_builder { |xml| helper.link_alternate(xml, 1) }).to match '<link rel="alternate" type="text/html" href="1"/>' |
| 110 | + end |
74 | 111 | end
|
75 | 112 |
|
76 | 113 | describe '#link_self' do
|
77 |
| - pending |
| 114 | + it 'creates a link' do |
| 115 | + expect(used_in_builder { |xml| helper.link_self(xml, 1) }).to match '<link rel="self" type="application/atom+xml" href="1"/>' |
| 116 | + end |
78 | 117 | end
|
79 | 118 |
|
80 | 119 | describe '#link_hub' do
|
81 |
| - pending |
| 120 | + it 'creates a link' do |
| 121 | + expect(used_in_builder { |xml| helper.link_hub(xml, 1) }).to match '<link rel="hub" href="1"/>' |
| 122 | + end |
82 | 123 | end
|
83 | 124 |
|
84 | 125 | describe '#link_salmon' do
|
85 |
| - pending |
| 126 | + it 'creates a link' do |
| 127 | + expect(used_in_builder { |xml| helper.link_salmon(xml, 1) }).to match '<link rel="salmon" href="1"/>' |
| 128 | + end |
86 | 129 | end
|
87 | 130 |
|
88 | 131 | describe '#portable_contact' do
|
89 |
| - pending |
| 132 | + let(:account) { Fabricate(:account, username: 'alice', display_name: 'Alice in Wonderland') } |
| 133 | + |
| 134 | + it 'creates portable contacts entries' do |
| 135 | + expect(used_with_namespaces { |xml| helper.portable_contact(xml, account) }).to match '<poco:displayName>Alice in Wonderland</poco:displayName>' |
| 136 | + end |
90 | 137 | end
|
91 | 138 |
|
92 | 139 | describe '#in_reply_to' do
|
93 |
| - pending |
| 140 | + it 'creates a thread' do |
| 141 | + expect(used_with_namespaces { |xml| helper.in_reply_to(xml, 'uri', 'url') }).to match '<thr:in-reply-to ref="uri" href="url" type="text/html"/>' |
| 142 | + end |
94 | 143 | end
|
95 | 144 |
|
96 | 145 | describe '#link_mention' do
|
97 |
| - pending |
| 146 | + let(:account) { Fabricate(:account, username: 'alice') } |
| 147 | + |
| 148 | + it 'creates a link' do |
| 149 | + expect(used_in_builder { |xml| helper.link_mention(xml, account) }).to match '<link rel="mentioned" href="http://test.host/users/alice"/>' |
| 150 | + end |
98 | 151 | end
|
99 | 152 |
|
100 | 153 | describe '#disambiguate_uri' do
|
|
114 | 167 | end
|
115 | 168 |
|
116 | 169 | describe '#link_avatar' do
|
117 |
| - pending |
| 170 | + let(:account) { Fabricate(:account, username: 'alice') } |
| 171 | + |
| 172 | + it 'creates a link' do |
| 173 | + expect(used_with_namespaces { |xml| helper.link_avatar(xml, account) }).to match '<link rel="avatar" type="" media:width="300" media:height="300" href="http://test.host/assets/avatars/missing.png"/>' |
| 174 | + end |
118 | 175 | end
|
119 | 176 |
|
120 | 177 | describe '#logo' do
|
121 |
| - pending |
| 178 | + it 'creates a logo' do |
| 179 | + expect(used_in_builder { |xml| helper.logo(xml, 1) }).to match '<logo>1</logo>' |
| 180 | + end |
| 181 | + end |
| 182 | + |
| 183 | + def used_in_builder(&block) |
| 184 | + builder = Nokogiri::XML::Builder.new(&block) |
| 185 | + builder.doc.root.to_xml |
| 186 | + end |
| 187 | + |
| 188 | + def used_with_namespaces(&block) |
| 189 | + used_in_builder { |xml| helper.entry(xml, true, &block) } |
122 | 190 | end
|
123 | 191 | end
|
0 commit comments