atom-tools 0.9.0 → 2.0.5

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.
Files changed (93) hide show
  1. data/COPYING +3 -3
  2. data/README +9 -49
  3. data/Rakefile +65 -62
  4. data/bin/atom-cp +159 -0
  5. data/bin/atom-grep +78 -0
  6. data/bin/atom-post +73 -0
  7. data/bin/atom-purge +82 -0
  8. data/doc/classes/Atom/AttrEl.html +163 -0
  9. data/doc/classes/Atom/Author.html +2 -19
  10. data/doc/classes/Atom/AutodiscoveryFailure.html +111 -0
  11. data/doc/classes/Atom/Categories.html +168 -0
  12. data/doc/classes/Atom/Category.html +10 -1
  13. data/doc/classes/Atom/Collection.html +194 -91
  14. data/doc/classes/Atom/Content.html +42 -1
  15. data/doc/classes/Atom/Contributor.html +2 -8
  16. data/doc/classes/Atom/Control.html +126 -0
  17. data/doc/classes/Atom/Converters.html +571 -0
  18. data/doc/classes/Atom/DigestAuth.html +285 -0
  19. data/doc/classes/Atom/Element.html +673 -106
  20. data/doc/classes/Atom/FileCache.html +287 -0
  21. data/doc/classes/Atom/HTTP.html +211 -95
  22. data/doc/classes/Atom/HTTPResponse.html +190 -0
  23. data/doc/classes/Atom/HasCategories.html +187 -0
  24. data/doc/classes/Atom/HasLinks.html +168 -0
  25. data/doc/classes/Atom/Link.html +80 -3
  26. data/doc/classes/Atom/NilCache.html +202 -0
  27. data/doc/classes/Atom/ParseError.html +111 -0
  28. data/doc/classes/Atom/Parsers.html +311 -0
  29. data/doc/classes/Atom/Person.html +130 -0
  30. data/doc/classes/Atom/Rights.html +113 -0
  31. data/doc/classes/Atom/Service.html +298 -0
  32. data/doc/{files/lib/atom/yaml_rb.html → classes/Atom/Source.html} +26 -24
  33. data/doc/classes/Atom/Subtitle.html +113 -0
  34. data/doc/classes/Atom/Summary.html +113 -0
  35. data/doc/classes/Atom/Text.html +196 -53
  36. data/doc/classes/Atom/Title.html +113 -0
  37. data/doc/classes/Atom/Tools.html +525 -0
  38. data/doc/classes/Atom/Workspace.html +121 -0
  39. data/doc/classes/Object.html +204 -0
  40. data/doc/created.rid +1 -1
  41. data/doc/files/README.html +9 -49
  42. data/doc/files/lib/atom/cache_rb.html +302 -0
  43. data/doc/files/lib/atom/collection_rb.html +1 -2
  44. data/doc/files/lib/atom/element_rb.html +2 -1
  45. data/doc/files/lib/atom/entry_rb.html +2 -2
  46. data/doc/files/lib/atom/feed_rb.html +1 -2
  47. data/doc/files/lib/atom/http_rb.html +6 -1
  48. data/doc/files/lib/atom/{xml_rb.html → service_rb.html} +8 -6
  49. data/doc/files/lib/atom/text_rb.html +2 -1
  50. data/doc/files/lib/atom/{app_rb.html → tools_rb.html} +4 -6
  51. data/doc/fr_class_index.html +23 -3
  52. data/doc/fr_file_index.html +3 -3
  53. data/doc/fr_method_index.html +111 -36
  54. data/lib/atom/cache.rb +178 -0
  55. data/lib/atom/collection.rb +90 -40
  56. data/lib/atom/element.rb +569 -161
  57. data/lib/atom/entry.rb +63 -89
  58. data/lib/atom/feed.rb +65 -67
  59. data/lib/atom/http.rb +421 -49
  60. data/lib/atom/service.rb +106 -0
  61. data/lib/atom/text.rb +138 -61
  62. data/lib/atom/tools.rb +163 -0
  63. data/spec/entry_spec.rb +364 -0
  64. data/spec/ext_spec.rb +42 -0
  65. data/spec/feed_spec.rb +39 -0
  66. data/spec/fixtures/contacts-feed.xml +34 -0
  67. data/spec/fixtures/entry-w-ext.xml +15 -0
  68. data/spec/fixtures/entry-w-xml.xml +24 -0
  69. data/spec/fixtures/entry.xml +42 -0
  70. data/spec/fixtures/feed-w-ext.xml +33 -0
  71. data/spec/fixtures/service-w-xhtml-ns.xml +21 -0
  72. data/spec/fixtures/service.xml +36 -0
  73. data/spec/service_spec.rb +108 -0
  74. data/spec/spec_helper.rb +9 -0
  75. data/test/conformance/order.rb +11 -10
  76. data/test/conformance/title.rb +9 -9
  77. data/test/conformance/updated.rb +2 -1
  78. data/test/runtests.rb +0 -0
  79. data/test/test_constructs.rb +78 -8
  80. data/test/test_feed.rb +35 -29
  81. data/test/test_general.rb +3 -30
  82. data/test/test_http.rb +248 -34
  83. data/test/test_protocol.rb +143 -24
  84. data/test/test_xml.rb +145 -53
  85. metadata +116 -62
  86. data/bin/atom-client.rb +0 -246
  87. data/bin/atom-server.rb~ +0 -71
  88. data/doc/classes/Atom/App.html +0 -217
  89. data/doc/classes/Atom/Entry.html +0 -365
  90. data/doc/classes/Atom/Feed.html +0 -585
  91. data/lib/atom/app.rb +0 -87
  92. data/lib/atom/xml.rb +0 -200
  93. data/lib/atom/yaml.rb +0 -101
@@ -0,0 +1,108 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ require 'atom/service'
4
+
5
+ describe Atom::Service do
6
+ describe 'when parsing' do
7
+ before(:each) do
8
+ @service = Atom::Service.parse(fixtures(:service))
9
+ end
10
+
11
+ it 'should parse workspace elements correctly' do
12
+ @service.workspaces.length.should == 2
13
+ end
14
+
15
+ it 'should absolutize relative hrefs' do
16
+ svc = Atom::Service.parse(
17
+ fixtures('service-w-xhtml-ns'),
18
+ 'http://example.org/introspection/')
19
+
20
+ coll = svc.workspaces.first.collections.first
21
+ coll.href.should == "http://example.org/entries/?yanel.resource.viewid=atom"
22
+ end
23
+
24
+ it 'should parse XHTML outside the default namespace correctly' do
25
+ xhtml_svc = Atom::Service.parse(fixtures('service-w-xhtml-ns'))
26
+
27
+ xhtml_svc.workspaces.length.should == 2
28
+ xhtml_coll = xhtml_svc.workspaces.last.collections.first
29
+ xhtml_coll.title.html.strip.should == 'Yulup <b>Releases</b>'
30
+ end
31
+ end
32
+ end
33
+
34
+ describe Atom::Workspace do
35
+ describe 'when parsing' do
36
+ before(:each) do
37
+ svc = Atom::Service.parse(fixtures(:service))
38
+ @main = svc.workspaces.first
39
+ @sidebar = svc.workspaces.last
40
+ end
41
+
42
+ it 'should parse title element correctly' do
43
+ @main.title.to_s.should == 'Main Site'
44
+ @sidebar.title.to_s.should == 'Sidebar Blog'
45
+ end
46
+
47
+ it 'should parse collection elements correctly' do
48
+ @main.collections.length.should == 2
49
+ @sidebar.collections.length.should == 1
50
+ end
51
+ end
52
+ end
53
+
54
+ describe Atom::Collection do
55
+ describe 'when parsing' do
56
+ before(:each) do
57
+ svc = Atom::Service.parse(fixtures(:service))
58
+ @entries = svc.workspaces.first.collections.first
59
+ @pictures = svc.workspaces.first.collections.last
60
+ @links = svc.workspaces.last.collections.first
61
+ end
62
+
63
+ it 'should parse href correctly' do
64
+ @entries.href.should == 'http://example.org/blog/main'
65
+ @entries.feed.uri.to_s.should == 'http://example.org/blog/main'
66
+
67
+ @pictures.href.should == 'http://example.org/blog/pic'
68
+ @links.href.should == 'http://example.org/sidebar/list'
69
+ end
70
+
71
+ it 'should parse title element correctly' do
72
+ @entries.title.to_s.should == 'My Blog Entries'
73
+ @pictures.title.to_s.should == 'Pictures'
74
+ @links.title.to_s.should == 'Remaindered Links'
75
+ end
76
+
77
+ it 'should parse accept elements correctly' do
78
+ @entries.accepts.should == ['application/atom+xml;type=entry']
79
+ @pictures.accepts.should == ['image/png', 'image/jpeg', 'image/gif']
80
+ @links.accepts.should == ['application/atom+xml;type=entry']
81
+ end
82
+ end
83
+ end
84
+
85
+ describe Atom::Categories do
86
+ describe 'when parsing' do
87
+ before(:each) do
88
+ svc = Atom::Service.parse(fixtures(:service))
89
+ @ool = svc.workspaces.first.collections.first.categories.first
90
+ @il = svc.workspaces.last.collections.first.categories.first
91
+ end
92
+
93
+ it 'should parse out-of-line categories correctly' do
94
+ @ool.href.should == 'http://example.com/cats/forMain.cats'
95
+ end
96
+
97
+ it 'should parse inline categories correctly' do
98
+ @il.fixed.should be_true
99
+
100
+ @il.list.length.should == 2
101
+
102
+ @il.list.first.scheme.should == 'http://example.org/extra-cats/'
103
+ @il.list.first.term.should == 'joke'
104
+
105
+ @il.list.last.term.should == 'serious'
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+
4
+ $:.unshift 'lib/', File.dirname(__FILE__) + '/../lib'
5
+
6
+ def fixtures(name)
7
+ File.read(File.dirname(__FILE__) + "/fixtures/#{name}.xml")
8
+ end
9
+
@@ -9,23 +9,23 @@ FEED.update!
9
9
  class TestOrderConformance < Test::Unit::TestCase
10
10
  def test_0
11
11
  entry = FEED.entries[0]
12
-
12
+
13
13
  assert_equal "tag:example.org,2006:atom/conformance/element_order/1", entry.id
14
14
  assert_equal "Simple order, nothing fancy", entry.title.to_s
15
15
  assert_equal "Simple ordering, nothing fancy", entry.summary.to_s
16
16
  assert_equal Time.parse("2006-01-26T09:20:01Z"), entry.updated
17
-
17
+
18
18
  assert_alternate_href(entry, "http://www.snellspace.com/public/alternate")
19
19
  end
20
20
 
21
21
  def test_1
22
22
  entry = FEED.entries[1]
23
-
23
+
24
24
  assert_equal "tag:example.org,2006:atom/conformance/element_order/2", entry.id
25
25
  assert_equal "Same as the first, only mixed up a bit", entry.title.to_s
26
26
  assert_equal "Same as the first, only mixed up a bit", entry.summary.to_s
27
27
  assert_equal Time.parse("2006-01-26T09:20:02Z"), entry.updated
28
-
28
+
29
29
  assert_alternate_href(entry, "http://www.snellspace.com/public/alternate")
30
30
  end
31
31
 
@@ -34,8 +34,9 @@ class TestOrderConformance < Test::Unit::TestCase
34
34
  entry = FEED.entries[2]
35
35
 
36
36
  # both links should be available, but it's up to you to choose which one to use
37
+
37
38
  assert_link_href(entry, "http://www.snellspace.com/public/alternate") { |l| l["rel"] == "alternate" and l["type"] == nil }
38
-
39
+
39
40
  assert_link_href(entry, "http://www.snellspace.com/public/alternate2") { |l| l["rel"] == "alternate" and l["type"] == "text/plain" }
40
41
  end
41
42
 
@@ -65,7 +66,7 @@ class TestOrderConformance < Test::Unit::TestCase
65
66
  # ^-- quoted summary is a typo, source is last
66
67
  def test_5
67
68
  entry = FEED.entries[5]
68
-
69
+
69
70
  assert_equal "tag:example.org,2006:atom/conformance/element_order/6", entry.id
70
71
  assert_equal "Entry with a source last", entry.title.to_s
71
72
  assert_equal Time.parse("2006-01-26T09:20:06Z"), entry.updated
@@ -91,18 +92,18 @@ class TestOrderConformance < Test::Unit::TestCase
91
92
  assert_equal "tag:example.org,2006:atom/conformance/element_order/8", entry.id
92
93
  assert_equal "Atom elements in an extension element", entry.title.to_s
93
94
  assert_equal Time.parse("2006-01-26T09:20:08Z"), entry.updated
94
-
95
+
95
96
  assert_alternate_href(entry, "http://www.snellspace.com/public/alternate")
96
97
  end
97
-
98
+
98
99
  # Atom elements in an extension element
99
100
  def test_8
100
101
  entry = FEED.entries[8]
101
-
102
+
102
103
  assert_equal "tag:example.org,2006:atom/conformance/element_order/9", entry.id
103
104
  assert_equal "Atom elements in an extension element", entry.title.to_s
104
105
  assert_equal Time.parse("2006-01-26T09:20:09Z"), entry.updated
105
-
106
+
106
107
  assert_alternate_href(entry, "http://www.snellspace.com/public/alternate")
107
108
  end
108
109
 
@@ -25,18 +25,18 @@ class TestTitleConformance < Test::Unit::TestCase
25
25
  feed.update!
26
26
 
27
27
  entry = feed.entries.first
28
- assert_equal "html", entry.title["type"]
28
+ assert_equal "html", entry.title["type"]
29
29
  assert_equal "&lt;title>", entry.title.html
30
30
  end
31
31
 
32
32
  def test_html_entity
33
33
  url = "http://atomtests.philringnalda.com/tests/item/title/html-entity.atom"
34
-
34
+
35
35
  feed = Atom::Feed.new(url)
36
36
  feed.update!
37
37
 
38
38
  entry = feed.entries.first
39
- assert_equal "html", entry.title["type"]
39
+ assert_equal "html", entry.title["type"]
40
40
  assert_equal "&lt;title>", entry.title.html
41
41
  end
42
42
 
@@ -47,7 +47,7 @@ class TestTitleConformance < Test::Unit::TestCase
47
47
  feed.update!
48
48
 
49
49
  entry = feed.entries.first
50
- assert_equal "html", entry.title["type"]
50
+ assert_equal "html", entry.title["type"]
51
51
  assert_equal "&lt;title>", entry.title.html
52
52
  end
53
53
 
@@ -78,7 +78,7 @@ class TestTitleConformance < Test::Unit::TestCase
78
78
 
79
79
  feed = Atom::Feed.new(url)
80
80
  feed.update!
81
-
81
+
82
82
  entry = feed.entries.first
83
83
  assert_equal "text", entry.title["type"]
84
84
  assert_equal "&lt;title&gt;", entry.title.html
@@ -86,10 +86,10 @@ class TestTitleConformance < Test::Unit::TestCase
86
86
 
87
87
  def test_xhtml_entity
88
88
  url = "http://atomtests.philringnalda.com/tests/item/title/xhtml-entity.atom"
89
-
89
+
90
90
  feed = Atom::Feed.new(url)
91
91
  feed.update!
92
-
92
+
93
93
  entry = feed.entries.first
94
94
  assert_equal "xhtml", entry.title["type"]
95
95
  assert_equal "&lt;title>", entry.title.html
@@ -97,10 +97,10 @@ class TestTitleConformance < Test::Unit::TestCase
97
97
 
98
98
  def test_xhtml_ncr
99
99
  url = "http://atomtests.philringnalda.com/tests/item/title/xhtml-ncr.atom"
100
-
100
+
101
101
  feed = Atom::Feed.new(url)
102
102
  feed.update!
103
-
103
+
104
104
  entry = feed.entries.first
105
105
  assert_equal "xhtml", entry.title["type"]
106
106
  assert_equal "&#60;title>", entry.title.html
@@ -16,7 +16,8 @@ class TestUpdatedConformance < Test::Unit::TestCase
16
16
 
17
17
  # this is an insignificant change,
18
18
  # (ie. atom:updated_1 == atom:updated_2),
19
- # but that's for you to handle
19
+ #
20
+ # the update is applied, your application can handle that however it wants.
20
21
  feed.update!
21
22
  assert_equal "12 of 13 miner<b>s</b> survive mine collapse", feed.entries.first.content.to_s.strip
22
23
 
data/test/runtests.rb CHANGED
File without changes
@@ -2,11 +2,54 @@ require "test/unit"
2
2
  require "atom/entry"
3
3
 
4
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
+
5
48
  def test_text_construct_text
6
49
  entry = Atom::Entry.new
7
50
 
8
- assert_nil(entry.title)
9
- assert_equal("", entry.title.to_s)
51
+ assert_nil entry.title
52
+ assert_equal "", entry.title.to_s
10
53
 
11
54
  entry.title = "<3"
12
55
 
@@ -30,7 +73,7 @@ class ConstructTest < Test::Unit::TestCase
30
73
  assert_equal "html", entry.title["type"]
31
74
  assert_equal "<3", entry.title.to_s
32
75
  assert_equal "&lt;3", entry.title.html
33
-
76
+
34
77
  title = entry.to_xml.root.children.first
35
78
  assert_equal "<3", title.text
36
79
  =end
@@ -46,9 +89,9 @@ class ConstructTest < Test::Unit::TestCase
46
89
  entry = Atom::Entry.new
47
90
 
48
91
  entry.title = "<3"
49
- assert_raises(RuntimeError) { entry.title["type"] = "xhtml" }
50
-
51
- assert_raises(RuntimeError) do
92
+ assert_raises(Atom::ParseError) { entry.title["type"] = "xhtml" }
93
+
94
+ assert_raises(Atom::ParseError) do
52
95
  entry.title["type"] = "application/xhtml+xml"
53
96
  end
54
97
 
@@ -81,11 +124,38 @@ class ConstructTest < Test::Unit::TestCase
81
124
  assert_equal("", entry.content.to_s)
82
125
  end
83
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
+
84
152
  require "date"
85
153
  def test_date_construct
154
+ entry = Atom::Entry.new
155
+
86
156
  today = Date.today
87
- time = Atom::Time.new today
157
+ entry.updated = today
88
158
 
89
- assert_match(/^#{today}T00:00:00/, time.to_s)
159
+ assert_match(/^#{today}T00:00:00/, entry.updated.to_s)
90
160
  end
91
161
  end
data/test/test_feed.rb CHANGED
@@ -60,6 +60,8 @@ END
60
60
 
61
61
  def test_update
62
62
  @s.mount_proc("/") do |req,res|
63
+ assert_equal "application/atom+xml", req["Accept"]
64
+
63
65
  res.content_type = "application/atom+xml"
64
66
  res.body = @test_feed
65
67
 
@@ -81,48 +83,52 @@ END
81
83
  assert_equal 1, feed.entries.length
82
84
  end
83
85
 
84
- def test_conditional_get
85
- @s.mount_proc("/") do |req,res|
86
- assert_nil req["If-None-Match"]
87
- assert_nil req["If-Modified-Since"]
88
-
89
- res["Etag"] = '"xyzzy"'
90
- res["Last-Modified"] = 'Wed, 15 Nov 1995 04:58:08 GMT'
91
- res.content_type = "application/atom+xml"
92
- res.body = @test_feed
93
-
94
- @s.stop
86
+ def test_media_types
87
+ c = proc do |c_t|
88
+ @s.mount_proc("/") do |req,res|
89
+ res.content_type = c_t
90
+ res.body = @test_feed
91
+
92
+ @s.stop
93
+ end
94
+ # there's some kind of race condition here that will result in a
95
+ # timeout sometimes. this is a dirty fix.
96
+ sleep 0.5
97
+ one_shot
95
98
  end
96
-
99
+
97
100
  feed = Atom::Feed.new "http://localhost:#{@port}/"
98
101
 
99
- assert_equal 0, feed.entries.length
100
- assert_equal nil, feed.etag
101
- assert_equal nil, feed.last_modified
102
+ # even if it looks like a feed, the server's word is law
103
+ c.call("text/plain")
104
+ assert_raise(Atom::WrongMimetype) { feed.update! }
102
105
 
103
- one_shot
106
+ # a parameter shouldn't change the type
107
+ c.call("application/atom+xml;type=feed")
108
+ assert_nothing_raised { feed.update! }
104
109
 
105
- feed.update!
110
+ # type and subtype are case insensitive (param. attribute names too)
111
+ c.call("ApPliCatIon/ATOM+XML")
112
+ assert_nothing_raised { feed.update! }
106
113
 
107
- assert_equal 1, feed.entries.length
108
- assert_equal '"xyzzy"', feed.etag
109
- assert_equal 'Wed, 15 Nov 1995 04:58:08 GMT', feed.last_modified
114
+ # text/xml isn't the preferred mimetype, but we'll accept it
115
+ c.call("text/xml")
116
+ assert_nothing_raised { feed.update! }
110
117
 
118
+ # same goes for application/xml
119
+ c.call("application/xml")
120
+ assert_nothing_raised { feed.update! }
121
+
122
+ # nil content type
111
123
  @s.mount_proc("/") do |req,res|
112
- assert_equal '"xyzzy"', req["If-None-Match"]
113
- assert_equal 'Wed, 15 Nov 1995 04:58:08 GMT', req["If-Modified-Since"]
124
+ res.body = @test_feed
114
125
 
115
- res.status = 304
116
- res.body = "this hasn't been modified"
117
-
118
126
  @s.stop
119
127
  end
120
-
121
128
  one_shot
122
- feed.update!
123
-
124
- assert_equal 1, feed.entries.length
129
+ assert_raises(Atom::HTTPException) { feed.update! }
125
130
  end
126
131
 
132
+ # prepares the server for a single request
127
133
  def one_shot; Thread.new { @s.start }; end
128
134
  end
data/test/test_general.rb CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  require "test/unit"
4
4
 
5
- require "atom/yaml"
6
- require "atom/xml"
7
-
8
5
  require "atom/feed"
9
6
 
10
7
  class AtomTest < Test::Unit::TestCase
@@ -46,30 +43,6 @@ class AtomTest < Test::Unit::TestCase
46
43
  assert_has_category(xml, "tags")
47
44
  end
48
45
 
49
- def test_snarf_yaml
50
- yaml = """title: testing YAML
51
- authors:
52
- - name: Mr. Safe
53
- uri: http://example.com/
54
- links:
55
- - href: http://atomenabled.org/
56
- content: not much here\
57
- """
58
-
59
- entry = Atom::Entry.from_yaml(yaml)
60
-
61
- assert_equal("testing YAML", entry.title.to_s)
62
-
63
- assert_equal(1, entry.authors.length)
64
- assert_equal("Mr. Safe", entry.authors.first.name)
65
- assert_equal("http://example.com/", entry.authors.first.uri)
66
-
67
- assert_equal(1, entry.links.length)
68
- assert_equal("http://atomenabled.org/", entry.links.first["href"])
69
-
70
- assert_equal("not much here", entry.content.to_s)
71
- end
72
-
73
46
  def assert_has_category xml, term
74
47
  assert_not_nil(REXML::XPath.match(xml, "/entry/category[@term = #{term}]"))
75
48
  end
@@ -85,10 +58,10 @@ content: not much here\
85
58
  def get_elements entry
86
59
  xml = entry.to_xml
87
60
 
88
- assert_equal(entry.to_s, Atom::Entry.parse(xml).to_s)
89
-
61
+ assert_equal(entry.to_s, Atom::Entry.parse(xml).to_s)
62
+
90
63
  base_check xml
91
-
64
+
92
65
  xml
93
66
  end
94
67