aboutsummaryrefslogtreecommitdiffstats
path: root/test/rss/test_maker_taxo.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-23 09:24:17 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-23 09:24:17 +0000
commit4ef7ec62cab725ad1dea2be9a26ca0f9fd195729 (patch)
tree2433c8b783f7af942de18409be11a6fded9852c9 /test/rss/test_maker_taxo.rb
parentf988ceb53b731f7465f8ace09c76cd69e9abef22 (diff)
downloadruby-4ef7ec62cab725ad1dea2be9a26ca0f9fd195729.tar.gz
* lib/rss/maker/taxonomy.rb: implemented taxonomy module for RSS
Maker. * lib/rss/taxonomy.rb: supported RSS Maker. * lib/rss/maker.rb: added taxonomy module support. * lib/rss/rss.rb: adjusted to other element API. * lib/rss/1.0.rb: adjusted to other element API but backward compatibility is reserved. * lib/rss/0.9.rb: ditto. * test/rss/test_maker_taxo.rb: added test case for taxonomy module for RSS Maker. * test/rss/test_setup_maker_1.0.rb: added tests for taxo:topic. * test/rss/test_setup_maker_1.0.rb: added backward compatibility test. * test/rss/test_setup_maker_0.9.rb: ditto. * test/rss/test_setup_maker_2.0.rb: ditto. * test/rss/rss-testcase.rb: added convenience method for setting up taxo:topic. * test/rss/rss-assertions.rb: added assertion for taxo:topic. * sample/rss/blend.rb: followed new API. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rss/test_maker_taxo.rb')
-rw-r--r--test/rss/test_maker_taxo.rb79
1 files changed, 79 insertions, 0 deletions
diff --git a/test/rss/test_maker_taxo.rb b/test/rss/test_maker_taxo.rb
new file mode 100644
index 0000000000..1c7d2844ce
--- /dev/null
+++ b/test/rss/test_maker_taxo.rb
@@ -0,0 +1,79 @@
+require "rss-testcase"
+
+require "rss/maker"
+
+module RSS
+ class TestMakerTaxonomy < TestCase
+
+ def setup
+ @uri = "http://purl.org/rss/1.0/modules/taxonomy/"
+
+ @resources = [
+ "http://meerkat.oreillynet.com/?c=cat23",
+ "http://meerkat.oreillynet.com/?c=47",
+ "http://dmoz.org/Computers/Data_Formats/Markup_Languages/XML/",
+ ]
+
+ @topics = [
+ {
+ :link => "http://meerkat.oreillynet.com/?c=cat23",
+ :title => "Data: XML",
+ :description => "A Meerkat channel",
+ },
+ {
+ :link => "http://dmoz.org/Computers/Data_Formats/Markup_Languages/XML/",
+ :title => "XML",
+ :subject => "XML",
+ :description => "DMOZ category",
+ :topics => [
+ "http://meerkat.oreillynet.com/?c=cat23",
+ "http://dmoz.org/Computers/Data_Formats/Markup_Languages/SGML/",
+ "http://dmoz.org/Computers/Programming/Internet/",
+ ]
+ },
+ ]
+ end
+
+ def test_rss10
+ rss = RSS::Maker.make("1.0") do |maker|
+ setup_dummy_channel(maker)
+ set_topics(maker.channel)
+
+ setup_dummy_item(maker)
+ set_topics(maker.items.last)
+
+ setup_taxo_topic(maker, @topics)
+ end
+ assert_equal(@resources, rss.channel.taxo_topics.resources)
+ assert_equal(@resources, rss.items.last.taxo_topics.resources)
+ assert_taxo_topic(@topics, rss)
+ end
+
+ def _test_date
+ t1 = Time.iso8601("2000-01-01T12:00:05+00:00")
+ t2 = Time.iso8601("2005-01-01T12:00:05+00:00")
+
+ rss = RSS::Maker.make("1.0") do |maker|
+ setup_dummy_channel(maker)
+ maker.channel.date = t1
+ date = maker.channel.dc_dates.new_date
+ date.value = t2
+
+ setup_dummy_item(maker)
+ item = maker.items.last
+ item.date = t2
+ date = item.dc_dates.new_date
+ date.value = t1
+ end
+ assert_equal([t1, t2], rss.channel.dc_dates.collect{|x| x.value})
+ assert_equal([t2, t1], rss.items.last.dc_dates.collect{|x| x.value})
+ end
+
+ private
+ def set_topics(target, resources=@resources)
+ resources.each do |value|
+ target.taxo_topics << value
+ end
+ end
+ end
+end