feedtools 0.2.17 → 0.2.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,28 +1,52 @@
1
1
  require 'test/unit'
2
2
  require 'feed_tools'
3
+ require 'feed_tools/helpers/feed_tools_helper'
3
4
 
4
5
  class AtomTest < Test::Unit::TestCase
6
+ include FeedToolsHelper
7
+
5
8
  def setup
6
9
  FeedTools.tidy_enabled = false
7
10
  FeedTools.feed_cache = FeedTools::DatabaseFeedCache
11
+ FeedToolsHelper.default_local_path =
12
+ File.expand_path(
13
+ File.expand_path(File.dirname(__FILE__)) + '/../feeds')
8
14
  end
9
15
 
10
16
  def test_feed_title
11
- feed = FeedTools::Feed.open(
12
- 'http://feedparser.org/tests/wellformed/atom/atom_namespace_1.xml')
13
- assert_equal("Example Atom", feed.title)
14
- feed = FeedTools::Feed.open(
15
- 'http://feedparser.org/tests/wellformed/atom/atom_namespace_2.xml')
16
- assert_equal("Example Atom", feed.title)
17
- feed = FeedTools::Feed.open(
18
- 'http://feedparser.org/tests/wellformed/atom/atom_namespace_3.xml')
19
- assert_equal("Example Atom", feed.title)
20
- feed = FeedTools::Feed.open(
21
- 'http://feedparser.org/tests/wellformed/atom/atom_namespace_4.xml')
22
- assert_equal("Example Atom", feed.title)
23
- feed = FeedTools::Feed.open(
24
- 'http://feedparser.org/tests/wellformed/atom/atom_namespace_5.xml')
25
- assert_equal("Example Atom", feed.title)
17
+ with_feed(:from_file => 'wellformed/atom/atom_namespace_1.xml') { |feed|
18
+ assert_equal("Example Atom", feed.title)
19
+ }
20
+ with_feed(:from_file => 'wellformed/atom/atom_namespace_2.xml') { |feed|
21
+ assert_equal("Example Atom", feed.title)
22
+ }
23
+ with_feed(:from_file => 'wellformed/atom/atom_namespace_3.xml') { |feed|
24
+ assert_equal("Example Atom", feed.title)
25
+ }
26
+ with_feed(:from_file => 'wellformed/atom/atom_namespace_4.xml') { |feed|
27
+ assert_equal("Example Atom", feed.title)
28
+ }
29
+ with_feed(:from_file => 'wellformed/atom/atom_namespace_5.xml') { |feed|
30
+ assert_equal("Example Atom", feed.title)
31
+ }
32
+ with_feed(:from_file => 'wellformed/atom/feed_title_base64.xml') { |feed|
33
+ assert_equal("Example <b>Atom</b>", feed.title)
34
+ }
35
+ with_feed(:from_file =>
36
+ 'wellformed/atom/feed_title_base64_2.xml') { |feed|
37
+ assert_equal("<p>History of the &lt;blink&gt; tag</p>", feed.title)
38
+ }
39
+ end
40
+
41
+ def test_copyright
42
+ with_feed(:from_file =>
43
+ 'wellformed/atom/feed_copyright_base64.xml') { |feed|
44
+ assert_equal("Example <b>Atom</b>", feed.copyright)
45
+ }
46
+ with_feed(:from_file =>
47
+ 'wellformed/atom/feed_copyright_base64_2.xml') { |feed|
48
+ assert_equal("<p>History of the &lt;blink&gt; tag</p>", feed.copyright)
49
+ }
26
50
  end
27
51
 
28
52
  def test_feed_author
@@ -30,4 +54,5 @@ class AtomTest < Test::Unit::TestCase
30
54
  # 'http://feedparser.org/tests/wellformed/atom/atom_namespace_5.xml')
31
55
  # assert_equal("Example Atom", feed.title)
32
56
  end
33
- end
57
+ end
58
+
@@ -1,46 +1,52 @@
1
1
  require 'test/unit'
2
2
  require 'feed_tools'
3
+ require 'feed_tools/helpers/feed_tools_helper'
3
4
 
4
5
  class CdfTest < Test::Unit::TestCase
6
+ include FeedToolsHelper
7
+
5
8
  def setup
6
9
  FeedTools.tidy_enabled = false
7
10
  FeedTools.feed_cache = FeedTools::DatabaseFeedCache
11
+ FeedToolsHelper.default_local_path =
12
+ File.expand_path(
13
+ File.expand_path(File.dirname(__FILE__)) + '/../feeds')
8
14
  end
9
15
 
10
16
  def test_feed_title
11
- feed = FeedTools::Feed.new
12
- feed.feed_data = <<-FEED
17
+ with_feed(:from_data => <<-FEED
13
18
  <CHANNEL>
14
19
  <TITLE>Example Title</TITLE>
15
20
  </CHANNEL>
16
21
  FEED
17
- assert_equal("Example Title", feed.title)
18
- feed = FeedTools::Feed.open(
19
- 'http://feedparser.org/tests/wellformed/cdf/channel_title.xml')
22
+ ) { |feed|
23
+ assert_equal("Example Title", feed.title)
24
+ }
25
+ with_feed(:from_file => 'wellformed/cdf/channel_title.xml') { |feed|
20
26
  assert_equal("Example feed", feed.title)
27
+ }
21
28
  end
22
29
 
23
30
  def test_feed_description
24
- feed = FeedTools::Feed.open(
25
- 'http://feedparser.org/tests/wellformed/cdf/' +
26
- 'channel_abstract_map_description.xml')
27
- assert_equal("Example description", feed.description)
28
- feed = FeedTools::Feed.open(
29
- 'http://feedparser.org/tests/wellformed/cdf/' +
30
- 'channel_abstract_map_tagline.xml')
31
- assert_equal("Example description", feed.tagline)
31
+ with_feed(:from_file => 'wellformed/cdf/channel_abstract_map_description.xml') { |feed|
32
+ assert_equal("Example description", feed.description)
33
+ }
34
+ with_feed(:from_file => 'wellformed/cdf/channel_abstract_map_tagline.xml') { |feed|
35
+ assert_equal("Example description", feed.tagline)
36
+ }
32
37
  end
33
38
 
34
39
  def test_feed_href
35
- feed = FeedTools::Feed.new
36
- feed.feed_data = <<-FEED
40
+ with_feed(:from_data => <<-FEED
37
41
  <CHANNEL HREF="http://www.example.com/">
38
42
  </CHANNEL>
39
43
  FEED
40
- assert_equal("http://www.example.com/", feed.link)
41
- feed = FeedTools::Feed.open(
42
- 'http://feedparser.org/tests/wellformed/cdf/channel_href_map_link.xml')
43
- assert_equal("http://www.example.org/", feed.link)
44
+ ) { |feed|
45
+ assert_equal("http://www.example.com/", feed.link)
46
+ }
47
+ with_feed(:from_file => 'wellformed/cdf/channel_href_map_link.xml') { |feed|
48
+ assert_equal("http://www.example.org/", feed.link)
49
+ }
44
50
  end
45
51
 
46
52
  def test_feed_links
@@ -48,40 +54,39 @@ class CdfTest < Test::Unit::TestCase
48
54
  end
49
55
 
50
56
  def test_feed_images
51
- feed = FeedTools::Feed.new
52
- feed.feed_data = <<-FEED
57
+ with_feed(:from_data => <<-FEED
53
58
  <CHANNEL>
54
59
  <LOGO HREF="http://www.example.com/exampleicon.gif" STYLE="ICON" />
55
60
  <LOGO HREF="http://www.example.com/exampleimage.gif" STYLE="IMAGE" />
56
61
  </CHANNEL>
57
62
  FEED
58
- assert_equal("http://www.example.com/exampleicon.gif", feed.images[0].url)
59
- assert_equal("icon", feed.images[0].style)
60
- assert_equal("http://www.example.com/exampleimage.gif", feed.images[1].url)
61
- assert_equal("image", feed.images[1].style)
63
+ ) { |feed|
64
+ assert_equal("http://www.example.com/exampleicon.gif", feed.images[0].url)
65
+ assert_equal("icon", feed.images[0].style)
66
+ assert_equal("http://www.example.com/exampleimage.gif", feed.images[1].url)
67
+ assert_equal("image", feed.images[1].style)
68
+ }
62
69
  end
63
70
 
64
71
  def test_feed_item_title
65
- feed = FeedTools::Feed.open(
66
- 'http://feedparser.org/tests/wellformed/cdf/item_title.xml')
67
- assert_equal("Example item", feed.items.first.title)
72
+ with_feed(:from_file => 'wellformed/cdf/item_title.xml') { |feed|
73
+ assert_equal("Example item", feed.items.first.title)
74
+ }
68
75
  end
69
76
 
70
77
  def test_feed_item_description
71
- feed = FeedTools::Feed.open(
72
- 'http://feedparser.org/tests/wellformed/cdf/' +
73
- 'item_abstract_map_description.xml')
74
- assert_equal("Example description", feed.items.first.description)
75
- feed = FeedTools::Feed.open(
76
- 'http://feedparser.org/tests/wellformed/cdf/' +
77
- 'item_abstract_map_summary.xml')
78
- assert_equal("Example description", feed.items.first.summary)
78
+ with_feed(:from_file => 'wellformed/cdf/item_abstract_map_description.xml') { |feed|
79
+ assert_equal("Example description", feed.items.first.description)
80
+ }
81
+ with_feed(:from_file => 'wellformed/cdf/item_abstract_map_summary.xml') { |feed|
82
+ assert_equal("Example description", feed.items.first.summary)
83
+ }
79
84
  end
80
85
 
81
86
  def test_feed_item_href
82
- feed = FeedTools::Feed.open(
83
- 'http://feedparser.org/tests/wellformed/cdf/item_href_map_link.xml')
84
- assert_equal("http://www.example.org/", feed.items.first.link)
87
+ with_feed(:from_file => 'wellformed/cdf/item_href_map_link.xml') { |feed|
88
+ assert_equal("http://www.example.org/", feed.items.first.link)
89
+ }
85
90
  end
86
91
 
87
92
  def test_feed_item_links
@@ -89,8 +94,7 @@ class CdfTest < Test::Unit::TestCase
89
94
  end
90
95
 
91
96
  def test_feed_item_images
92
- feed = FeedTools::Feed.new
93
- feed.feed_data = <<-FEED
97
+ with_feed(:from_data => <<-FEED
94
98
  <CHANNEL>
95
99
  <ITEM HREF="http://www.example.com/item">
96
100
  <LOGO HREF="http://www.example.com/exampleicon.gif" STYLE="ICON" />
@@ -98,13 +102,15 @@ class CdfTest < Test::Unit::TestCase
98
102
  </ITEM>
99
103
  </CHANNEL>
100
104
  FEED
101
- assert_equal("http://www.example.com/item",
102
- feed.items.first.link)
103
- assert_equal("http://www.example.com/exampleicon.gif",
104
- feed.items.first.images[0].url)
105
- assert_equal("icon", feed.items.first.images[0].style)
106
- assert_equal("http://www.example.com/exampleimage.gif",
107
- feed.items.first.images[1].url)
108
- assert_equal("image", feed.items.first.images[1].style)
105
+ ) { |feed|
106
+ assert_equal("http://www.example.com/item",
107
+ feed.items.first.link)
108
+ assert_equal("http://www.example.com/exampleicon.gif",
109
+ feed.items.first.images[0].url)
110
+ assert_equal("icon", feed.items.first.images[0].style)
111
+ assert_equal("http://www.example.com/exampleimage.gif",
112
+ feed.items.first.images[1].url)
113
+ assert_equal("image", feed.items.first.images[1].style)
114
+ }
109
115
  end
110
116
  end
@@ -1,7 +1,7 @@
1
1
  require 'test/unit'
2
2
  require 'feed_tools'
3
3
 
4
- class HelperTest < Test::Unit::TestCase
4
+ class GenerationTest < Test::Unit::TestCase
5
5
  def setup
6
6
  FeedTools.tidy_enabled = false
7
7
  FeedTools.feed_cache = FeedTools::DatabaseFeedCache
@@ -5,6 +5,9 @@ class HelperTest < Test::Unit::TestCase
5
5
  def setup
6
6
  FeedTools.tidy_enabled = false
7
7
  FeedTools.feed_cache = FeedTools::DatabaseFeedCache
8
+ FeedToolsHelper.default_local_path =
9
+ File.expand_path(
10
+ File.expand_path(File.dirname(__FILE__)) + '/../feeds')
8
11
  end
9
12
 
10
13
  def test_escape_entities
@@ -32,6 +35,7 @@ class HelperTest < Test::Unit::TestCase
32
35
  end
33
36
 
34
37
  def test_sanitize_html
38
+ assert_equal("<!--foo-->", FeedTools.sanitize_html("<!--foo-->"))
35
39
  end
36
40
 
37
41
  def test_tidy_html
@@ -1,15 +1,20 @@
1
1
  require 'test/unit'
2
2
  require 'feed_tools'
3
+ require 'feed_tools/helpers/feed_tools_helper'
3
4
 
4
5
  class NonStandardTest < Test::Unit::TestCase
6
+ include FeedToolsHelper
7
+
5
8
  def setup
6
9
  FeedTools.tidy_enabled = false
7
10
  FeedTools.feed_cache = FeedTools::DatabaseFeedCache
11
+ FeedToolsHelper.default_local_path =
12
+ File.expand_path(
13
+ File.expand_path(File.dirname(__FILE__)) + '/../feeds')
8
14
  end
9
15
 
10
16
  def test_xss_strict
11
- feed = FeedTools::Feed.new
12
- feed.feed_data = <<-FEED
17
+ with_feed(:from_data => <<-FEED
13
18
  <?xml version="1.0" encoding="iso-8859-1"?>
14
19
  <rss version="2.0/XSS-strict">
15
20
  <channel>
@@ -44,30 +49,31 @@ class NonStandardTest < Test::Unit::TestCase
44
49
  </channel>
45
50
  </rss>
46
51
  FEED
47
- assert_equal("tima thinking outloud.", feed.title)
48
- assert_equal("http://www.timaoutloud.org/", feed.link)
49
- assert_equal("The personal weblog of Timothy Appnel", feed.description)
50
-
51
- assert_equal("OSCON Wrap-Up.", feed.items[0].title)
52
- assert_equal("http://www.timaoutloud.org/archives/000415.html",
53
- feed.items[0].link)
54
- assert_equal(false, feed.items[0].description == nil)
55
-
56
- assert_equal("Write For The People Who Support You.", feed.items[1].title)
57
- assert_equal("http://www.timaoutloud.org/archives/000414.html",
58
- feed.items[1].link)
59
- assert_equal(false, feed.items[1].description == nil)
60
-
61
- assert_equal("tima@OSCON", feed.items[2].title)
62
- assert_equal("http://www.timaoutloud.org/archives/000413.html",
63
- feed.items[2].link)
64
- assert_equal(false, feed.items[2].description == nil)
52
+ ) { |feed|
53
+ assert_equal("tima thinking outloud.", feed.title)
54
+ assert_equal("http://www.timaoutloud.org/", feed.link)
55
+ assert_equal("The personal weblog of Timothy Appnel", feed.description)
56
+
57
+ assert_equal("OSCON Wrap-Up.", feed.items[0].title)
58
+ assert_equal("http://www.timaoutloud.org/archives/000415.html",
59
+ feed.items[0].link)
60
+ assert_equal(false, feed.items[0].description == nil)
61
+
62
+ assert_equal("Write For The People Who Support You.", feed.items[1].title)
63
+ assert_equal("http://www.timaoutloud.org/archives/000414.html",
64
+ feed.items[1].link)
65
+ assert_equal(false, feed.items[1].description == nil)
66
+
67
+ assert_equal("tima@OSCON", feed.items[2].title)
68
+ assert_equal("http://www.timaoutloud.org/archives/000413.html",
69
+ feed.items[2].link)
70
+ assert_equal(false, feed.items[2].description == nil)
71
+ }
65
72
  end
66
73
 
67
74
  def test_rss_30_lite
68
75
  # Delusions of grandeur...
69
- feed = FeedTools::Feed.new
70
- feed.feed_data = <<-FEED
76
+ with_feed(:from_data => <<-FEED
71
77
  <?xml version="1.0" encoding="UTF-8"?>
72
78
  <rss version="3.0" type="lite"
73
79
  source="http://www.rss3.org/files/liteSample.rss">
@@ -116,33 +122,35 @@ class NonStandardTest < Test::Unit::TestCase
116
122
  </channel>
117
123
  </rss>
118
124
  FEED
119
- assert_equal("RSS Version 3", feed.title)
120
- assert_equal("http://www.rss3.org/", feed.link)
121
- assert_equal("This is a sample RSS 3 Lite-type feed", feed.description)
122
- assert_equal("http://no.address/", feed.generator)
123
- assert_equal("en", feed.language)
124
- assert_equal("http://www.rss3.org/files/r1.ico", feed.icon)
125
- assert_equal("Jonathan Avidan 2005 (c)", feed.copyright)
126
- assert_equal(7.day, feed.ttl)
127
- assert_equal("http://www.rss3.org/rss3lite.html", feed.docs)
128
-
129
- assert_equal("RSS 3 Lite First Draft Now Available", feed.items[0].title)
130
- assert_equal("http://www.rss3.org/archive/rss3lite/first_draft.html",
131
- feed.items[0].link)
132
- assert_equal(false, feed.items[0].description == nil)
133
- assert_equal(Time.utc(2005, "Aug", 18, 9, 53, 59), feed.items[0].time)
134
- assert_equal("Jonathan Avidan", feed.items[0].author.name)
135
- assert_equal("jonathan@rss3.org", feed.items[0].author.email)
136
- assert_equal("6457894357689", feed.items[0].guid)
137
-
138
- assert_equal("Welcome to the RSS 3 Official Blog!", feed.items[1].title)
139
- assert_equal("http://www.rss3.org/official_blog/?p=2", feed.items[1].link)
140
- assert_equal(false, feed.items[1].description == nil)
141
- assert_equal("http://www.rss3.org/official_blog/?p=2#comments",
142
- feed.items[1].comments)
143
- assert_equal(Time.utc(2005, "Jul", 27, 14, 34, 51), feed.items[1].time)
144
- assert_equal("Jonathan Avidan", feed.items[1].author.name)
145
- assert_equal("jonathan@rss3.org", feed.items[1].author.email)
146
- assert_equal("http://www.rss3.org/official_blog/?p=2", feed.items[1].guid)
125
+ ) { |feed|
126
+ assert_equal("RSS Version 3", feed.title)
127
+ assert_equal("http://www.rss3.org/", feed.link)
128
+ assert_equal("This is a sample RSS 3 Lite-type feed", feed.description)
129
+ assert_equal("http://no.address/", feed.generator)
130
+ assert_equal("en", feed.language)
131
+ assert_equal("http://www.rss3.org/files/r1.ico", feed.icon)
132
+ assert_equal("Jonathan Avidan 2005 (c)", feed.copyright)
133
+ assert_equal(7.day, feed.ttl)
134
+ assert_equal("http://www.rss3.org/rss3lite.html", feed.docs)
135
+
136
+ assert_equal("RSS 3 Lite First Draft Now Available", feed.items[0].title)
137
+ assert_equal("http://www.rss3.org/archive/rss3lite/first_draft.html",
138
+ feed.items[0].link)
139
+ assert_equal(false, feed.items[0].description == nil)
140
+ assert_equal(Time.utc(2005, "Aug", 18, 9, 53, 59), feed.items[0].time)
141
+ assert_equal("Jonathan Avidan", feed.items[0].author.name)
142
+ assert_equal("jonathan@rss3.org", feed.items[0].author.email)
143
+ assert_equal("6457894357689", feed.items[0].guid)
144
+
145
+ assert_equal("Welcome to the RSS 3 Official Blog!", feed.items[1].title)
146
+ assert_equal("http://www.rss3.org/official_blog/?p=2", feed.items[1].link)
147
+ assert_equal(false, feed.items[1].description == nil)
148
+ assert_equal("http://www.rss3.org/official_blog/?p=2#comments",
149
+ feed.items[1].comments)
150
+ assert_equal(Time.utc(2005, "Jul", 27, 14, 34, 51), feed.items[1].time)
151
+ assert_equal("Jonathan Avidan", feed.items[1].author.name)
152
+ assert_equal("jonathan@rss3.org", feed.items[1].author.email)
153
+ assert_equal("http://www.rss3.org/official_blog/?p=2", feed.items[1].guid)
154
+ }
147
155
  end
148
156
  end
@@ -1,579 +1,553 @@
1
1
  require 'test/unit'
2
2
  require 'feed_tools'
3
+ require 'feed_tools/helpers/feed_tools_helper'
3
4
 
4
5
  class RssTest < Test::Unit::TestCase
6
+ include FeedToolsHelper
7
+
5
8
  def setup
6
9
  FeedTools.tidy_enabled = false
7
10
  FeedTools.feed_cache = FeedTools::DatabaseFeedCache
11
+ FeedToolsHelper.default_local_path =
12
+ File.expand_path(
13
+ File.expand_path(File.dirname(__FILE__)) + '/../feeds')
8
14
  end
9
15
 
10
16
  def test_feed_well_formed
11
- feed = FeedTools::Feed.open(
12
- 'http://feedparser.org/tests/wellformed/rss/aaa_wellformed.xml')
13
- end
17
+ with_feed(:from_file => 'wellformed/rss/aaa_wellformed.xml') { |feed|
18
+ assert_not_nil feed
19
+ }
20
+ end
14
21
 
15
22
  def test_feed_title
16
- feed = FeedTools::Feed.open(
17
- 'http://feedparser.org/tests/wellformed/rss/channel_title.xml')
18
- assert_equal("Example feed", feed.title)
19
- feed = FeedTools::Feed.open(
20
- 'http://feedparser.org/tests/wellformed/rss/channel_title_apos.xml')
21
- assert_equal("Mark's title", feed.title)
22
- feed = FeedTools::Feed.open(
23
- 'http://feedparser.org/tests/wellformed/rss/channel_title_gt.xml')
24
- assert_equal("2 > 1", feed.title)
25
- feed = FeedTools::Feed.open(
26
- 'http://feedparser.org/tests/wellformed/rss/channel_title_lt.xml')
27
- assert_equal("1 < 2", feed.title)
28
- feed = FeedTools::Feed.open(
29
- 'http://feedparser.org/tests/wellformed/rss/channel_dc_title.xml')
30
- assert_equal("Example title", feed.title)
23
+ with_feed(:from_file => 'wellformed/rss/channel_title.xml') { |feed|
24
+ assert_equal("Example feed", feed.title)
25
+ }
26
+ with_feed(:from_file => 'wellformed/rss/channel_title_apos.xml') { |feed|
27
+ assert_equal("Mark's title", feed.title)
28
+ }
29
+ with_feed(:from_file => 'wellformed/rss/channel_title_gt.xml') { |feed|
30
+ assert_equal("2 > 1", feed.title)
31
+ }
32
+ with_feed(:from_file => 'wellformed/rss/channel_title_lt.xml') { |feed|
33
+ assert_equal("1 < 2", feed.title)
34
+ }
35
+ with_feed(:from_file => 'wellformed/rss/channel_dc_title.xml') { |feed|
36
+ assert_equal("Example title", feed.title)
37
+ }
31
38
  end
32
39
 
33
40
  def test_feed_description
34
- feed = FeedTools::Feed.open(
35
- 'http://feedparser.org/tests/wellformed/rss/channel_description.xml')
36
- assert_equal(nil, feed.title)
37
- assert_equal("Example description", feed.description)
38
- feed = FeedTools::Feed.open(
39
- 'http://feedparser.org/tests/wellformed/rss/' +
40
- 'channel_description_escaped_markup.xml')
41
- assert_equal("<p>Example description</p>", feed.description)
42
- feed = FeedTools::Feed.open(
43
- 'http://feedparser.org/tests/wellformed/rss/' +
44
- 'channel_description_map_tagline.xml')
45
- assert_equal("Example description", feed.tagline)
46
- feed = FeedTools::Feed.open(
47
- 'http://feedparser.org/tests/wellformed/rss/' +
48
- 'channel_description_naked_markup.xml')
49
- assert_equal("<p>Example description</p>", feed.description)
50
- feed = FeedTools::Feed.open(
51
- 'http://feedparser.org/tests/wellformed/rss/' +
52
- 'channel_description_shorttag.xml')
53
- assert_equal(nil, feed.description)
54
- assert_equal('http://example.com/', feed.link)
41
+ with_feed(:from_file => 'wellformed/rss/channel_description.xml') { |feed|
42
+ assert_equal(nil, feed.title)
43
+ assert_equal("Example description", feed.description)
44
+ }
45
+ with_feed(:from_file => 'wellformed/rss/channel_description_escaped_markup.xml') { |feed|
46
+ assert_equal("<p>Example description</p>", feed.description)
47
+ }
48
+ with_feed(:from_file => 'wellformed/rss/channel_description_map_tagline.xml') { |feed|
49
+ assert_equal("Example description", feed.tagline)
50
+ }
51
+ with_feed(:from_file => 'wellformed/rss/channel_description_naked_markup.xml') { |feed|
52
+ assert_equal("<p>Example description</p>", feed.description)
53
+ }
54
+ with_feed(:from_file => 'wellformed/rss/channel_description_shorttag.xml') { |feed|
55
+ assert_equal(nil, feed.description)
56
+ assert_equal('http://example.com/', feed.link)
57
+ }
55
58
  end
56
59
 
57
60
  def test_feed_link
58
- feed = FeedTools::Feed.open(
59
- 'http://feedparser.org/tests/wellformed/rss/channel_link.xml')
60
- assert_equal('http://example.com/', feed.link)
61
+ with_feed(:from_file => 'wellformed/rss/channel_link.xml') { |feed|
62
+ assert_equal('http://example.com/', feed.link)
63
+ }
61
64
  end
62
65
 
63
66
  def test_feed_generator
64
- feed = FeedTools::Feed.open(
65
- 'http://feedparser.org/tests/wellformed/rss/channel_generator.xml')
66
- assert_equal("Example generator", feed.generator)
67
+ with_feed(:from_file => 'wellformed/rss/channel_generator.xml') { |feed|
68
+ assert_equal("Example generator", feed.generator)
69
+ }
67
70
  end
68
71
 
69
72
  def test_feed_docs
70
- feed = FeedTools::Feed.open(
71
- 'http://feedparser.org/tests/wellformed/rss/channel_docs.xml')
72
- assert_equal("http://www.example.com/", feed.docs)
73
+ with_feed(:from_file => 'wellformed/rss/channel_docs.xml') { |feed|
74
+ assert_equal("http://www.example.com/", feed.docs)
75
+ }
73
76
  end
74
77
 
75
78
  def test_feed_ttl
76
- feed = FeedTools::Feed.open(
77
- 'http://feedparser.org/tests/wellformed/rss/channel_ttl.xml')
78
- assert_equal(1.hour, feed.ttl)
79
+ with_feed(:from_file => 'wellformed/rss/channel_ttl.xml') { |feed|
80
+ assert_equal(1.hour, feed.ttl)
81
+ }
79
82
  end
80
83
 
81
84
  def test_feed_author
82
- feed = FeedTools::Feed.open(
83
- 'http://feedparser.org/tests/wellformed/rss/channel_author.xml')
84
- assert_equal("Example editor (me@example.com)", feed.author.raw)
85
- assert_equal("Example editor", feed.author.name)
86
- assert_equal("me@example.com", feed.author.email)
87
- assert_equal(nil, feed.author.url)
88
- feed = FeedTools::Feed.open(
89
- 'http://feedparser.org/tests/wellformed/rss/' +
90
- 'channel_author_map_author_detail_email_2.xml')
91
- assert_equal("Example editor (me+spam@example.com)", feed.author.raw)
92
- assert_equal("Example editor", feed.author.name)
93
- assert_equal("me+spam@example.com", feed.author.email)
94
- assert_equal(nil, feed.author.url)
95
- feed = FeedTools::Feed.open(
96
- 'http://feedparser.org/tests/wellformed/rss/' +
97
- 'channel_author_map_author_detail_email_3.xml')
98
- assert_equal("me@example.com (Example editor)", feed.author.raw)
99
- assert_equal("Example editor", feed.author.name)
100
- assert_equal("me@example.com", feed.author.email)
101
- assert_equal(nil, feed.author.url)
102
- feed = FeedTools::Feed.open(
103
- 'http://feedparser.org/tests/wellformed/rss/channel_dc_author.xml')
104
- assert_equal("Example editor", feed.author.raw)
105
- assert_equal("Example editor", feed.author.name)
106
- assert_equal(nil, feed.author.email)
107
- assert_equal(nil, feed.author.url)
108
- feed = FeedTools::Feed.open(
109
- 'http://feedparser.org/tests/wellformed/rss/' +
110
- 'channel_dc_author_map_author_detail_email.xml')
111
- assert_equal("Example editor (me@example.com)", feed.author.raw)
112
- assert_equal("Example editor", feed.author.name)
113
- assert_equal("me@example.com", feed.author.email)
114
- assert_equal(nil, feed.author.url)
115
- feed = FeedTools::Feed.open(
116
- 'http://feedparser.org/tests/wellformed/rss/channel_dc_creator.xml')
117
- assert_equal("Example editor", feed.author.raw)
118
- assert_equal("Example editor", feed.author.name)
119
- assert_equal(nil, feed.author.email)
120
- assert_equal(nil, feed.author.url)
121
- feed = FeedTools::Feed.open(
122
- 'http://feedparser.org/tests/wellformed/rss/' +
123
- 'channel_dc_creator_map_author_detail_email.xml')
124
- assert_equal("Example editor (me@example.com)", feed.author.raw)
125
- assert_equal("Example editor", feed.author.name)
126
- assert_equal("me@example.com", feed.author.email)
127
- assert_equal(nil, feed.author.url)
128
- feed = FeedTools::Feed.open(
129
- 'http://feedparser.org/tests/wellformed/rss/channel_managingEditor.xml')
130
- assert_equal("Example editor", feed.author.raw)
131
- assert_equal("Example editor", feed.author.name)
132
- assert_equal(nil, feed.author.email)
133
- assert_equal(nil, feed.author.url)
134
- feed = FeedTools::Feed.open(
135
- 'http://feedparser.org/tests/wellformed/rss' +
136
- '/channel_managingEditor_map_author_detail_email.xml')
137
- assert_equal("Example editor (me@example.com)", feed.author.raw)
138
- assert_equal("Example editor", feed.author.name)
139
- assert_equal("me@example.com", feed.author.email)
140
- assert_equal(nil, feed.author.url)
85
+ with_feed(:from_file => 'wellformed/rss/channel_author.xml') { |feed|
86
+ assert_equal("Example editor (me@example.com)", feed.author.raw)
87
+ assert_equal("Example editor", feed.author.name)
88
+ assert_equal("me@example.com", feed.author.email)
89
+ assert_equal(nil, feed.author.url)
90
+ }
91
+ with_feed(:from_file => 'wellformed/rss/channel_author_map_author_detail_email_2.xml') { |feed|
92
+ assert_equal("Example editor (me+spam@example.com)", feed.author.raw)
93
+ assert_equal("Example editor", feed.author.name)
94
+ assert_equal("me+spam@example.com", feed.author.email)
95
+ assert_equal(nil, feed.author.url)
96
+ }
97
+ with_feed(:from_file => 'wellformed/rss/channel_author_map_author_detail_email_3.xml') { |feed|
98
+ assert_equal("me@example.com (Example editor)", feed.author.raw)
99
+ assert_equal("Example editor", feed.author.name)
100
+ assert_equal("me@example.com", feed.author.email)
101
+ assert_equal(nil, feed.author.url)
102
+ }
103
+ with_feed(:from_file => 'wellformed/rss/channel_dc_author.xml') { |feed|
104
+ assert_equal("Example editor", feed.author.raw)
105
+ assert_equal("Example editor", feed.author.name)
106
+ assert_equal(nil, feed.author.email)
107
+ assert_equal(nil, feed.author.url)
108
+ }
109
+ with_feed(:from_file => 'wellformed/rss/channel_dc_author_map_author_detail_email.xml') { |feed|
110
+ assert_equal("Example editor (me@example.com)", feed.author.raw)
111
+ assert_equal("Example editor", feed.author.name)
112
+ assert_equal("me@example.com", feed.author.email)
113
+ assert_equal(nil, feed.author.url)
114
+ }
115
+ with_feed(:from_file => 'wellformed/rss/channel_dc_creator.xml') { |feed|
116
+ assert_equal("Example editor", feed.author.raw)
117
+ assert_equal("Example editor", feed.author.name)
118
+ assert_equal(nil, feed.author.email)
119
+ assert_equal(nil, feed.author.url)
120
+ }
121
+ with_feed(:from_file => 'wellformed/rss/channel_dc_creator_map_author_detail_email.xml') { |feed|
122
+ assert_equal("Example editor (me@example.com)", feed.author.raw)
123
+ assert_equal("Example editor", feed.author.name)
124
+ assert_equal("me@example.com", feed.author.email)
125
+ assert_equal(nil, feed.author.url)
126
+ }
127
+ with_feed(:from_file => 'wellformed/rss/channel_managingEditor.xml') { |feed|
128
+ assert_equal("Example editor", feed.author.raw)
129
+ assert_equal("Example editor", feed.author.name)
130
+ assert_equal(nil, feed.author.email)
131
+ assert_equal(nil, feed.author.url)
132
+ }
133
+ with_feed(:from_file => 'wellformed/rss/channel_managingEditor_map_author_detail_email.xml') { |feed|
134
+ assert_equal("Example editor (me@example.com)", feed.author.raw)
135
+ assert_equal("Example editor", feed.author.name)
136
+ assert_equal("me@example.com", feed.author.email)
137
+ assert_equal(nil, feed.author.url)
138
+ }
141
139
  end
142
140
 
143
141
  def test_feed_publisher
144
- feed = FeedTools::Feed.open(
145
- 'http://feedparser.org/tests/wellformed/rss/channel_dc_publisher.xml')
146
- assert_equal("Example editor", feed.publisher.raw)
147
- assert_equal("Example editor", feed.publisher.name)
148
- assert_equal(nil, feed.publisher.email)
149
- assert_equal(nil, feed.publisher.url)
150
- feed = FeedTools::Feed.open(
151
- 'http://feedparser.org/tests/wellformed/rss/' +
152
- 'channel_dc_publisher_email.xml')
153
- assert_equal("Example editor (me@example.com)", feed.publisher.raw)
154
- assert_equal("Example editor", feed.publisher.name)
155
- assert_equal("me@example.com", feed.publisher.email)
156
- assert_equal(nil, feed.publisher.url)
157
- feed = FeedTools::Feed.open(
158
- 'http://feedparser.org/tests/wellformed/rss/channel_webMaster.xml')
159
- assert_equal("Example editor", feed.publisher.raw)
160
- assert_equal("Example editor", feed.publisher.name)
161
- assert_equal(nil, feed.publisher.email)
162
- assert_equal(nil, feed.publisher.url)
163
- feed = FeedTools::Feed.open(
164
- 'http://feedparser.org/tests/wellformed/rss/' +
165
- 'channel_webMaster_email.xml')
166
- assert_equal("Example editor (me@example.com)", feed.publisher.raw)
167
- assert_equal("Example editor", feed.publisher.name)
168
- assert_equal("me@example.com", feed.publisher.email)
169
- assert_equal(nil, feed.publisher.url)
142
+ with_feed(:from_file => 'wellformed/rss/channel_dc_publisher.xml') { |feed|
143
+ assert_equal("Example editor", feed.publisher.raw)
144
+ assert_equal("Example editor", feed.publisher.name)
145
+ assert_equal(nil, feed.publisher.email)
146
+ assert_equal(nil, feed.publisher.url)
147
+ }
148
+ with_feed(:from_file => 'wellformed/rss/channel_dc_publisher_email.xml') { |feed|
149
+ assert_equal("Example editor (me@example.com)", feed.publisher.raw)
150
+ assert_equal("Example editor", feed.publisher.name)
151
+ assert_equal("me@example.com", feed.publisher.email)
152
+ assert_equal(nil, feed.publisher.url)
153
+ }
154
+ with_feed(:from_file => 'wellformed/rss/channel_webMaster.xml') { |feed|
155
+ assert_equal("Example editor", feed.publisher.raw)
156
+ assert_equal("Example editor", feed.publisher.name)
157
+ assert_equal(nil, feed.publisher.email)
158
+ assert_equal(nil, feed.publisher.url)
159
+ }
160
+ with_feed(:from_file => 'wellformed/rss/channel_webMaster_email.xml') { |feed|
161
+ assert_equal("Example editor (me@example.com)", feed.publisher.raw)
162
+ assert_equal("Example editor", feed.publisher.name)
163
+ assert_equal("me@example.com", feed.publisher.email)
164
+ assert_equal(nil, feed.publisher.url)
165
+ }
170
166
  end
171
167
 
172
168
  def test_feed_categories
173
- feed = FeedTools::Feed.open(
174
- 'http://feedparser.org/tests/wellformed/rss/channel_category.xml')
175
- assert_equal(1, feed.categories.size)
176
- assert_equal("Example category", feed.categories.first.value)
177
- feed = FeedTools::Feed.open(
178
- 'http://feedparser.org/tests/wellformed/rss/' +
179
- 'channel_category_domain.xml')
180
- assert_equal(1, feed.categories.size)
181
- assert_equal("Example category", feed.categories.first.value)
182
- assert_equal("http://www.example.com/", feed.categories.first.domain)
183
- feed = FeedTools::Feed.open(
184
- 'http://feedparser.org/tests/wellformed/rss/' +
185
- 'channel_category_multiple.xml')
186
- assert_equal(2, feed.categories.size)
187
- assert_equal("Example category 1", feed.categories[0].value)
188
- assert_equal("http://www.example.com/1", feed.categories[0].domain)
189
- assert_equal("Example category 2", feed.categories[1].value)
190
- assert_equal("http://www.example.com/2", feed.categories[1].domain)
191
- feed = FeedTools::Feed.open(
192
- 'http://feedparser.org/tests/wellformed/rss/' +
193
- 'channel_category_multiple_2.xml')
194
- assert_equal(2, feed.categories.size)
195
- assert_equal("Example category 1", feed.categories[0].value)
196
- assert_equal(nil, feed.categories[0].domain)
197
- assert_equal("Example category 2", feed.categories[1].value)
198
- assert_equal(nil, feed.categories[1].domain)
199
- feed = FeedTools::Feed.open(
200
- 'http://feedparser.org/tests/wellformed/rss/channel_dc_subject.xml')
201
- assert_equal(1, feed.categories.size)
202
- assert_equal("Example category", feed.categories.first.value)
203
- feed = FeedTools::Feed.open(
204
- 'http://feedparser.org/tests/wellformed/rss/' +
205
- 'channel_dc_subject_multiple.xml')
206
- assert_equal(2, feed.categories.size)
207
- assert_equal("Example category 1", feed.categories[0].value)
208
- assert_equal(nil, feed.categories[0].domain)
209
- assert_equal("Example category 2", feed.categories[1].value)
210
- assert_equal(nil, feed.categories[1].domain)
169
+ with_feed(:from_file => 'wellformed/rss/channel_category.xml') { |feed|
170
+ assert_equal(1, feed.categories.size)
171
+ assert_equal("Example category", feed.categories.first.value)
172
+ }
173
+ with_feed(:from_file => 'wellformed/rss/channel_category_domain.xml') { |feed|
174
+ assert_equal(1, feed.categories.size)
175
+ assert_equal("Example category", feed.categories.first.value)
176
+ assert_equal("http://www.example.com/", feed.categories.first.domain)
177
+ }
178
+ with_feed(:from_file => 'wellformed/rss/channel_category_multiple.xml') { |feed|
179
+ assert_equal(2, feed.categories.size)
180
+ assert_equal("Example category 1", feed.categories[0].value)
181
+ assert_equal("http://www.example.com/1", feed.categories[0].domain)
182
+ assert_equal("Example category 2", feed.categories[1].value)
183
+ assert_equal("http://www.example.com/2", feed.categories[1].domain)
184
+ }
185
+ with_feed(:from_file => 'wellformed/rss/channel_category_multiple_2.xml') { |feed|
186
+ assert_equal(2, feed.categories.size)
187
+ assert_equal("Example category 1", feed.categories[0].value)
188
+ assert_equal(nil, feed.categories[0].domain)
189
+ assert_equal("Example category 2", feed.categories[1].value)
190
+ assert_equal(nil, feed.categories[1].domain)
191
+ }
192
+ with_feed(:from_file => 'wellformed/rss/channel_dc_subject.xml') { |feed|
193
+ assert_equal(1, feed.categories.size)
194
+ assert_equal("Example category", feed.categories.first.value)
195
+ }
196
+ with_feed(:from_file => 'wellformed/rss/channel_dc_subject_multiple.xml') { |feed|
197
+ assert_equal(2, feed.categories.size)
198
+ assert_equal("Example category 1", feed.categories[0].value)
199
+ assert_equal(nil, feed.categories[0].domain)
200
+ assert_equal("Example category 2", feed.categories[1].value)
201
+ assert_equal(nil, feed.categories[1].domain)
202
+ }
211
203
  end
212
204
 
213
205
  def test_feed_copyright
214
- feed = FeedTools::Feed.open(
215
- 'http://feedparser.org/tests/wellformed/rss/channel_copyright.xml')
216
- assert_equal("Example copyright", feed.copyright)
217
- feed = FeedTools::Feed.open(
218
- 'http://feedparser.org/tests/wellformed/rss/channel_dc_rights.xml')
219
- assert_equal("Example copyright", feed.copyright)
206
+ with_feed(:from_file => 'wellformed/rss/channel_copyright.xml') { |feed|
207
+ assert_equal("Example copyright", feed.copyright)
208
+ }
209
+ with_feed(:from_file => 'wellformed/rss/channel_dc_rights.xml') { |feed|
210
+ assert_equal("Example copyright", feed.copyright)
211
+ }
220
212
  end
221
213
 
222
214
  def test_feed_cloud
223
- feed = FeedTools::Feed.open(
224
- 'http://feedparser.org/tests/wellformed/rss/channel_cloud_domain.xml')
225
- assert_equal("rpc.sys.com", feed.cloud.domain)
226
- assert_equal(80, feed.cloud.port)
227
- assert_equal("/RPC2", feed.cloud.path)
228
- assert_equal("myCloud.rssPleaseNotify", feed.cloud.register_procedure)
229
- assert_equal("xml-rpc", feed.cloud.protocol)
215
+ with_feed(:from_file => 'wellformed/rss/channel_cloud_domain.xml') { |feed|
216
+ assert_equal("rpc.sys.com", feed.cloud.domain)
217
+ assert_equal(80, feed.cloud.port)
218
+ assert_equal("/RPC2", feed.cloud.path)
219
+ assert_equal("myCloud.rssPleaseNotify", feed.cloud.register_procedure)
220
+ assert_equal("xml-rpc", feed.cloud.protocol)
221
+ }
230
222
  end
231
223
 
232
224
  def test_feed_time_to_live
233
- feed = FeedTools::Feed.open(
234
- 'http://feedparser.org/tests/wellformed/rss/channel_ttl.xml')
235
- assert_equal(1.hour, feed.time_to_live)
225
+ with_feed(:from_file => 'wellformed/rss/channel_ttl.xml') { |feed|
226
+ assert_equal(1.hour, feed.time_to_live)
227
+ }
236
228
  end
237
229
 
238
230
  def test_feed_images
239
- feed = FeedTools::Feed.open(
240
- 'http://feedparser.org/tests/wellformed/rss/' +
241
- 'channel_image_description.xml')
242
- assert_equal("Sample image", feed.images.first.title)
243
- assert_equal("Available in Netscape RSS 0.91",
244
- feed.images.first.description)
245
- assert_equal("http://example.org/url", feed.images.first.url)
246
- assert_equal("http://example.org/link", feed.images.first.link)
247
- assert_equal(80, feed.images.first.width)
248
- assert_equal(15, feed.images.first.height)
231
+ with_feed(:from_file => 'wellformed/rss/channel_image_description.xml') { |feed|
232
+ assert_equal("Sample image", feed.images.first.title)
233
+ assert_equal("Available in Netscape RSS 0.91",
234
+ feed.images.first.description)
235
+ assert_equal("http://example.org/url", feed.images.first.url)
236
+ assert_equal("http://example.org/link", feed.images.first.link)
237
+ assert_equal(80, feed.images.first.width)
238
+ assert_equal(15, feed.images.first.height)
239
+ }
249
240
  end
250
241
 
251
242
  def test_feed_text_input
252
- feed = FeedTools::Feed.open(
253
- 'http://feedparser.org/tests/wellformed/rss/' +
254
- 'channel_textInput_description.xml')
255
- assert_equal("Real title", feed.title)
256
- assert_equal("Real description", feed.description)
257
- assert_equal("textInput title", feed.text_input.title)
258
- assert_equal("textInput description", feed.text_input.description)
259
- assert_equal(nil, feed.text_input.link)
260
- assert_equal(nil, feed.text_input.name)
261
- feed = FeedTools::Feed.open(
262
- 'http://feedparser.org/tests/wellformed/rss/channel_textInput_link.xml')
263
- assert_equal("http://channel.example.com/", feed.link)
264
- assert_equal("http://textinput.example.com/", feed.text_input.link)
265
- assert_equal(nil, feed.text_input.title)
266
- assert_equal(nil, feed.text_input.description)
267
- assert_equal(nil, feed.text_input.name)
268
- feed = FeedTools::Feed.open(
269
- 'http://feedparser.org/tests/wellformed/rss/channel_textInput_name.xml')
270
- assert_equal("textinput name", feed.text_input.name)
271
- assert_equal(nil, feed.text_input.title)
272
- assert_equal(nil, feed.text_input.description)
273
- assert_equal(nil, feed.text_input.link)
243
+ with_feed(:from_file => 'wellformed/rss/channel_textInput_description.xml') { |feed|
244
+ assert_equal("Real title", feed.title)
245
+ assert_equal("Real description", feed.description)
246
+ assert_equal("textInput title", feed.text_input.title)
247
+ assert_equal("textInput description", feed.text_input.description)
248
+ assert_equal(nil, feed.text_input.link)
249
+ assert_equal(nil, feed.text_input.name)
250
+ }
251
+ with_feed(:from_file => 'wellformed/rss/channel_textInput_link.xml') { |feed|
252
+ assert_equal("http://channel.example.com/", feed.link)
253
+ assert_equal("http://textinput.example.com/", feed.text_input.link)
254
+ assert_equal(nil, feed.text_input.title)
255
+ assert_equal(nil, feed.text_input.description)
256
+ assert_equal(nil, feed.text_input.name)
257
+ }
258
+ with_feed(:from_file => 'wellformed/rss/channel_textInput_name.xml') { |feed|
259
+ assert_equal("textinput name", feed.text_input.name)
260
+ assert_equal(nil, feed.text_input.title)
261
+ assert_equal(nil, feed.text_input.description)
262
+ assert_equal(nil, feed.text_input.link)
263
+ }
274
264
  end
275
265
 
276
266
  def test_item_title
277
- feed = FeedTools::Feed.open(
278
- 'http://feedparser.org/tests/wellformed/rss/item_title.xml')
279
- assert_equal("Item 1 title", feed.items.first.title)
280
- assert_equal(nil, feed.items.first.description)
281
- feed = FeedTools::Feed.open(
282
- 'http://feedparser.org/tests/wellformed/rss/item_dc_title.xml')
283
- assert_equal("Example title", feed.items.first.title)
284
- assert_equal(nil, feed.items.first.description)
267
+ with_feed(:from_file => 'wellformed/rss/item_title.xml') { |feed|
268
+ assert_equal("Item 1 title", feed.items.first.title)
269
+ assert_equal(nil, feed.items.first.description)
270
+ }
271
+ with_feed(:from_file => 'wellformed/rss/item_dc_title.xml') { |feed|
272
+ assert_equal("Example title", feed.items.first.title)
273
+ assert_equal(nil, feed.items.first.description)
274
+ }
285
275
  end
286
276
 
287
277
  def test_item_description
288
- feed = FeedTools::Feed.open(
289
- 'http://feedparser.org/tests/wellformed/rss/item_description.xml')
290
- assert_equal('Example description', feed.entries.first.description)
291
- assert_equal(nil, feed.entries.first.title)
292
- feed = FeedTools::Feed.open(
293
- 'http://feedparser.org/tests/wellformed/rss/' +
294
- 'item_description_escaped_markup.xml')
295
- assert_equal('<p>Example description</p>', feed.entries.first.description)
296
- assert_equal(nil, feed.entries.first.title)
297
- feed = FeedTools::Feed.open(
298
- 'http://feedparser.org/tests/wellformed/rss/' +
299
- 'item_description_map_summary.xml')
300
- assert_equal('Example description', feed.entries.first.description)
301
- assert_equal(nil, feed.entries.first.title)
302
- feed = FeedTools::Feed.open(
303
- 'http://feedparser.org/tests/wellformed/rss/' +
304
- 'item_description_naked_markup.xml')
305
- assert_equal('<p>Example description</p>', feed.entries.first.description)
306
- assert_equal(nil, feed.entries.first.title)
307
- feed = FeedTools::Feed.open(
308
- 'http://feedparser.org/tests/wellformed/rss/' +
309
- 'item_description_not_a_doctype.xml')
310
- assert_equal('&lt;!\' <a href="foo">', feed.entries.first.description)
311
- assert_equal(nil, feed.entries.first.title)
312
- feed = FeedTools::Feed.open(
313
- 'http://feedparser.org/tests/wellformed/rss/item_content_encoded.xml')
314
- assert_equal('<p>Example content</p>', feed.entries.first.content)
315
- assert_equal(nil, feed.entries.first.title)
316
- feed = FeedTools::Feed.open(
317
- 'http://feedparser.org/tests/wellformed/rss/item_fullitem.xml')
318
- assert_equal('<p>Example content</p>', feed.entries.first.content)
319
- assert_equal(nil, feed.entries.first.title)
320
- feed = FeedTools::Feed.open(
321
- 'http://feedparser.org/tests/wellformed/rss/item_xhtml_body.xml')
322
- assert_equal('<p>Example content</p>', feed.entries.first.description)
323
- assert_equal(nil, feed.entries.first.title)
278
+ with_feed(:from_file => 'wellformed/rss/item_description.xml') { |feed|
279
+ assert_equal('Example description', feed.entries.first.description)
280
+ assert_equal(nil, feed.entries.first.title)
281
+ }
282
+ with_feed(:from_file => 'wellformed/rss/item_description_escaped_markup.xml') { |feed|
283
+ assert_equal('<p>Example description</p>', feed.entries.first.description)
284
+ assert_equal(nil, feed.entries.first.title)
285
+ }
286
+ with_feed(:from_file => 'wellformed/rss/item_description_map_summary.xml') { |feed|
287
+ assert_equal('Example description', feed.entries.first.description)
288
+ assert_equal(nil, feed.entries.first.title)
289
+ }
290
+ with_feed(:from_file => 'wellformed/rss/item_description_naked_markup.xml') { |feed|
291
+ assert_equal('<p>Example description</p>', feed.entries.first.description)
292
+ assert_equal(nil, feed.entries.first.title)
293
+ }
294
+ with_feed(:from_file => 'wellformed/rss/item_description_not_a_doctype.xml') { |feed|
295
+ assert_equal('&lt;!\' <a href="foo">', feed.entries.first.description)
296
+ assert_equal(nil, feed.entries.first.title)
297
+ }
298
+ with_feed(:from_file => 'wellformed/rss/item_content_encoded.xml') { |feed|
299
+ assert_equal('<p>Example content</p>', feed.entries.first.content)
300
+ assert_equal(nil, feed.entries.first.title)
301
+ }
302
+ with_feed(:from_file => 'wellformed/rss/item_fullitem.xml') { |feed|
303
+ assert_equal('<p>Example content</p>', feed.entries.first.content)
304
+ assert_equal(nil, feed.entries.first.title)
305
+ }
306
+ with_feed(:from_file => 'wellformed/rss/item_xhtml_body.xml') { |feed|
307
+ assert_equal('<p>Example content</p>', feed.entries.first.description)
308
+ assert_equal(nil, feed.entries.first.title)
309
+ }
324
310
  end
325
311
 
326
312
  def test_item_link
327
- feed = FeedTools::Feed.open(
328
- 'http://feedparser.org/tests/wellformed/rss/item_link.xml')
329
- assert_equal('http://example.com/', feed.entries.first.link)
330
- assert_equal(nil, feed.entries.first.title)
331
- assert_equal(nil, feed.entries.first.description)
313
+ with_feed(:from_file => 'wellformed/rss/item_link.xml') { |feed|
314
+ assert_equal('http://example.com/', feed.entries.first.link)
315
+ assert_equal(nil, feed.entries.first.title)
316
+ assert_equal(nil, feed.entries.first.description)
317
+ }
332
318
  end
333
319
 
334
320
  def test_item_guid
335
- feed = FeedTools::Feed.open(
336
- 'http://feedparser.org/tests/wellformed/rss/item_guid.xml')
337
- assert_equal('http://guid.example.com/', feed.entries.first.guid)
338
- feed = FeedTools::Feed.open(
339
- 'http://feedparser.org/tests/wellformed/rss/' +
340
- 'item_guid_conflict_link.xml')
341
- assert_equal('http://guid.example.com/', feed.entries.first.guid)
342
- assert_equal('http://link.example.com/', feed.entries.first.link)
343
- feed = FeedTools::Feed.open(
344
- 'http://feedparser.org/tests/wellformed/rss/item_guid_guidislink.xml')
345
- assert_equal('http://guid.example.com/', feed.entries.first.guid)
346
- assert_equal('http://guid.example.com/', feed.entries.first.link)
347
- feed = FeedTools::Feed.open(
348
- 'http://feedparser.org/tests/wellformed/rss/' +
349
- 'item_guid_isPermaLink_map_link.xml')
350
- assert_equal('http://guid.example.com/', feed.entries.first.guid)
351
- assert_equal('http://guid.example.com/', feed.entries.first.link)
321
+ with_feed(:from_file => 'wellformed/rss/item_guid.xml') { |feed|
322
+ assert_equal('http://guid.example.com/', feed.entries.first.guid)
323
+ }
324
+ with_feed(:from_file => 'wellformed/rss/item_guid_conflict_link.xml') { |feed|
325
+ assert_equal('http://guid.example.com/', feed.entries.first.guid)
326
+ assert_equal('http://link.example.com/', feed.entries.first.link)
327
+ }
328
+ with_feed(:from_file => 'wellformed/rss/item_guid_guidislink.xml') { |feed|
329
+ assert_equal('http://guid.example.com/', feed.entries.first.guid)
330
+ assert_equal('http://guid.example.com/', feed.entries.first.link)
331
+ }
332
+ with_feed(:from_file => 'wellformed/rss/item_guid_isPermaLink_map_link.xml') { |feed|
333
+ assert_equal('http://guid.example.com/', feed.entries.first.guid)
334
+ assert_equal('http://guid.example.com/', feed.entries.first.link)
335
+ }
352
336
  end
353
337
 
354
338
  def test_item_author
355
- feed = FeedTools::Feed.open(
356
- 'http://feedparser.org/tests/wellformed/rss/item_author.xml')
357
- assert_equal("Example editor", feed.items.first.author.raw)
358
- assert_equal("Example editor", feed.items.first.author.name)
359
- assert_equal(nil, feed.items.first.author.email)
360
- assert_equal(nil, feed.items.first.author.url)
361
- feed = FeedTools::Feed.open(
362
- 'http://feedparser.org/tests/wellformed/rss/' +
363
- 'item_author_map_author_detail_email.xml')
364
- assert_equal("Example editor (me@example.com)",
365
- feed.items.first.author.raw)
366
- assert_equal("Example editor", feed.items.first.author.name)
367
- assert_equal("me@example.com", feed.items.first.author.email)
368
- assert_equal(nil, feed.items.first.author.url)
369
- feed = FeedTools::Feed.open(
370
- 'http://feedparser.org/tests/wellformed/rss/item_dc_author.xml')
371
- assert_equal("Example editor", feed.items.first.author.raw)
372
- assert_equal("Example editor", feed.items.first.author.name)
373
- assert_equal(nil, feed.items.first.author.email)
374
- assert_equal(nil, feed.items.first.author.url)
375
- feed = FeedTools::Feed.open(
376
- 'http://feedparser.org/tests/wellformed/rss/' +
377
- 'item_dc_author_map_author_detail_email.xml')
378
- assert_equal("Example editor (me@example.com)",
379
- feed.items.first.author.raw)
380
- assert_equal("Example editor", feed.items.first.author.name)
381
- assert_equal("me@example.com", feed.items.first.author.email)
382
- assert_equal(nil, feed.items.first.author.url)
383
- feed = FeedTools::Feed.open(
384
- 'http://feedparser.org/tests/wellformed/rss/item_dc_creator.xml')
385
- assert_equal("Example editor", feed.items.first.author.raw)
386
- assert_equal("Example editor", feed.items.first.author.name)
387
- assert_equal(nil, feed.items.first.author.email)
388
- assert_equal(nil, feed.items.first.author.url)
389
- feed = FeedTools::Feed.open(
390
- 'http://feedparser.org/tests/wellformed/rss/' +
391
- 'item_dc_creator_map_author_detail_email.xml')
392
- assert_equal("Example editor (me@example.com)",
393
- feed.items.first.author.raw)
394
- assert_equal("Example editor", feed.items.first.author.name)
395
- assert_equal("me@example.com", feed.items.first.author.email)
396
- assert_equal(nil, feed.items.first.author.url)
339
+ with_feed(:from_file => 'wellformed/rss/item_author.xml') { |feed|
340
+ assert_equal("Example editor", feed.items.first.author.raw)
341
+ assert_equal("Example editor", feed.items.first.author.name)
342
+ assert_equal(nil, feed.items.first.author.email)
343
+ assert_equal(nil, feed.items.first.author.url)
344
+ }
345
+ with_feed(:from_file => 'wellformed/rss/item_author_map_author_detail_email.xml') { |feed|
346
+ assert_equal("Example editor (me@example.com)",
347
+ feed.items.first.author.raw)
348
+ assert_equal("Example editor", feed.items.first.author.name)
349
+ assert_equal("me@example.com", feed.items.first.author.email)
350
+ assert_equal(nil, feed.items.first.author.url)
351
+ }
352
+ with_feed(:from_file => 'wellformed/rss/item_dc_author.xml') { |feed|
353
+ assert_equal("Example editor", feed.items.first.author.raw)
354
+ assert_equal("Example editor", feed.items.first.author.name)
355
+ assert_equal(nil, feed.items.first.author.email)
356
+ assert_equal(nil, feed.items.first.author.url)
357
+ }
358
+ with_feed(:from_file => 'wellformed/rss/item_dc_author_map_author_detail_email.xml') { |feed|
359
+ assert_equal("Example editor (me@example.com)",
360
+ feed.items.first.author.raw)
361
+ assert_equal("Example editor", feed.items.first.author.name)
362
+ assert_equal("me@example.com", feed.items.first.author.email)
363
+ assert_equal(nil, feed.items.first.author.url)
364
+ }
365
+ with_feed(:from_file => 'wellformed/rss/item_dc_creator.xml') { |feed|
366
+ assert_equal("Example editor", feed.items.first.author.raw)
367
+ assert_equal("Example editor", feed.items.first.author.name)
368
+ assert_equal(nil, feed.items.first.author.email)
369
+ assert_equal(nil, feed.items.first.author.url)
370
+ }
371
+ with_feed(:from_file => 'wellformed/rss/item_dc_creator_map_author_detail_email.xml') { |feed|
372
+ assert_equal("Example editor (me@example.com)",
373
+ feed.items.first.author.raw)
374
+ assert_equal("Example editor", feed.items.first.author.name)
375
+ assert_equal("me@example.com", feed.items.first.author.email)
376
+ assert_equal(nil, feed.items.first.author.url)
377
+ }
397
378
  end
398
379
 
399
380
  def test_item_publisher
400
- feed = FeedTools::Feed.open(
401
- 'http://feedparser.org/tests/wellformed/rss/item_dc_publisher.xml')
402
- assert_equal("Example editor", feed.items.first.publisher.raw)
403
- assert_equal("Example editor", feed.items.first.publisher.name)
404
- assert_equal(nil, feed.items.first.publisher.email)
405
- assert_equal(nil, feed.items.first.publisher.url)
406
- feed = FeedTools::Feed.open(
407
- 'http://feedparser.org/tests/wellformed/rss/' +
408
- 'item_dc_publisher_email.xml')
409
- assert_equal("Example editor (me@example.com)", feed.items.first.publisher.raw)
410
- assert_equal("Example editor", feed.items.first.publisher.name)
411
- assert_equal("me@example.com", feed.items.first.publisher.email)
412
- assert_equal(nil, feed.items.first.publisher.url)
381
+ with_feed(:from_file => 'wellformed/rss/item_dc_publisher.xml') { |feed|
382
+ assert_equal("Example editor", feed.items.first.publisher.raw)
383
+ assert_equal("Example editor", feed.items.first.publisher.name)
384
+ assert_equal(nil, feed.items.first.publisher.email)
385
+ assert_equal(nil, feed.items.first.publisher.url)
386
+ }
387
+ with_feed(:from_file => 'wellformed/rss/item_dc_publisher_email.xml') { |feed|
388
+ assert_equal("Example editor (me@example.com)", feed.items.first.publisher.raw)
389
+ assert_equal("Example editor", feed.items.first.publisher.name)
390
+ assert_equal("me@example.com", feed.items.first.publisher.email)
391
+ assert_equal(nil, feed.items.first.publisher.url)
392
+ }
413
393
  end
414
394
 
415
395
  def test_item_categories
416
- feed = FeedTools::Feed.open(
417
- 'http://feedparser.org/tests/wellformed/rss/item_category.xml')
418
- assert_equal(1, feed.items.first.categories.size)
419
- assert_equal("Example category", feed.items.first.categories.first.value)
420
- feed = FeedTools::Feed.open(
421
- 'http://feedparser.org/tests/wellformed/rss/' +
422
- 'item_category_domain.xml')
423
- assert_equal(1, feed.items.first.categories.size)
424
- assert_equal("Example category", feed.items.first.categories.first.value)
425
- assert_equal("http://www.example.com/",
426
- feed.items.first.categories.first.domain)
427
- feed = FeedTools::Feed.open(
428
- 'http://feedparser.org/tests/wellformed/rss/' +
429
- 'item_category_multiple.xml')
430
- assert_equal(2, feed.items.first.categories.size)
431
- assert_equal("Example category 1",
432
- feed.items.first.categories[0].value)
433
- assert_equal("http://www.example.com/1",
434
- feed.items.first.categories[0].domain)
435
- assert_equal("Example category 2",
436
- feed.items.first.categories[1].value)
437
- assert_equal("http://www.example.com/2",
438
- feed.items.first.categories[1].domain)
439
- feed = FeedTools::Feed.open(
440
- 'http://feedparser.org/tests/wellformed/rss/' +
441
- 'item_category_multiple_2.xml')
442
- assert_equal(2, feed.items.first.categories.size)
443
- assert_equal("Example category 1",
444
- feed.items.first.categories[0].value)
445
- assert_equal(nil, feed.items.first.categories[0].domain)
446
- assert_equal("Example category 2",
447
- feed.items.first.categories[1].value)
448
- assert_equal(nil, feed.items.first.categories[1].domain)
449
- feed = FeedTools::Feed.open(
450
- 'http://feedparser.org/tests/wellformed/rss/item_dc_subject.xml')
451
- assert_equal(1, feed.items.first.categories.size)
452
- assert_equal("Example category", feed.items.first.categories.first.value)
453
- feed = FeedTools::Feed.open(
454
- 'http://feedparser.org/tests/wellformed/rss/' +
455
- 'item_dc_subject_multiple.xml')
456
- assert_equal(2, feed.items.first.categories.size)
457
- assert_equal("Example category 1", feed.items.first.categories[0].value)
458
- assert_equal(nil, feed.items.first.categories[0].domain)
459
- assert_equal("Example category 2", feed.items.first.categories[1].value)
460
- assert_equal(nil, feed.items.first.categories[1].domain)
396
+ with_feed(:from_file => 'wellformed/rss/item_category.xml') { |feed|
397
+ assert_equal(1, feed.items.first.categories.size)
398
+ assert_equal("Example category", feed.items.first.categories.first.value)
399
+ }
400
+ with_feed(:from_file => 'wellformed/rss/item_category_domain.xml') { |feed|
401
+ assert_equal(1, feed.items.first.categories.size)
402
+ assert_equal("Example category", feed.items.first.categories.first.value)
403
+ assert_equal("http://www.example.com/",
404
+ feed.items.first.categories.first.domain)
405
+ }
406
+ with_feed(:from_file => 'wellformed/rss/item_category_multiple.xml') { |feed|
407
+ assert_equal(2, feed.items.first.categories.size)
408
+ assert_equal("Example category 1",
409
+ feed.items.first.categories[0].value)
410
+ assert_equal("http://www.example.com/1",
411
+ feed.items.first.categories[0].domain)
412
+ assert_equal("Example category 2",
413
+ feed.items.first.categories[1].value)
414
+ assert_equal("http://www.example.com/2",
415
+ feed.items.first.categories[1].domain)
416
+ }
417
+ with_feed(:from_file => 'wellformed/rss/item_category_multiple_2.xml') { |feed|
418
+ assert_equal(2, feed.items.first.categories.size)
419
+ assert_equal("Example category 1",
420
+ feed.items.first.categories[0].value)
421
+ assert_equal(nil, feed.items.first.categories[0].domain)
422
+ assert_equal("Example category 2",
423
+ feed.items.first.categories[1].value)
424
+ assert_equal(nil, feed.items.first.categories[1].domain)
425
+ }
426
+ with_feed(:from_file => 'wellformed/rss/item_dc_subject.xml') { |feed|
427
+ assert_equal(1, feed.items.first.categories.size)
428
+ assert_equal("Example category", feed.items.first.categories.first.value)
429
+ }
430
+ with_feed(:from_file => 'wellformed/rss/item_dc_subject_multiple.xml') { |feed|
431
+ assert_equal(2, feed.items.first.categories.size)
432
+ assert_equal("Example category 1", feed.items.first.categories[0].value)
433
+ assert_equal(nil, feed.items.first.categories[0].domain)
434
+ assert_equal("Example category 2", feed.items.first.categories[1].value)
435
+ assert_equal(nil, feed.items.first.categories[1].domain)
436
+ }
461
437
  end
462
438
 
463
439
  def test_item_copyright
464
- feed = FeedTools::Feed.open(
465
- 'http://feedparser.org/tests/wellformed/rss/item_dc_rights.xml')
466
- assert_equal("Example copyright", feed.items.first.copyright)
440
+ with_feed(:from_file => 'wellformed/rss/item_dc_rights.xml') { |feed|
441
+ assert_equal("Example copyright", feed.items.first.copyright)
442
+ }
467
443
  end
468
444
 
469
445
  def test_item_comments
470
- feed = FeedTools::Feed.open(
471
- 'http://feedparser.org/tests/wellformed/rss/item_comments.xml')
472
- assert_equal("http://example.com/", feed.items.first.comments)
446
+ with_feed(:from_file => 'wellformed/rss/item_comments.xml') { |feed|
447
+ assert_equal("http://example.com/", feed.items.first.comments)
448
+ }
473
449
  end
474
450
 
475
451
  def test_item_enclosures
476
- feed = FeedTools::Feed.open(
477
- 'http://feedparser.org/tests/wellformed/rss/item_enclosure_length.xml')
478
- assert_equal("http://example.com/", feed.items.first.link)
479
- assert_equal("http://example.com/",
480
- feed.items.first.enclosures[0].link)
481
- assert_equal(100000, feed.items.first.enclosures[0].file_size)
482
- assert_equal("image/jpeg", feed.items.first.enclosures[0].type)
483
- assert_equal(nil, feed.items.first.title)
484
- assert_equal(nil, feed.items.first.description)
485
- feed = FeedTools::Feed.open(
486
- 'http://feedparser.org/tests/wellformed/rss/' +
487
- 'item_enclosure_multiple.xml')
488
- assert_equal("http://example.com/", feed.items.first.link)
489
- assert_equal("http://example.com/1",
490
- feed.items.first.enclosures[0].link)
491
- assert_equal(100000, feed.items.first.enclosures[0].file_size)
492
- assert_equal("image/jpeg", feed.items.first.enclosures[0].type)
493
- assert_equal("http://example.com/2",
494
- feed.items.first.enclosures[1].link)
495
- assert_equal(200000, feed.items.first.enclosures[1].file_size)
496
- assert_equal("image/gif", feed.items.first.enclosures[1].type)
497
- assert_equal(nil, feed.items.first.title)
498
- assert_equal(nil, feed.items.first.description)
452
+ with_feed(:from_file => 'wellformed/rss/item_enclosure_length.xml') { |feed|
453
+ assert_equal("http://example.com/", feed.items.first.link)
454
+ assert_equal("http://example.com/",
455
+ feed.items.first.enclosures[0].link)
456
+ assert_equal(100000, feed.items.first.enclosures[0].file_size)
457
+ assert_equal("image/jpeg", feed.items.first.enclosures[0].type)
458
+ assert_equal(nil, feed.items.first.title)
459
+ assert_equal(nil, feed.items.first.description)
460
+ }
461
+ with_feed(:from_file => 'wellformed/rss/item_enclosure_multiple.xml') { |feed|
462
+ assert_equal("http://example.com/", feed.items.first.link)
463
+ assert_equal("http://example.com/1",
464
+ feed.items.first.enclosures[0].link)
465
+ assert_equal(100000, feed.items.first.enclosures[0].file_size)
466
+ assert_equal("image/jpeg", feed.items.first.enclosures[0].type)
467
+ assert_equal("http://example.com/2",
468
+ feed.items.first.enclosures[1].link)
469
+ assert_equal(200000, feed.items.first.enclosures[1].file_size)
470
+ assert_equal("image/gif", feed.items.first.enclosures[1].type)
471
+ assert_equal(nil, feed.items.first.title)
472
+ assert_equal(nil, feed.items.first.description)
473
+ }
499
474
  end
500
475
 
501
476
  def test_item_source
502
- feed = FeedTools::Feed.open(
503
- 'http://feedparser.org/tests/wellformed/rss/item_source.xml')
504
- assert_equal("http://example.com/", feed.items.first.source.url)
505
- assert_equal("Example source", feed.items.first.source.value)
477
+ with_feed(:from_file => 'wellformed/rss/item_source.xml') { |feed|
478
+ assert_equal("http://example.com/", feed.items.first.source.url)
479
+ assert_equal("Example source", feed.items.first.source.value)
480
+ }
506
481
  end
507
482
 
508
483
  # This doesn't *really* test much since FeedTools isn't a namespace
509
484
  # aware parser yet. Mostly it just verifies that switching namepaces
510
485
  # doesn't make the feeds unreadable.
511
486
  def test_namespaces
512
- feed = FeedTools::Feed.open(
513
- 'http://feedparser.org/tests/wellformed/rss/rss_namespace_1.xml')
514
- assert_equal("Example description", feed.description)
515
- assert_equal(nil, feed.title)
516
- feed = FeedTools::Feed.open(
517
- 'http://feedparser.org/tests/wellformed/rss/rss_namespace_2.xml')
518
- assert_equal("Example description", feed.description)
519
- assert_equal(nil, feed.title)
520
- feed = FeedTools::Feed.open(
521
- 'http://feedparser.org/tests/wellformed/rss/rss_namespace_3.xml')
522
- assert_equal("Example description", feed.description)
523
- assert_equal(nil, feed.title)
524
- feed = FeedTools::Feed.open(
525
- 'http://feedparser.org/tests/wellformed/rss/rss_namespace_4.xml')
526
- assert_equal("Example description", feed.description)
527
- assert_equal(nil, feed.title)
528
- feed = FeedTools::Feed.open(
529
- 'http://feedparser.org/tests/wellformed/rss/rss_version_090.xml')
530
- assert_equal("rss", feed.feed_type)
531
- assert_equal(0.9, feed.feed_version)
532
- feed = FeedTools::Feed.open(
533
- 'http://feedparser.org/tests/wellformed/rss/rss_version_091_netscape.xml')
534
- assert_equal("rss", feed.feed_type)
535
- assert_equal(0.91, feed.feed_version)
536
- feed = FeedTools::Feed.open(
537
- 'http://feedparser.org/tests/wellformed/rss/rss_version_091_userland.xml')
538
- assert_equal("rss", feed.feed_type)
539
- assert_equal(0.91, feed.feed_version)
540
- feed = FeedTools::Feed.open(
541
- 'http://feedparser.org/tests/wellformed/rss/rss_version_092.xml')
542
- assert_equal("rss", feed.feed_type)
543
- assert_equal(0.92, feed.feed_version)
544
- feed = FeedTools::Feed.open(
545
- 'http://feedparser.org/tests/wellformed/rss/rss_version_093.xml')
546
- assert_equal("rss", feed.feed_type)
547
- assert_equal(0.93, feed.feed_version)
548
- feed = FeedTools::Feed.open(
549
- 'http://feedparser.org/tests/wellformed/rss/rss_version_094.xml')
550
- assert_equal("rss", feed.feed_type)
551
- assert_equal(0.94, feed.feed_version)
552
- feed = FeedTools::Feed.open(
553
- 'http://feedparser.org/tests/wellformed/rss/rss_version_20.xml')
554
- assert_equal("rss", feed.feed_type)
555
- assert_equal(2.0, feed.feed_version)
556
- feed = FeedTools::Feed.open(
557
- 'http://feedparser.org/tests/wellformed/rss/rss_version_201.xml')
558
- assert_equal("rss", feed.feed_type)
559
- assert_equal(2.0, feed.feed_version)
560
- feed = FeedTools::Feed.open(
561
- 'http://feedparser.org/tests/wellformed/rss/rss_version_21.xml')
562
- assert_equal("rss", feed.feed_type)
563
- assert_equal(2.0, feed.feed_version)
564
- feed = FeedTools::Feed.open(
565
- 'http://feedparser.org/tests/wellformed/rss/rss_version_missing.xml')
566
- assert_equal("rss", feed.feed_type)
567
- assert_equal(nil, feed.feed_version)
487
+ with_feed(:from_file => 'wellformed/rss/rss_namespace_1.xml') { |feed|
488
+ assert_equal("Example description", feed.description)
489
+ assert_equal(nil, feed.title)
490
+ }
491
+ with_feed(:from_file => 'wellformed/rss/rss_namespace_2.xml') { |feed|
492
+ assert_equal("Example description", feed.description)
493
+ assert_equal(nil, feed.title)
494
+ }
495
+ with_feed(:from_file => 'wellformed/rss/rss_namespace_3.xml') { |feed|
496
+ assert_equal("Example description", feed.description)
497
+ assert_equal(nil, feed.title)
498
+ }
499
+ with_feed(:from_file => 'wellformed/rss/rss_namespace_4.xml') { |feed|
500
+ assert_equal("Example description", feed.description)
501
+ assert_equal(nil, feed.title)
502
+ }
503
+ with_feed(:from_file => 'wellformed/rss/rss_version_090.xml') { |feed|
504
+ assert_equal("rss", feed.feed_type)
505
+ assert_equal(0.9, feed.feed_version)
506
+ }
507
+ with_feed(:from_file => 'wellformed/rss/rss_version_091_netscape.xml') { |feed|
508
+ assert_equal("rss", feed.feed_type)
509
+ assert_equal(0.91, feed.feed_version)
510
+ }
511
+ with_feed(:from_file => 'wellformed/rss/rss_version_091_userland.xml') { |feed|
512
+ assert_equal("rss", feed.feed_type)
513
+ assert_equal(0.91, feed.feed_version)
514
+ }
515
+ with_feed(:from_file => 'wellformed/rss/rss_version_092.xml') { |feed|
516
+ assert_equal("rss", feed.feed_type)
517
+ assert_equal(0.92, feed.feed_version)
518
+ }
519
+ with_feed(:from_file => 'wellformed/rss/rss_version_093.xml') { |feed|
520
+ assert_equal("rss", feed.feed_type)
521
+ assert_equal(0.93, feed.feed_version)
522
+ }
523
+ with_feed(:from_file => 'wellformed/rss/rss_version_094.xml') { |feed|
524
+ assert_equal("rss", feed.feed_type)
525
+ assert_equal(0.94, feed.feed_version)
526
+ }
527
+ with_feed(:from_file => 'wellformed/rss/rss_version_20.xml') { |feed|
528
+ assert_equal("rss", feed.feed_type)
529
+ assert_equal(2.0, feed.feed_version)
530
+ }
531
+ with_feed(:from_file => 'wellformed/rss/rss_version_201.xml') { |feed|
532
+ assert_equal("rss", feed.feed_type)
533
+ assert_equal(2.0, feed.feed_version)
534
+ }
535
+ with_feed(:from_file => 'wellformed/rss/rss_version_21.xml') { |feed|
536
+ assert_equal("rss", feed.feed_type)
537
+ assert_equal(2.0, feed.feed_version)
538
+ }
539
+ with_feed(:from_file => 'wellformed/rss/rss_version_missing.xml') { |feed|
540
+ assert_equal("rss", feed.feed_type)
541
+ assert_equal(nil, feed.feed_version)
542
+ }
568
543
  end
569
544
 
570
545
  def test_content_encoded
571
- feed = FeedTools::Feed.new
572
- feed.feed_data = <<-FEED
573
- <rss>
574
- <channel>
575
- <item>
576
- <title>Test Feed Title</title>
546
+ with_feed(:from_data => <<-FEED
547
+ <rss>
548
+ <channel>
549
+ <item>
550
+ <title>Test Feed Title</title>
577
551
  <content:encoded
578
552
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
579
553
  <![CDATA[
@@ -584,82 +558,88 @@ class RssTest < Test::Unit::TestCase
584
558
  </channel>
585
559
  </rss>
586
560
  FEED
587
- assert_equal("Test Feed Title", feed.items.first.title)
588
- assert_equal("Test Feed Content", feed.items.first.content)
561
+ ) { |feed|
562
+ assert_equal("Test Feed Title", feed.items.first.title)
563
+ assert_equal("Test Feed Content", feed.items.first.content)
564
+ }
589
565
  end
590
566
 
591
567
  def test_item_order
592
- feed = FeedTools::Feed.new
593
- feed.feed_data = <<-FEED
594
- <rss>
595
- <channel>
596
- <item>
597
- <title>Item 1</title>
568
+ with_feed(:from_data => <<-FEED
569
+ <rss>
570
+ <channel>
571
+ <item>
572
+ <title>Item 1</title>
598
573
  </item>
599
- <item>
600
- <title>Item 2</title>
574
+ <item>
575
+ <title>Item 2</title>
601
576
  </item>
602
- <item>
603
- <title>Item 3</title>
577
+ <item>
578
+ <title>Item 3</title>
604
579
  </item>
605
- </channel>
580
+ </channel>
606
581
  </rss>
607
- FEED
608
- assert_equal("Item 1", feed.items[0].title)
609
- assert_equal("Item 2", feed.items[1].title)
610
- assert_equal("Item 3", feed.items[2].title)
582
+ FEED
583
+ ) { |feed|
584
+ assert_equal("Item 1", feed.items[0].title)
585
+ assert_equal("Item 2", feed.items[1].title)
586
+ assert_equal("Item 3", feed.items[2].title)
587
+ }
611
588
 
612
- feed = FeedTools::Feed.new
613
- feed.feed_data = <<-FEED
614
- <rss>
615
- <channel>
616
- <item>
617
- <title>Item 1</title>
589
+ with_feed(:from_data => <<-FEED
590
+ <rss>
591
+ <channel>
592
+ <item>
593
+ <title>Item 1</title>
618
594
  </item>
619
- <item>
620
- <title>Item 2</title>
595
+ <item>
596
+ <title>Item 2</title>
621
597
  <pubDate>Thu, 13 Oct 2005 19:59:00 +0000</pubDate>
622
- </item>
598
+ </item>
623
599
  <item>
624
600
  <title>Item 3</title>
625
- </item>
601
+ </item>
626
602
  </channel>
627
603
  </rss>
628
604
  FEED
629
- assert_equal("Item 1", feed.items[0].title)
630
- assert_equal("Item 2", feed.items[1].title)
631
- assert_equal("Item 3", feed.items[2].title)
605
+ ) { |feed|
606
+ assert_equal("Item 1", feed.items[0].title)
607
+ assert_equal("Item 2", feed.items[1].title)
608
+ assert_equal("Item 3", feed.items[2].title)
609
+ }
632
610
  end
633
611
 
634
612
  def test_usm
635
- feed = FeedTools::Feed.new
636
- feed.feed_data = <<-FEED
637
- <rss xmlns:atom="http://www.w3.org/2005/Atom">
638
- <channel>
639
- <atom:link href="http://nowhere.com/feed.xml" rel="self" />
640
- <title>Feed Title</title>
613
+ with_feed(:from_data => <<-FEED
614
+ <rss xmlns:atom="http://www.w3.org/2005/Atom">
615
+ <channel>
616
+ <atom:link href="http://nowhere.com/feed.xml" rel="self" />
617
+ <title>Feed Title</title>
641
618
  </channel>
642
619
  </rss>
643
620
  FEED
644
- assert_equal("http://nowhere.com/feed.xml", feed.url)
645
- assert_equal("Feed Title", feed.title)
621
+ ) { |feed|
622
+ assert_equal("http://nowhere.com/feed.xml", feed.url)
623
+ assert_equal("Feed Title", feed.title)
624
+ }
646
625
 
647
- feed = FeedTools::Feed.new
648
- feed.feed_data = <<-FEED
626
+ with_feed(:from_data => <<-FEED
649
627
  <rss xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
650
- xmlns:admin="http://webns.net/mvcb/">
651
- <channel>
652
- <admin:feed rdf:resource="http://nowhere.com/feed.xml" />
653
- <title>Feed Title</title>
628
+ xmlns:admin="http://webns.net/mvcb/">
629
+ <channel>
630
+ <admin:feed rdf:resource="http://nowhere.com/feed.xml" />
631
+ <title>Feed Title</title>
654
632
  </channel>
655
633
  </rss>
656
634
  FEED
657
- assert_equal("http://nowhere.com/feed.xml", feed.url)
658
- assert_equal("Feed Title", feed.title)
635
+ ) { |feed|
636
+ assert_equal("http://nowhere.com/feed.xml", feed.url)
637
+ assert_equal("Feed Title", feed.title)
638
+ }
659
639
  end
660
640
 
661
641
  def test_http_retrieval
662
642
  # Just make sure this doesn't toss out any errors
663
643
  FeedTools::Feed.open('http://scobleizer.wordpress.com/feed/')
664
644
  end
665
- end
645
+ end