thehack-atom-tools 2.0.3
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/COPYING +18 -0
- data/README +65 -0
- data/Rakefile +87 -0
- data/bin/atom-cp +159 -0
- data/bin/atom-grep +78 -0
- data/bin/atom-post +72 -0
- data/bin/atom-purge +82 -0
- data/lib/atom/cache.rb +178 -0
- data/lib/atom/collection.rb +125 -0
- data/lib/atom/element.rb +640 -0
- data/lib/atom/entry.rb +134 -0
- data/lib/atom/feed.rb +223 -0
- data/lib/atom/http.rb +417 -0
- data/lib/atom/service.rb +106 -0
- data/lib/atom/text.rb +231 -0
- data/lib/atom/tools.rb +163 -0
- data/setup.rb +1585 -0
- data/test/conformance/order.rb +118 -0
- data/test/conformance/title.rb +108 -0
- data/test/conformance/updated.rb +34 -0
- data/test/conformance/xhtmlcontentdiv.rb +18 -0
- data/test/conformance/xmlnamespace.rb +54 -0
- data/test/runtests.rb +14 -0
- data/test/test_constructs.rb +161 -0
- data/test/test_feed.rb +134 -0
- data/test/test_general.rb +72 -0
- data/test/test_http.rb +323 -0
- data/test/test_protocol.rb +168 -0
- data/test/test_xml.rb +445 -0
- metadata +83 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
require "test/unit"
|
|
2
|
+
require "atom/feed"
|
|
3
|
+
|
|
4
|
+
# http://www.intertwingly.net/wiki/pie/OrderConformanceTests
|
|
5
|
+
|
|
6
|
+
FEED = Atom::Feed.new("http://www.snellspace.com/public/ordertest.xml")
|
|
7
|
+
FEED.update!
|
|
8
|
+
|
|
9
|
+
class TestOrderConformance < Test::Unit::TestCase
|
|
10
|
+
def test_0
|
|
11
|
+
entry = FEED.entries[0]
|
|
12
|
+
|
|
13
|
+
assert_equal "tag:example.org,2006:atom/conformance/element_order/1", entry.id
|
|
14
|
+
assert_equal "Simple order, nothing fancy", entry.title.to_s
|
|
15
|
+
assert_equal "Simple ordering, nothing fancy", entry.summary.to_s
|
|
16
|
+
assert_equal Time.parse("2006-01-26T09:20:01Z"), entry.updated
|
|
17
|
+
|
|
18
|
+
assert_alternate_href(entry, "http://www.snellspace.com/public/alternate")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_1
|
|
22
|
+
entry = FEED.entries[1]
|
|
23
|
+
|
|
24
|
+
assert_equal "tag:example.org,2006:atom/conformance/element_order/2", entry.id
|
|
25
|
+
assert_equal "Same as the first, only mixed up a bit", entry.title.to_s
|
|
26
|
+
assert_equal "Same as the first, only mixed up a bit", entry.summary.to_s
|
|
27
|
+
assert_equal Time.parse("2006-01-26T09:20:02Z"), entry.updated
|
|
28
|
+
|
|
29
|
+
assert_alternate_href(entry, "http://www.snellspace.com/public/alternate")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Multiple alt link elements, which does your reader show?
|
|
33
|
+
def test_2
|
|
34
|
+
entry = FEED.entries[2]
|
|
35
|
+
|
|
36
|
+
# both links should be available, but it's up to you to choose which one to use
|
|
37
|
+
|
|
38
|
+
assert_link_href(entry, "http://www.snellspace.com/public/alternate") { |l| l["rel"] == "alternate" and l["type"] == nil }
|
|
39
|
+
|
|
40
|
+
assert_link_href(entry, "http://www.snellspace.com/public/alternate2") { |l| l["rel"] == "alternate" and l["type"] == "text/plain" }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Multiple link elements, does your feed reader show the "alternate" correctly? (also checks to see if the reader is paying attention to link rel values)
|
|
44
|
+
def test_3
|
|
45
|
+
entry = FEED.entries[3]
|
|
46
|
+
|
|
47
|
+
assert_alternate_href(entry, "http://www.snellspace.com/public/alternate")
|
|
48
|
+
|
|
49
|
+
assert_link_href(entry, "http://www.snellspace.com/public/related") { |l| l["rel"] == "related" }
|
|
50
|
+
|
|
51
|
+
assert_link_href(entry, "http://www.snellspace.com/public/foo") { |l| l["rel"] == "urn:foo" }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Entry with a source first.. does your feed reader show the right title, updated, and alt link?
|
|
55
|
+
def test_4
|
|
56
|
+
entry = FEED.entries[4]
|
|
57
|
+
|
|
58
|
+
assert_equal "tag:example.org,2006:atom/conformance/element_order/5", entry.id
|
|
59
|
+
assert_equal "Entry with a source first", entry.title.to_s
|
|
60
|
+
assert_equal Time.parse("2006-01-26T09:20:05Z"), entry.updated
|
|
61
|
+
|
|
62
|
+
assert_alternate_href(entry, "http://www.snellspace.com/public/alternate")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Entry with a source first.. does your feed reader show the right title, updated, and alt link?
|
|
66
|
+
# ^-- quoted summary is a typo, source is last
|
|
67
|
+
def test_5
|
|
68
|
+
entry = FEED.entries[5]
|
|
69
|
+
|
|
70
|
+
assert_equal "tag:example.org,2006:atom/conformance/element_order/6", entry.id
|
|
71
|
+
assert_equal "Entry with a source last", entry.title.to_s
|
|
72
|
+
assert_equal Time.parse("2006-01-26T09:20:06Z"), entry.updated
|
|
73
|
+
|
|
74
|
+
assert_alternate_href(entry, "http://www.snellspace.com/public/alternate")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Entry with a source in the middle.. does your feed reader show the right id, title, updated, and alt link?
|
|
78
|
+
def test_6
|
|
79
|
+
entry = FEED.entries[6]
|
|
80
|
+
|
|
81
|
+
assert_equal "tag:example.org,2006:atom/conformance/element_order/7", entry.id
|
|
82
|
+
assert_equal "Entry with a source in the middle", entry.title.to_s
|
|
83
|
+
assert_equal Time.parse("2006-01-26T09:20:07Z"), entry.updated
|
|
84
|
+
|
|
85
|
+
assert_alternate_href(entry, "http://www.snellspace.com/public/alternate")
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Atom elements in an extension element
|
|
89
|
+
def test_7
|
|
90
|
+
entry = FEED.entries[7]
|
|
91
|
+
|
|
92
|
+
assert_equal "tag:example.org,2006:atom/conformance/element_order/8", entry.id
|
|
93
|
+
assert_equal "Atom elements in an extension element", entry.title.to_s
|
|
94
|
+
assert_equal Time.parse("2006-01-26T09:20:08Z"), entry.updated
|
|
95
|
+
|
|
96
|
+
assert_alternate_href(entry, "http://www.snellspace.com/public/alternate")
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Atom elements in an extension element
|
|
100
|
+
def test_8
|
|
101
|
+
entry = FEED.entries[8]
|
|
102
|
+
|
|
103
|
+
assert_equal "tag:example.org,2006:atom/conformance/element_order/9", entry.id
|
|
104
|
+
assert_equal "Atom elements in an extension element", entry.title.to_s
|
|
105
|
+
assert_equal Time.parse("2006-01-26T09:20:09Z"), entry.updated
|
|
106
|
+
|
|
107
|
+
assert_alternate_href(entry, "http://www.snellspace.com/public/alternate")
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def assert_link_href(entry, href, &block)
|
|
111
|
+
link = entry.links.find(&block)
|
|
112
|
+
assert_equal href, link["href"]
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def assert_alternate_href(entry, href)
|
|
116
|
+
assert_link_href(entry, href) { |l| l["rel"] == "alternate" }
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
require "test/unit"
|
|
2
|
+
require "atom/feed"
|
|
3
|
+
|
|
4
|
+
# wiki page at <http://www.intertwingly.net/wiki/pie/TitleConformanceTests>
|
|
5
|
+
|
|
6
|
+
# http://atomtests.philringnalda.com/tests/item/title/html-cdata.atom
|
|
7
|
+
# http://atomtests.philringnalda.com/tests/item/title/html-entity.atom
|
|
8
|
+
# http://atomtests.philringnalda.com/tests/item/title/html-ncr.atom
|
|
9
|
+
# http://atomtests.philringnalda.com/tests/item/title/text-cdata.atom
|
|
10
|
+
# http://atomtests.philringnalda.com/tests/item/title/text-entity.atom
|
|
11
|
+
# http://atomtests.philringnalda.com/tests/item/title/text-ncr.atom
|
|
12
|
+
# http://atomtests.philringnalda.com/tests/item/title/xhtml-entity.atom
|
|
13
|
+
# http://atomtests.philringnalda.com/tests/item/title/xhtml-ncr.atom
|
|
14
|
+
|
|
15
|
+
# I make no attempt to normalize the XML from entry.title.to_s
|
|
16
|
+
# therefore, the direct equalities I do below are unwise.
|
|
17
|
+
# (eg. they *could* return < or < and still be perfectly correct)
|
|
18
|
+
#
|
|
19
|
+
# It shouldn't be a problem unless REXML changes what it encodes.
|
|
20
|
+
class TestTitleConformance < Test::Unit::TestCase
|
|
21
|
+
def test_html_cdata
|
|
22
|
+
url = "http://atomtests.philringnalda.com/tests/item/title/html-cdata.atom"
|
|
23
|
+
|
|
24
|
+
feed = Atom::Feed.new(url)
|
|
25
|
+
feed.update!
|
|
26
|
+
|
|
27
|
+
entry = feed.entries.first
|
|
28
|
+
assert_equal "html", entry.title["type"]
|
|
29
|
+
assert_equal "<title>", entry.title.html
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_html_entity
|
|
33
|
+
url = "http://atomtests.philringnalda.com/tests/item/title/html-entity.atom"
|
|
34
|
+
|
|
35
|
+
feed = Atom::Feed.new(url)
|
|
36
|
+
feed.update!
|
|
37
|
+
|
|
38
|
+
entry = feed.entries.first
|
|
39
|
+
assert_equal "html", entry.title["type"]
|
|
40
|
+
assert_equal "<title>", entry.title.html
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_html_ncr
|
|
44
|
+
url = "http://atomtests.philringnalda.com/tests/item/title/html-ncr.atom"
|
|
45
|
+
|
|
46
|
+
feed = Atom::Feed.new(url)
|
|
47
|
+
feed.update!
|
|
48
|
+
|
|
49
|
+
entry = feed.entries.first
|
|
50
|
+
assert_equal "html", entry.title["type"]
|
|
51
|
+
assert_equal "<title>", entry.title.html
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_text_cdata
|
|
55
|
+
url = "http://atomtests.philringnalda.com/tests/item/title/text-cdata.atom"
|
|
56
|
+
|
|
57
|
+
feed = Atom::Feed.new(url)
|
|
58
|
+
feed.update!
|
|
59
|
+
|
|
60
|
+
entry = feed.entries.first
|
|
61
|
+
assert_equal "text", entry.title["type"]
|
|
62
|
+
assert_equal "<title>", entry.title.html
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_text_entity
|
|
66
|
+
url = "http://atomtests.philringnalda.com/tests/item/title/text-entity.atom"
|
|
67
|
+
|
|
68
|
+
feed = Atom::Feed.new(url)
|
|
69
|
+
feed.update!
|
|
70
|
+
|
|
71
|
+
entry = feed.entries.first
|
|
72
|
+
assert_equal "text", entry.title["type"]
|
|
73
|
+
assert_equal "<title>", entry.title.html
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_text_ncr
|
|
77
|
+
url = "http://atomtests.philringnalda.com/tests/item/title/text-ncr.atom"
|
|
78
|
+
|
|
79
|
+
feed = Atom::Feed.new(url)
|
|
80
|
+
feed.update!
|
|
81
|
+
|
|
82
|
+
entry = feed.entries.first
|
|
83
|
+
assert_equal "text", entry.title["type"]
|
|
84
|
+
assert_equal "<title>", entry.title.html
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_xhtml_entity
|
|
88
|
+
url = "http://atomtests.philringnalda.com/tests/item/title/xhtml-entity.atom"
|
|
89
|
+
|
|
90
|
+
feed = Atom::Feed.new(url)
|
|
91
|
+
feed.update!
|
|
92
|
+
|
|
93
|
+
entry = feed.entries.first
|
|
94
|
+
assert_equal "xhtml", entry.title["type"]
|
|
95
|
+
assert_equal "<title>", entry.title.html
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def test_xhtml_ncr
|
|
99
|
+
url = "http://atomtests.philringnalda.com/tests/item/title/xhtml-ncr.atom"
|
|
100
|
+
|
|
101
|
+
feed = Atom::Feed.new(url)
|
|
102
|
+
feed.update!
|
|
103
|
+
|
|
104
|
+
entry = feed.entries.first
|
|
105
|
+
assert_equal "xhtml", entry.title["type"]
|
|
106
|
+
assert_equal "<title>", entry.title.html
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require "test/unit"
|
|
2
|
+
require "atom/feed"
|
|
3
|
+
|
|
4
|
+
# wiki page at <http://www.intertwingly.net/wiki/pie/UpdatedConformanceTests>
|
|
5
|
+
# test feed at <http://intertwingly.net/testcase/updated.atom>
|
|
6
|
+
|
|
7
|
+
class TestUpdatedConformance < Test::Unit::TestCase
|
|
8
|
+
def test_it_all
|
|
9
|
+
feed = Atom::Feed.new "http://intertwingly.net/testcase/updated.atom"
|
|
10
|
+
|
|
11
|
+
assert_equal [], feed.entries
|
|
12
|
+
|
|
13
|
+
# initial filling
|
|
14
|
+
feed.update!
|
|
15
|
+
assert_equal "12 of 13 miner survive mine collapse", feed.entries.first.content.to_s.strip
|
|
16
|
+
|
|
17
|
+
# this is an insignificant change,
|
|
18
|
+
# (ie. atom:updated_1 == atom:updated_2),
|
|
19
|
+
#
|
|
20
|
+
# the update is applied, your application can handle that however it wants.
|
|
21
|
+
feed.update!
|
|
22
|
+
assert_equal "12 of 13 miner<b>s</b> survive mine collapse", feed.entries.first.content.to_s.strip
|
|
23
|
+
|
|
24
|
+
# now we've got a significant change
|
|
25
|
+
feed.update!
|
|
26
|
+
assert_equal "12 of 13 miners <del>survive</del> <b>killed</b> in mine collapse", feed.entries.first.content.to_s.strip
|
|
27
|
+
|
|
28
|
+
# and now the feed is gone totally
|
|
29
|
+
assert_raises(Atom::FeedGone) do
|
|
30
|
+
feed.update!
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "test/unit"
|
|
2
|
+
require "atom/feed"
|
|
3
|
+
|
|
4
|
+
class TestXHTMLContentDivConformance < Test::Unit::TestCase
|
|
5
|
+
def test_all
|
|
6
|
+
feed = Atom::Feed.new("http://www.franklinmint.fm/2006/06/divtest.atom")
|
|
7
|
+
feed.update!
|
|
8
|
+
|
|
9
|
+
assert_equal "<b>test</b> content", feed.entries.first.content.html
|
|
10
|
+
|
|
11
|
+
e = feed.entries.first.content.xml
|
|
12
|
+
assert_equal "http://www.w3.org/1999/xhtml", e.first.namespace
|
|
13
|
+
assert_equal "b", e.first.name
|
|
14
|
+
assert_equal "test", e.first.text
|
|
15
|
+
|
|
16
|
+
assert_equal " content", e.last.to_s
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require "test/unit"
|
|
2
|
+
require "atom/feed"
|
|
3
|
+
|
|
4
|
+
class TestXMLNamespaceConformance < Test::Unit::TestCase
|
|
5
|
+
def test_baseline
|
|
6
|
+
feed = Atom::Feed.new "http://plasmasturm.org/attic/atom-tests/nondefaultnamespace-baseline.atom"
|
|
7
|
+
feed.update!
|
|
8
|
+
|
|
9
|
+
assert_baseline feed
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def assert_baseline feed
|
|
13
|
+
assert_equal Time.parse("2006-01-18T12:26:54+01:00"), feed.updated
|
|
14
|
+
assert_equal "http://example.org/tests/namespace/result.html", feed.links.first["href"]
|
|
15
|
+
|
|
16
|
+
assert_equal "urn:uuid:f8195e66-863f-11da-9fcb-dd680b0526e0", feed.id
|
|
17
|
+
|
|
18
|
+
assert_equal "Aristotle Pagaltzis", feed.authors.first.name
|
|
19
|
+
assert_equal "pagaltzis@gmx.de", feed.authors.first.email
|
|
20
|
+
|
|
21
|
+
entry = feed.entries.first
|
|
22
|
+
|
|
23
|
+
assert_equal "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a", entry.id
|
|
24
|
+
|
|
25
|
+
assert_equal Time.parse("2006-01-18T12:26:54+01:00"), entry.updated
|
|
26
|
+
assert_equal "http://example.org/tests/namespace/result.html", entry.links.first["href"]
|
|
27
|
+
|
|
28
|
+
# XXX content.html should strip namespace prefixes
|
|
29
|
+
e = entry.content.xml
|
|
30
|
+
|
|
31
|
+
assert_equal "http://www.w3.org/1999/xhtml", e[1].namespace
|
|
32
|
+
assert_equal "p", e[1].name
|
|
33
|
+
assert_equal "For information, see:", e[1].text
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_1
|
|
37
|
+
feed = Atom::Feed.new "http://plasmasturm.org/attic/atom-tests/nondefaultnamespace.atom"
|
|
38
|
+
feed.update!
|
|
39
|
+
|
|
40
|
+
assert_baseline feed
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_2
|
|
44
|
+
feed = Atom::Feed.new "http://plasmasturm.org/attic/atom-tests/nondefaultnamespace-xhtml.atom"
|
|
45
|
+
feed.update!
|
|
46
|
+
|
|
47
|
+
assert_baseline feed
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_3
|
|
51
|
+
assert(false, "I haven't written the last test")
|
|
52
|
+
# XXX FINISHME
|
|
53
|
+
end
|
|
54
|
+
end
|
data/test/runtests.rb
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
require "test/unit"
|
|
2
|
+
require "atom/entry"
|
|
3
|
+
|
|
4
|
+
class ConstructTest < Test::Unit::TestCase
|
|
5
|
+
def test_text_construct_html_to_xml
|
|
6
|
+
begin
|
|
7
|
+
require "hpricot"
|
|
8
|
+
rescue LoadError
|
|
9
|
+
# hpricot isn't installed, just skip this test
|
|
10
|
+
puts "skipping hpricot tests"
|
|
11
|
+
return
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
entry = Atom::Entry.new
|
|
15
|
+
|
|
16
|
+
html = <<END
|
|
17
|
+
<p>Paragraph 1 contains <a href=http://example.org/>a link
|
|
18
|
+
<p>This really is a horrendous mess.
|
|
19
|
+
END
|
|
20
|
+
|
|
21
|
+
entry.content = html
|
|
22
|
+
entry.content["type"] = "html"
|
|
23
|
+
|
|
24
|
+
xhtml = entry.content.xml
|
|
25
|
+
|
|
26
|
+
# Hpricot is imperfect; for now I'll just test that it's parseable
|
|
27
|
+
assert_instance_of REXML::Element, xhtml
|
|
28
|
+
assert_equal 'div', xhtml.name
|
|
29
|
+
|
|
30
|
+
=begin
|
|
31
|
+
assert_equal 2, xhtml.length
|
|
32
|
+
|
|
33
|
+
first = xhtml.first
|
|
34
|
+
assert_equal "p", first.name
|
|
35
|
+
assert_equal 2, first.children.length
|
|
36
|
+
|
|
37
|
+
a = first.children.last
|
|
38
|
+
assert_equal "a", a.name
|
|
39
|
+
assert_equal "http://example.org/", a.attributes["href"]
|
|
40
|
+
assert_equal "a link", a.text
|
|
41
|
+
|
|
42
|
+
last = xhtml.last
|
|
43
|
+
assert_equal "p", last.name
|
|
44
|
+
assert_equal "This really is a horrendous mess.", last.text
|
|
45
|
+
=end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_text_construct_text
|
|
49
|
+
entry = Atom::Entry.new
|
|
50
|
+
|
|
51
|
+
assert_nil entry.title
|
|
52
|
+
assert_equal "", entry.title.to_s
|
|
53
|
+
|
|
54
|
+
entry.title = "<3"
|
|
55
|
+
|
|
56
|
+
assert_equal "text", entry.title["type"]
|
|
57
|
+
assert_equal "<3", entry.title.to_s
|
|
58
|
+
assert_equal "<3", entry.title.html
|
|
59
|
+
|
|
60
|
+
assert_equal "'<3'#text", entry.title.inspect
|
|
61
|
+
|
|
62
|
+
title = entry.to_xml.root.children.first
|
|
63
|
+
assert_equal "<3", title.text
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_text_construct_html
|
|
67
|
+
entry = Atom::Entry.new
|
|
68
|
+
|
|
69
|
+
=begin
|
|
70
|
+
entry.title = "<3"
|
|
71
|
+
entry.title["type"] = "html"
|
|
72
|
+
|
|
73
|
+
assert_equal "html", entry.title["type"]
|
|
74
|
+
assert_equal "<3", entry.title.to_s
|
|
75
|
+
assert_equal "<3", entry.title.html
|
|
76
|
+
|
|
77
|
+
title = entry.to_xml.root.children.first
|
|
78
|
+
assert_equal "<3", title.text
|
|
79
|
+
=end
|
|
80
|
+
|
|
81
|
+
entry.title = "<p>pi < 4?"
|
|
82
|
+
entry.title["type"] = "html"
|
|
83
|
+
|
|
84
|
+
assert_equal "<p>pi < 4?", entry.title.to_s
|
|
85
|
+
assert_equal "<p>pi < 4?", entry.title.html
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_text_construct_xhtml
|
|
89
|
+
entry = Atom::Entry.new
|
|
90
|
+
|
|
91
|
+
entry.title = "<3"
|
|
92
|
+
assert_raises(Atom::ParseError) { entry.title["type"] = "xhtml" }
|
|
93
|
+
|
|
94
|
+
assert_raises(Atom::ParseError) do
|
|
95
|
+
entry.title["type"] = "application/xhtml+xml"
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
entry.title = REXML::Document.new("<div xmlns='http://www.w3.org/1999/xhtml'><3</div>").root
|
|
99
|
+
entry.title["type"] = "xhtml"
|
|
100
|
+
|
|
101
|
+
assert_equal "<3", entry.title.to_s
|
|
102
|
+
assert_equal "<3", entry.title.html
|
|
103
|
+
|
|
104
|
+
entry.title = "<3"
|
|
105
|
+
entry.title["type"] = "xhtml"
|
|
106
|
+
|
|
107
|
+
assert_equal "<3", entry.title.to_s
|
|
108
|
+
assert_equal "<3", entry.title.html
|
|
109
|
+
|
|
110
|
+
entry.title = "<em>goodness</em> gracious"
|
|
111
|
+
entry.title["type"] = "xhtml"
|
|
112
|
+
|
|
113
|
+
assert_equal "<em>goodness</em> gracious", entry.title.to_s
|
|
114
|
+
assert_equal "<em>goodness</em> gracious", entry.title.html
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_content
|
|
118
|
+
entry = Atom::Entry.new
|
|
119
|
+
|
|
120
|
+
entry.content = ""
|
|
121
|
+
entry.content["src"] = "http://example.com/example.svg"
|
|
122
|
+
entry.content["type"] = "image/svg+xml"
|
|
123
|
+
|
|
124
|
+
assert_equal("", entry.content.to_s)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def test_multiple
|
|
128
|
+
entry = Atom::Entry.new
|
|
129
|
+
|
|
130
|
+
link = Atom::Link.new
|
|
131
|
+
link["href"] = "http://example.org/"
|
|
132
|
+
|
|
133
|
+
assert_raises(ArgumentError) { entry.authors << "test" }
|
|
134
|
+
assert_raises(ArgumentError) { entry.authors << link }
|
|
135
|
+
|
|
136
|
+
entry.links << link
|
|
137
|
+
|
|
138
|
+
assert_equal 1, entry.links.length
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def test_nice_multiple
|
|
142
|
+
entry = Atom::Entry.new
|
|
143
|
+
|
|
144
|
+
entry.authors.new :name => 'Brendan Taylor', :email => 'fake@fake.com', :uri => 'http://necronomicorp.com/bct'
|
|
145
|
+
entry.authors.new :name => 'some jerk'
|
|
146
|
+
|
|
147
|
+
assert_equal 2, entry.authors.length
|
|
148
|
+
|
|
149
|
+
assert_equal 'Brendan Taylor', entry.authors.first.name
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
require "date"
|
|
153
|
+
def test_date_construct
|
|
154
|
+
entry = Atom::Entry.new
|
|
155
|
+
|
|
156
|
+
today = Date.today
|
|
157
|
+
entry.updated = today
|
|
158
|
+
|
|
159
|
+
assert_match(/^#{today}T00:00:00/, entry.updated.to_s)
|
|
160
|
+
end
|
|
161
|
+
end
|