summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rss/rss-assertions.rb12
-rw-r--r--test/rss/test_maker_slash.rb37
-rw-r--r--test/rss/test_parser.rb2
-rw-r--r--test/rss/test_parser_1.0.rb8
-rw-r--r--test/rss/test_setup_maker_slash.rb38
-rw-r--r--test/rss/test_slash.rb64
-rw-r--r--test/rss/test_version.rb2
7 files changed, 161 insertions, 2 deletions
diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb
index 3b212c794de..41e6cd62c52 100644
--- a/test/rss/rss-assertions.rb
+++ b/test/rss/rss-assertions.rb
@@ -2018,6 +2018,18 @@ EOA
end
end
+ def assert_slash_elements(expected, target)
+ assert_equal(expected,
+ {
+ "section" => target.slash_section,
+ "department" => target.slash_department,
+ "comments" => target.slash_comments,
+ "hit_parades" => target.slash_hit_parades,
+ })
+ assert_equal(expected["hit_parades"].join(","),
+ target.slash_hit_parade)
+ end
+
def chain_reader(target, readers, &block)
readers.inject(target) do |result, reader|
return nil if result.nil?
diff --git a/test/rss/test_maker_slash.rb b/test/rss/test_maker_slash.rb
new file mode 100644
index 00000000000..f2fbf9a2314
--- /dev/null
+++ b/test/rss/test_maker_slash.rb
@@ -0,0 +1,37 @@
+require "rss-testcase"
+
+require "rss/maker"
+
+module RSS
+ class TestMakerSlash < TestCase
+ def setup
+ @elements = {
+ "section" => "articles",
+ "department" => "not-an-ocean-unless-there-are-lobsters",
+ "comments" => 177,
+ "hit_parades" => [177, 155, 105, 33, 6, 3, 0],
+ }
+ end
+
+ def test_rss10
+ rss = RSS::Maker.make("1.0") do |maker|
+ setup_dummy_channel(maker)
+
+ setup_dummy_item(maker)
+ item = maker.items.last
+ @elements.each do |name, value|
+ item.send("slash_#{name}=", value)
+ end
+ end
+
+ item = rss.items.last
+ assert_not_nil(item)
+ assert_slash_elements(item)
+ end
+
+ private
+ def assert_slash_elements(target)
+ super(@elements, target)
+ end
+ end
+end
diff --git a/test/rss/test_parser.rb b/test/rss/test_parser.rb
index 45f31e20145..59458ef51bb 100644
--- a/test/rss/test_parser.rb
+++ b/test/rss/test_parser.rb
@@ -1,4 +1,4 @@
-require 'fileutils'
+require "fileutils"
require "rss-testcase"
diff --git a/test/rss/test_parser_1.0.rb b/test/rss/test_parser_1.0.rb
index 472602b04ab..1c4e53c1da6 100644
--- a/test/rss/test_parser_1.0.rb
+++ b/test/rss/test_parser_1.0.rb
@@ -498,6 +498,14 @@ EOR
Parser.parse(rss, true, false)
end
end
+
+ def test_unknown_duplicated_element
+ assert_parse(make_RDF(<<-EOR), :nothing_raised)
+ #{make_channel("<test:string/>")}
+ #{make_item}
+ #{make_image}
+ EOR
+ end
end
end
diff --git a/test/rss/test_setup_maker_slash.rb b/test/rss/test_setup_maker_slash.rb
new file mode 100644
index 00000000000..07fa5bb342c
--- /dev/null
+++ b/test/rss/test_setup_maker_slash.rb
@@ -0,0 +1,38 @@
+require "rss-testcase"
+
+require "rss/maker"
+
+module RSS
+ class TestSetupMakerSlash < TestCase
+ def test_setup_maker
+ elements = {
+ "section" => "articles",
+ "department" => "not-an-ocean-unless-there-are-lobsters",
+ "comments" => 177,
+ "hit_parades" => [177, 155, 105, 33, 6, 3, 0],
+ }
+
+ rss = RSS::Maker.make("rss1.0") do |maker|
+ setup_dummy_channel(maker)
+ setup_dummy_item(maker)
+
+ item = maker.items.last
+ item.slash_section = elements["section"]
+ item.slash_department = elements["department"]
+ item.slash_comments = elements["comments"]
+ item.slash_hit_parade = elements["hit_parades"].join(",")
+ end
+ assert_not_nil(rss)
+
+ new_rss = RSS::Maker.make("rss1.0") do |maker|
+ rss.setup_maker(maker)
+ end
+ assert_not_nil(new_rss)
+
+ item = new_rss.items.last
+ assert_not_nil(item)
+
+ assert_slash_elements(elements, item)
+ end
+ end
+end
diff --git a/test/rss/test_slash.rb b/test/rss/test_slash.rb
new file mode 100644
index 00000000000..aec0a868f51
--- /dev/null
+++ b/test/rss/test_slash.rb
@@ -0,0 +1,64 @@
+require "cgi"
+require "rexml/document"
+
+require "rss-testcase"
+
+require "rss/1.0"
+require "rss/slash"
+
+module RSS
+ class TestSlash < TestCase
+ def setup
+ @elements = {
+ "section" => "articles",
+ "department" => "not-an-ocean-unless-there-are-lobsters",
+ "comments" => 177,
+ "hit_parades" => [177, 155, 105, 33, 6, 3, 0],
+ }
+
+ slash_nodes = @elements.collect do |name, value|
+ if name == "hit_parades"
+ name = "hit_parade"
+ value = value.join(",")
+ end
+ "<slash:#{name}>#{value}</slash:#{name}>"
+ end.join("\n")
+
+ slash_ns = {"slash" => "http://purl.org/rss/1.0/modules/slash/"}
+ @source = make_RDF(<<-EOR, slash_ns)
+#{make_channel}
+#{make_image}
+#{make_item(slash_nodes)}
+#{make_textinput}
+EOR
+ end
+
+ def test_parser
+ rss = RSS::Parser.parse(@source)
+
+ assert_not_nil(rss)
+
+ item = rss.items[0]
+ assert_not_nil(item)
+
+ assert_slash_elements(item)
+ end
+
+ def test_to_s
+ rss = RSS::Parser.parse(@source)
+ rss = RSS::Parser.parse(rss.to_s)
+
+ assert_not_nil(rss)
+
+ item = rss.items[0]
+ assert_not_nil(item)
+
+ assert_slash_elements(item)
+ end
+
+ private
+ def assert_slash_elements(target)
+ super(@elements, target)
+ end
+ end
+end
diff --git a/test/rss/test_version.rb b/test/rss/test_version.rb
index 8e63af7c234..9b64f0d4ed4 100644
--- a/test/rss/test_version.rb
+++ b/test/rss/test_version.rb
@@ -3,7 +3,7 @@ require "rss-testcase"
module RSS
class TestVersion < TestCase
def test_version
- assert_equal("0.1.9", ::RSS::VERSION)
+ assert_equal("0.2.0", ::RSS::VERSION)
end
end
end