summaryrefslogtreecommitdiff
path: root/test/rss
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-25 03:43:48 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-25 03:43:48 +0000
commit456ba712fe921f2387611055b67090d70dfad071 (patch)
tree0644be10cb619619103327215fa15209515be7c1 /test/rss
parentea0e7c1599d1163b70b952775a55222ea90c5ae3 (diff)
* lib/rss/rss.rb: improved type conversion.
* lib/rss/1.0.rb: ditto. * lib/rss/0.9.rb: ditto. * lib/rss/2.0.rb: ditto. * lib/rss/image.rb: ditto. * lib/rss/syndication.rb: ditto. * test/rss/test_2.0.rb: added type conversion tests. * test/rss/test_accessor.rb: ditto. * test/rss/test_to_s.rb: ditto. * test/rss/test_syndication.rb: ditto. * test/rss/test_setup_maker_2.0.rb: ditto. * test/rss/test_setup_maker_1.0.rb: ditto. * test/rss/test_setup_maker_0.9.rb: ditto. * test/rss/test_maker_sy.rb: ditto. * test/rss/test_maker_image.rb: ditto. * test/rss/test_maker_2.0.rb: ditto. * test/rss/test_maker_0.9.rb: ditto. * test/rss/test_image.rb: ditto. * test/rss/test_maker_1.0.rb: use assert instead of assert_equal. * test/rss/rss-assertions.rb: improved type conversion assertions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rss')
-rw-r--r--test/rss/rss-assertions.rb42
-rw-r--r--test/rss/test_2.0.rb53
-rw-r--r--test/rss/test_accessor.rb83
-rw-r--r--test/rss/test_image.rb42
-rw-r--r--test/rss/test_maker_0.9.rb20
-rw-r--r--test/rss/test_maker_1.0.rb2
-rw-r--r--test/rss/test_maker_2.0.rb32
-rw-r--r--test/rss/test_maker_image.rb8
-rw-r--r--test/rss/test_maker_sy.rb2
-rw-r--r--test/rss/test_setup_maker_0.9.rb16
-rw-r--r--test/rss/test_setup_maker_1.0.rb4
-rw-r--r--test/rss/test_setup_maker_2.0.rb26
-rw-r--r--test/rss/test_syndication.rb14
-rw-r--r--test/rss/test_to_s.rb10
14 files changed, 250 insertions, 104 deletions
diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb
index cb757a9..f90eb7f 100644
--- a/test/rss/rss-assertions.rb
+++ b/test/rss/rss-assertions.rb
@@ -83,7 +83,7 @@ module RSS
end
end
- def assert_not_available_value(tag, value)
+ def assert_not_available_value(tag, value, attribute=nil)
_wrap_assertion do
begin
yield
@@ -91,6 +91,7 @@ module RSS
rescue ::RSS::NotAvailableValueError => e
assert_equal(tag, e.tag)
assert_equal(value, e.value)
+ assert_equal(attribute, e.attribute)
end
end
end
@@ -256,14 +257,16 @@ module RSS
_wrap_assertion do
hours = skipHours.hours
contents.each_with_index do |content, i|
- assert_equal(content, hours[i].content)
+ assert_equal(content.to_i, hours[i].content)
end
end
end
def assert_image09(attrs, image)
_wrap_assertion do
- names = %w(url link title description width height)
+ names = %w(url link title description)
+ names << ["width", :integer]
+ names << ["height", :integer]
assert_attributes(attrs, names, image)
end
end
@@ -291,7 +294,8 @@ module RSS
names = %w(title link description language copyright
managingEditor webMaster pubDate
- lastBuildDate generator docs ttl rating)
+ lastBuildDate generator docs rating)
+ names << ["ttl", :integer]
assert_attributes(attrs, names, channel)
%w(cloud categories skipHours skipDays).each do |name|
@@ -314,7 +318,8 @@ module RSS
def assert_channel20_cloud(attrs, cloud)
_wrap_assertion do
- names = %w(domain port path registerProcedure protocol)
+ names = %w(domain path registerProcedure protocol)
+ names << ["port", :integer]
assert_attributes(attrs, names, cloud)
end
end
@@ -330,7 +335,9 @@ module RSS
def assert_image20(attrs, image)
_wrap_assertion do
- names = %w(url link title description width height)
+ names = %w(url link title description)
+ names << ["width", :integer]
+ names << ["height", :integer]
assert_attributes(attrs, names, image)
end
end
@@ -362,7 +369,7 @@ module RSS
def assert_items20_enclosure(attrs, enclosure)
_wrap_assertion do
- names = %w(url length type)
+ names = ["url", ["length", :integer], "type"]
assert_attributes(attrs, names, enclosure)
end
end
@@ -375,7 +382,8 @@ module RSS
def assert_items20_guid(attrs, guid)
_wrap_assertion do
- assert_attributes(attrs, %w(isPermaLink content), guid)
+ names = [["isPermaLink", :boolean], ["content"]]
+ assert_attributes(attrs, names, guid)
end
end
@@ -408,7 +416,9 @@ module RSS
def assert_syndication(elems, target)
_wrap_assertion do
elems.each do |name, value|
- assert_equal(value, target.__send__("sy_#{name}"))
+ meth = "sy_#{name}"
+ value = value.to_i if meth == "sy_updateFrequency"
+ assert_equal(value, target.__send__(meth ))
end
end
end
@@ -458,13 +468,25 @@ module RSS
def assert_attributes(attrs, names, target)
_wrap_assertion do
n_attrs = normalized_attrs(attrs)
- names.each do |name|
+ names.each do |info|
+ if info.is_a?(String)
+ name = info
+ type = nil
+ else
+ name, type = info
+ end
value = n_attrs[name]
if value.is_a?(Time)
actual = target.__send__(name)
assert_instance_of(Time, actual)
assert_equal(value.to_i, actual.to_i)
elsif value
+ case type
+ when :integer
+ value = value.to_i
+ when :boolean
+ value = value == "true" if value.is_a?(String)
+ end
assert_equal(value, target.__send__(name))
end
end
diff --git a/test/rss/test_2.0.rb b/test/rss/test_2.0.rb
index 238d3ef..5e2e6bd 100644
--- a/test/rss/test_2.0.rb
+++ b/test/rss/test_2.0.rb
@@ -75,9 +75,9 @@ module RSS
generator = "MightyInHouse Content System v2.3"
docs = "http://blogs.law.harvard.edu/tech/rss"
- ttl = 60
+ ttl = "60"
- rating = 6
+ rating = '(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0))'
channel = Rss::Channel.new
@@ -85,7 +85,9 @@ module RSS
managingEditor webMaster pubDate lastBuildDate
generator docs ttl rating)
elems.each do |x|
- channel.__send__("#{x}=", instance_eval(x))
+ value = instance_eval(x)
+ value = value.rfc822 if %w(pubDate lastBuildDate).include?(x)
+ channel.__send__("#{x}=", value)
end
categories.each do |cat|
channel.categories << Rss::Channel::Category.new(cat[:domain],
@@ -103,7 +105,8 @@ module RSS
case x
when "pubDate", "lastBuildDate"
assert_equal(expected, Time.parse(elem.text))
- when "ttl", "rating"
+ when "ttl"
+ expected = channel.__send__(x)
assert_equal(expected, elem.text.to_i)
else
assert_equal(expected, elem.text)
@@ -124,7 +127,7 @@ module RSS
def test_channel_cloud
cloud_params = {
:domain => "rpc.sys.com",
- :port => 80,
+ :port => "80",
:path => "/RPC2",
:registerProcedure => "myCloud.rssPleaseNotify",
:protocol => "xml-rpc",
@@ -134,7 +137,8 @@ module RSS
cloud_params[:path],
cloud_params[:registerProcedure],
cloud_params[:protocol])
-
+ cloud_params[:port] = cloud.port
+
doc = REXML::Document.new(cloud.to_s)
cloud_elem = doc.root
@@ -151,8 +155,8 @@ module RSS
:url => "http://hoge.com/hoge.png",
:title => "fugafuga",
:link => "http://hoge.com",
- :width => 144,
- :height => 400,
+ :width => "144",
+ :height => "400",
:description => "an image",
}
image = Rss::Channel::Image.new(image_params[:url],
@@ -166,6 +170,7 @@ module RSS
image_elem = doc.root
image_params.each do |name, value|
+ value = image.__send__(name)
actual = image_elem.elements[name.to_s].text
actual = actual.to_i if [:width, :height].include?(name)
assert_equal(value, actual)
@@ -213,8 +218,8 @@ module RSS
def test_channel_skip_hours
skipHours_values = [
- 0,
- 13,
+ "0",
+ "13",
]
skipHours = Rss::Channel::SkipHours.new
skipHours_values.each do |value|
@@ -225,7 +230,8 @@ module RSS
hours_elem = doc.root
skipHours_values.each_with_index do |value, i|
- assert_equal(value, hours_elem.elements[i + 1].text.to_i)
+ expected = skipHours.hours[i].content
+ assert_equal(expected, hours_elem.elements[i + 1].text.to_i)
end
end
@@ -252,7 +258,9 @@ module RSS
elems = %w(title link description author comments pubDate)
elems.each do |x|
- item.__send__("#{x}=", instance_eval(x))
+ value = instance_eval(x)
+ value = value.rfc822 if x == "pubDate"
+ item.__send__("#{x}=", value)
end
categories.each do |cat|
item.categories << Rss::Channel::Category.new(cat[:domain],
@@ -290,23 +298,21 @@ module RSS
def test_item_enclosure
enclosure_params = {
:url => "http://www.scripting.com/mp3s/weatherReportSuite.mp3",
- :length => 12216320,
+ :length => "12216320",
:type => "audio/mpeg",
}
enclosure = Rss::Channel::Item::Enclosure.new(enclosure_params[:url],
enclosure_params[:length],
enclosure_params[:type])
-
+ enclosure_params[:length] = enclosure.length
+
doc = REXML::Document.new(enclosure.to_s)
enclosure_elem = doc.root
actual = {}
enclosure_elem.attributes.each do |name, value|
- if name == "length"
- enclosure_params[name.to_sym] = value.to_i
- value = value.to_i
- end
+ value = value.to_i if name == "length"
actual[name.to_sym] = value
end
assert_equal(enclosure_params, actual)
@@ -326,13 +332,22 @@ module RSS
test_params.each do |guid_params|
guid = Rss::Channel::Item::Guid.new(guid_params[:isPermaLink],
guid_params[:content])
-
+ if guid_params.has_key?(:isPermaLink)
+ guid_params[:isPermaLink] = guid.isPermaLink
+ end
+ if guid.isPermaLink.nil?
+ assert_equal(true, guid.PermaLink?)
+ else
+ assert_equal(guid.isPermaLink, guid.PermaLink?)
+ end
+
doc = REXML::Document.new(guid.to_s)
guid_elem = doc.root
actual = {}
actual[:content] = guid_elem.text if guid_elem.text
guid_elem.attributes.each do |name, value|
+ value = value == "true" if name == "isPermaLink"
actual[name.to_sym] = value
end
assert_equal(guid_params, actual)
diff --git a/test/rss/test_accessor.rb b/test/rss/test_accessor.rb
index 5281a81..ceb31fc 100644
--- a/test/rss/test_accessor.rb
+++ b/test/rss/test_accessor.rb
@@ -2,13 +2,13 @@ require "rss-testcase"
require "rss/1.0"
require "rss/2.0"
+require "rss/syndication"
+require "rss/image"
module RSS
class TestAccessor < TestCase
-
def test_date
channel = Rss::Channel.new
- channel.do_validate = false
channel.pubDate = nil
assert_nil(channel.pubDate)
@@ -16,9 +16,88 @@ module RSS
channel.pubDate = time
assert_equal(time, channel.pubDate)
+ time = Time.parse(Time.now.rfc822)
+ channel.pubDate = time.rfc822
+ assert_equal(time, channel.pubDate)
+
+ time = Time.parse(Time.now.iso8601)
+ value = time.iso8601
+ assert_not_available_value("pubDate", value) do
+ channel.pubDate = value
+ end
+
+ channel.do_validate = false
+ time = Time.parse(Time.now.iso8601)
+ value = time.iso8601
+ channel.pubDate = value
+ assert_equal(time, channel.pubDate)
+
channel.pubDate = nil
assert_nil(channel.pubDate)
end
+ def test_integer
+ image_item = RDF::Item::ImageItem.new
+
+ image_item.width = nil
+ assert_nil(image_item.width)
+
+ width = 10
+ image_item.width = width
+ assert_equal(width, image_item.width)
+
+ width = 10.0
+ image_item.width = width
+ assert_equal(width, image_item.width)
+
+ width = "10"
+ image_item.width = width
+ assert_equal(width.to_i, image_item.width)
+
+ width = "10.0"
+ assert_not_available_value("image:width", width) do
+ image_item.width = width
+ end
+
+ image_item.do_validate = false
+ width = "10.0"
+ image_item.width = width
+ assert_equal(width.to_i, image_item.width)
+
+ image_item.width = nil
+ assert_nil(image_item.width)
+ end
+
+ def test_positive_integer
+ channel = RDF::Channel.new
+
+ channel.sy_updateFrequency = nil
+ assert_nil(channel.sy_updateFrequency)
+
+ freq = 10
+ channel.sy_updateFrequency = freq
+ assert_equal(freq, channel.sy_updateFrequency)
+
+ freq = 10.0
+ channel.sy_updateFrequency = freq
+ assert_equal(freq, channel.sy_updateFrequency)
+
+ freq = "10"
+ channel.sy_updateFrequency = freq
+ assert_equal(freq.to_i, channel.sy_updateFrequency)
+
+ freq = "10.0"
+ assert_not_available_value("sy:updateFrequency", freq) do
+ channel.sy_updateFrequency = freq
+ end
+
+ channel.do_validate = false
+ freq = "10.0"
+ channel.sy_updateFrequency = freq
+ assert_equal(freq.to_i, channel.sy_updateFrequency)
+
+ channel.sy_updateFrequency = nil
+ assert_nil(channel.sy_updateFrequency)
+ end
end
end
diff --git a/test/rss/test_image.rb b/test/rss/test_image.rb
index e268205..0fb9fce 100644
--- a/test/rss/test_image.rb
+++ b/test/rss/test_image.rb
@@ -26,8 +26,8 @@ module RSS
},
{
"dc:title" => "Example Image",
- "#{@prefix}:width" => 100,
- "#{@prefix}:height" => 65,
+ "#{@prefix}:width" => "100",
+ "#{@prefix}:height" => "65",
},
],
[
@@ -36,8 +36,8 @@ module RSS
},
{
"dc:title" => "Culture",
- "#{@prefix}:width" => 80,
- "#{@prefix}:height" => 50,
+ "#{@prefix}:width" => "80",
+ "#{@prefix}:height" => "50",
},
]
]
@@ -93,6 +93,23 @@ EOR
assert_equal(@favicon_attrs[full_name], favicon.__send__(name))
end
+ %w(small medium large).each do |value|
+ assert_nothing_raised do
+ favicon.size = value
+ favicon.image_size = value
+ end
+ end
+
+ %w(aaa AAA SMALL MEDIUM LARGE).each do |value|
+ args = ["#{@prefix}:favicon", value, "#{@prefix}:size"]
+ assert_not_available_value(*args) do
+ favicon.size = value
+ end
+ assert_not_available_value(*args) do
+ favicon.image_size = value
+ end
+ end
+
[
%w(dc_title dc:title sample-favicon),
].each do |name, full_name, new_value|
@@ -120,10 +137,19 @@ EOR
end
[
- ["width", "image:width", 111],
- ["image_width", "image:width", 44],
- ["height", "image:height", 222],
- ["image_height", "image:height", 88],
+ ["width", "image:width", "111"],
+ ["image_width", "image:width", "44"],
+ ["height", "image:height", "222"],
+ ["image_height", "image:height", "88"],
+ ].each do |name, full_name, new_value|
+ assert_equal(contents[full_name].to_i, image_item.__send__(name))
+ image_item.__send__("#{name}=", new_value)
+ assert_equal(new_value.to_i, image_item.__send__(name))
+ image_item.__send__("#{name}=", contents[full_name])
+ assert_equal(contents[full_name].to_i, image_item.__send__(name))
+ end
+
+ [
["dc_title", "dc:title", "sample-image"],
].each do |name, full_name, new_value|
assert_equal(contents[full_name], image_item.__send__(name))
diff --git a/test/rss/test_maker_0.9.rb b/test/rss/test_maker_0.9.rb
index 8fdd5f2..d855688 100644
--- a/test/rss/test_maker_0.9.rb
+++ b/test/rss/test_maker_0.9.rb
@@ -55,15 +55,15 @@ module RSS
copyright = "foo"
managingEditor = "bar"
webMaster = "web master"
- rating = "6"
+ rating = '(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0))'
docs = "http://foo.com/doc"
skipDays = [
"Sunday",
"Monday",
]
skipHours = [
- 0,
- 13,
+ "0",
+ "13",
]
pubDate = Time.now
lastBuildDate = Time.now
@@ -109,7 +109,7 @@ module RSS
assert_equal(day, channel.skipDays.days[i].content)
end
skipHours.each_with_index do |hour, i|
- assert_equal(hour, channel.skipHours.hours[i].content)
+ assert_equal(hour.to_i, channel.skipHours.hours[i].content)
end
assert(channel.items.empty?)
@@ -165,8 +165,8 @@ module RSS
title = "fugafuga"
link = "http://hoge.com"
url = "http://hoge.com/hoge.png"
- width = 144
- height = 400
+ width = "144"
+ height = "400"
description = "an image"
rss = RSS::Maker.make("0.91") do |maker|
@@ -183,8 +183,8 @@ module RSS
assert_equal(title, image.title)
assert_equal(link, image.link)
assert_equal(url, image.url)
- assert_equal(width, image.width)
- assert_equal(height, image.height)
+ assert_equal(width.to_i, image.width)
+ assert_equal(height.to_i, image.height)
assert_equal(description, image.description)
assert_not_set_error("maker.channel", %w(description title language)) do
@@ -205,8 +205,8 @@ module RSS
title = "fugafuga"
link = "http://hoge.com"
url = "http://hoge.com/hoge.png"
- width = 144
- height = 400
+ width = "144"
+ height = "400"
description = "an image"
rss = RSS::Maker.make("0.91") do |maker|
diff --git a/test/rss/test_maker_1.0.rb b/test/rss/test_maker_1.0.rb
index dca50f7..9d90f3b 100644
--- a/test/rss/test_maker_1.0.rb
+++ b/test/rss/test_maker_1.0.rb
@@ -55,7 +55,7 @@ module RSS
assert_equal(title, channel.title)
assert_equal(link, channel.link)
assert_equal(description, channel.description)
- assert_equal(true, channel.items.Seq.lis.empty?)
+ assert(channel.items.Seq.lis.empty?)
assert_nil(channel.image)
assert_nil(channel.textinput)
diff --git a/test/rss/test_maker_2.0.rb b/test/rss/test_maker_2.0.rb
index b4d402a..2c581f7 100644
--- a/test/rss/test_maker_2.0.rb
+++ b/test/rss/test_maker_2.0.rb
@@ -49,15 +49,15 @@ module RSS
copyright = "foo"
managingEditor = "bar"
webMaster = "web master"
- rating = "6"
+ rating = '(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0))'
docs = "http://foo.com/doc"
skipDays = [
"Sunday",
"Monday",
]
skipHours = [
- 0,
- 13,
+ "0",
+ "13",
]
pubDate = Time.now
lastBuildDate = Time.now
@@ -66,7 +66,7 @@ module RSS
"misc",
]
generator = "RSS Maker"
- ttl = 60
+ ttl = "60"
rss = RSS::Maker.make("2.0") do |maker|
maker.channel.title = title
@@ -117,7 +117,7 @@ module RSS
assert_equal(day, channel.skipDays.days[i].content)
end
skipHours.each_with_index do |hour, i|
- assert_equal(hour, channel.skipHours.hours[i].content)
+ assert_equal(hour.to_i, channel.skipHours.hours[i].content)
end
channel.categories.each_with_index do |category, i|
@@ -125,7 +125,7 @@ module RSS
end
assert_equal(generator, channel.generator)
- assert_equal(ttl, channel.ttl)
+ assert_equal(ttl.to_i, channel.ttl)
assert(channel.items.empty?)
assert_nil(channel.image)
@@ -193,7 +193,7 @@ module RSS
end
cloud = rss.channel.cloud
assert_equal(domain, cloud.domain)
- assert_equal(port, cloud.port)
+ assert_equal(port.to_i, cloud.port)
assert_equal(path, cloud.path)
assert_equal(registerProcedure, cloud.registerProcedure)
assert_equal(protocol, cloud.protocol)
@@ -267,8 +267,8 @@ module RSS
title = "fugafuga"
link = "http://hoge.com"
url = "http://hoge.com/hoge.png"
- width = 144
- height = 400
+ width = "144"
+ height = "400"
description = "an image"
rss = RSS::Maker.make("2.0") do |maker|
@@ -285,8 +285,8 @@ module RSS
assert_equal(title, image.title)
assert_equal(link, image.link)
assert_equal(url, image.url)
- assert_equal(width, image.width)
- assert_equal(height, image.height)
+ assert_equal(width.to_i, image.width)
+ assert_equal(height.to_i, image.height)
assert_equal(description, image.description)
assert_not_set_error("maker.channel", %w(title description)) do
@@ -307,8 +307,8 @@ module RSS
title = "fugafuga"
link = "http://hoge.com"
url = "http://hoge.com/hoge.png"
- width = 144
- height = 400
+ width = "144"
+ height = "400"
description = "an image"
rss = RSS::Maker.make("2.0") do |maker|
@@ -418,7 +418,7 @@ module RSS
end
def test_guid
- isPermaLink = true
+ isPermaLink = "true"
content = "http://inessential.com/2002/09/01.php#a2"
rss = RSS::Maker.make("2.0") do |maker|
@@ -430,7 +430,7 @@ module RSS
guid.content = content
end
guid = rss.channel.items.last.guid
- assert_equal(isPermaLink, guid.isPermaLink)
+ assert_equal(isPermaLink == "true", guid.isPermaLink)
assert_equal(content, guid.content)
end
@@ -463,7 +463,7 @@ module RSS
end
enclosure = rss.channel.items.last.enclosure
assert_equal(url, enclosure.url)
- assert_equal(length, enclosure.length)
+ assert_equal(length.to_i, enclosure.length)
assert_equal(type, enclosure.type)
end
diff --git a/test/rss/test_maker_image.rb b/test/rss/test_maker_image.rb
index 1c161b2..1fc8076 100644
--- a/test/rss/test_maker_image.rb
+++ b/test/rss/test_maker_image.rb
@@ -17,8 +17,8 @@ module RSS
"about" => "http://www.example.org/item.png",
"resource" => "http://www.example.org/item",
"dc_title" => "Example Image",
- "image_width" => 100,
- "image_height" => 65,
+ "image_width" => "100",
+ "image_height" => "65",
}
end
@@ -53,8 +53,8 @@ module RSS
item = target.items.last.image_item
assert_equal(@item_infos["about"], item.about)
assert_equal(@item_infos["resource"], item.resource)
- assert_equal(@item_infos["image_width"], item.image_width)
- assert_equal(@item_infos["image_height"], item.image_height)
+ assert_equal(@item_infos["image_width"].to_i, item.image_width)
+ assert_equal(@item_infos["image_height"].to_i, item.image_height)
assert_equal(@item_infos["dc_title"], item.dc_title)
end
end
diff --git a/test/rss/test_maker_sy.rb b/test/rss/test_maker_sy.rb
index 58e95d9..fd6df9a 100644
--- a/test/rss/test_maker_sy.rb
+++ b/test/rss/test_maker_sy.rb
@@ -15,7 +15,7 @@ module RSS
@elements = {
:updatePeriod => "hourly",
- :updateFrequency => 2,
+ :updateFrequency => "2",
:updateBase => t,
}
end
diff --git a/test/rss/test_setup_maker_0.9.rb b/test/rss/test_setup_maker_0.9.rb
index 217ea8b..086065c 100644
--- a/test/rss/test_setup_maker_0.9.rb
+++ b/test/rss/test_setup_maker_0.9.rb
@@ -13,15 +13,15 @@ module RSS
copyright = "foo"
managingEditor = "bar"
webMaster = "web master"
- rating = "6"
+ rating = '(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0))'
docs = "http://foo.com/doc"
skipDays = [
"Sunday",
"Monday",
]
skipHours = [
- 0,
- 13,
+ "0",
+ "13",
]
pubDate = Time.now
lastBuildDate = Time.now
@@ -70,7 +70,7 @@ module RSS
assert_equal(day, channel.skipDays.days[i].content)
end
skipHours.each_with_index do |hour, i|
- assert_equal(hour, channel.skipHours.hours[i].content)
+ assert_equal(hour.to_i, channel.skipHours.hours[i].content)
end
assert(channel.items.empty?)
@@ -82,8 +82,8 @@ module RSS
title = "fugafuga"
link = "http://hoge.com"
url = "http://hoge.com/hoge.png"
- width = 144
- height = 400
+ width = "144"
+ height = "400"
description = "an image"
rss = RSS::Maker.make("0.91") do |maker|
@@ -106,8 +106,8 @@ module RSS
assert_equal(title, image.title)
assert_equal(link, image.link)
assert_equal(url, image.url)
- assert_equal(width, image.width)
- assert_equal(height, image.height)
+ assert_equal(width.to_i, image.width)
+ assert_equal(height.to_i, image.height)
assert_equal(description, image.description)
end
diff --git a/test/rss/test_setup_maker_1.0.rb b/test/rss/test_setup_maker_1.0.rb
index cd0958a..95d8b31 100644
--- a/test/rss/test_setup_maker_1.0.rb
+++ b/test/rss/test_setup_maker_1.0.rb
@@ -32,7 +32,7 @@ module RSS
@sy_elems = {
:updatePeriod => "hourly",
- :updateFrequency => 2,
+ :updateFrequency => "2",
:updateBase => t,
}
@@ -107,6 +107,7 @@ module RSS
end
@sy_elems.each do |var, value|
+ value = value.to_i if var == :updateFrequency
assert_equal(value, channel.__send__("sy_#{var}"))
end
@@ -473,6 +474,7 @@ module RSS
assert_equal(value, channel.__send__("dc_#{var}"))
end
@sy_elems.each do |var, value|
+ value = value.to_i if var == :updateFrequency
assert_equal(value, channel.__send__("sy_#{var}"))
end
diff --git a/test/rss/test_setup_maker_2.0.rb b/test/rss/test_setup_maker_2.0.rb
index 6bf27d4..a35096c 100644
--- a/test/rss/test_setup_maker_2.0.rb
+++ b/test/rss/test_setup_maker_2.0.rb
@@ -13,15 +13,15 @@ module RSS
copyright = "foo"
managingEditor = "bar"
webMaster = "web master"
- rating = "6"
+ rating = '(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0))'
docs = "http://foo.com/doc"
skipDays = [
"Sunday",
"Monday",
]
skipHours = [
- 0,
- 13,
+ "0",
+ "13",
]
pubDate = Time.now
lastBuildDate = Time.now
@@ -30,7 +30,7 @@ module RSS
"misc",
]
generator = "RSS Maker"
- ttl = 60
+ ttl = "60"
rss = RSS::Maker.make("2.0") do |maker|
maker.channel.title = title
@@ -85,7 +85,7 @@ module RSS
assert_equal(day, channel.skipDays.days[i].content)
end
skipHours.each_with_index do |hour, i|
- assert_equal(hour, channel.skipHours.hours[i].content)
+ assert_equal(hour.to_i, channel.skipHours.hours[i].content)
end
@@ -94,7 +94,7 @@ module RSS
end
assert_equal(generator, channel.generator)
- assert_equal(ttl, channel.ttl)
+ assert_equal(ttl.to_i, channel.ttl)
assert(channel.items.empty?)
@@ -106,8 +106,8 @@ module RSS
title = "fugafuga"
link = "http://hoge.com"
url = "http://hoge.com/hoge.png"
- width = 144
- height = 400
+ width = "144"
+ height = "400"
description = "an image"
rss = RSS::Maker.make("2.0") do |maker|
@@ -130,8 +130,8 @@ module RSS
assert_equal(title, image.title)
assert_equal(link, image.link)
assert_equal(url, image.url)
- assert_equal(width, image.width)
- assert_equal(height, image.height)
+ assert_equal(width.to_i, image.width)
+ assert_equal(height.to_i, image.height)
assert_equal(description, image.description)
end
@@ -170,7 +170,7 @@ module RSS
comments = "http://www.myblog.org/cgi-local/mt/mt-comments.cgi?entry_id=290"
pubDate = Time.now
- guid_isPermaLink = true
+ guid_isPermaLink = "true"
guid_content = "http://inessential.com/2002/09/01.php#a2"
enclosure_url = "http://www.scripting.com/mp3s/weatherReportSuite.mp3"
@@ -234,11 +234,11 @@ module RSS
assert_equal("#{comments}#{i}", item.comments)
assert_equal(pubDate, item.pubDate)
- assert_equal(guid_isPermaLink, item.guid.isPermaLink)
+ assert_equal(guid_isPermaLink == "true", item.guid.isPermaLink)
assert_equal(guid_content, item.guid.content)
assert_equal(enclosure_url, item.enclosure.url)
- assert_equal(enclosure_length, item.enclosure.length)
+ assert_equal(enclosure_length.to_i, item.enclosure.length)
assert_equal(enclosure_type, item.enclosure.type)
assert_equal(source_url, item.source.url)
diff --git a/test/rss/test_syndication.rb b/test/rss/test_syndication.rb
index 0a3a21f..894a785 100644
--- a/test/rss/test_syndication.rb
+++ b/test/rss/test_syndication.rb
@@ -22,7 +22,7 @@ module RSS
@elems = {
:updatePeriod => "hourly",
- :updateFrequency => 2,
+ :updateFrequency => "2",
:updateBase => t,
}
@@ -68,16 +68,18 @@ EOR
new_value = {
:updatePeriod => "daily",
- :updateFrequency => +11,
+ :updateFrequency => "11",
:updateBase => t,
}
@elems.each do |name, value|
+ value = value.to_i if name == :updateFrequency
@parents.each do |parent|
- assert_equal(value, @rss.__send__(parent).funcall("sy_#{name}"))
- @rss.__send__(parent).funcall("sy_#{name}=", new_value[name].to_s)
- assert_equal(new_value[name],
- @rss.__send__(parent).funcall("sy_#{name}"))
+ assert_equal(value, @rss.__send__(parent).__send__("sy_#{name}"))
+ @rss.__send__(parent).__send__("sy_#{name}=", new_value[name])
+ new_val = new_value[name]
+ new_val = new_val.to_i if name == :updateFrequency
+ assert_equal(new_val, @rss.__send__(parent).__send__("sy_#{name}"))
end
end
diff --git a/test/rss/test_to_s.rb b/test/rss/test_to_s.rb
index d6c761e..1538534 100644
--- a/test/rss/test_to_s.rb
+++ b/test/rss/test_to_s.rb
@@ -146,13 +146,13 @@ module RSS
"Friday",
],
"skipHours" => [
- 12,
- 23,
+ "12",
+ "23",
],
"date" => Time.now,
"lastBuildDate" => Time.now - 3600,
"generator" => "RSS Maker",
- "ttl" => 60,
+ "ttl" => "60",
"cloud" => {
"domain" => "rpc.sys.com",
"port" => "80",
@@ -187,7 +187,7 @@ module RSS
"author" => "foo@example.com",
"comments" => "http://example.com/1/comments",
"guid" => {
- "isPermaLink" => "ture",
+ "isPermaLink" => "true",
"content" => "http://example.com/1",
},
"enclosure" => {
@@ -275,7 +275,7 @@ module RSS
def setup_syndication_info
@sy_info = {
"updatePeriod" => "hourly",
- "updateFrequency" => 2,
+ "updateFrequency" => "2",
"updateBase" => Time.now - 3600,
}
end