summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-17 01:28:46 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-17 01:28:46 +0000
commit02cce7ed8273bab55081357c57f24a8265a6f32a (patch)
tree81fcc7a474ce90e19acf57390e5b5795849de6c0 /test
parent463c6a218fed7248531a002806e9b07be7f5a6ea (diff)
* lib/rss/rss.rb (Kernel#funcall): removed.
* lib/rss/parser.rb (Kernel.URI): removed. * lib/rss/maker/: supported xxx.new_yyy do |yyy| yyy.zzz = zzz ... end style and this style became the style of the recommendation. Old style yyy = xxx.new_yyy yyy.zzz = zzz ... is supported too but this style isn't recommended. [ruby-talk:197284] * test/rss/test_*maker*.rb: used new recommended style. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/rss/test_maker_0.9.rb37
-rw-r--r--test/rss/test_maker_1.0.rb68
-rw-r--r--test/rss/test_maker_2.0.rb57
-rw-r--r--test/rss/test_maker_dc.rb20
-rw-r--r--test/rss/test_maker_taxo.rb10
-rw-r--r--test/rss/test_maker_trackback.rb5
-rw-r--r--test/rss/test_maker_xml-stylesheet.rb42
-rw-r--r--test/rss/test_setup_maker_0.9.rb36
-rw-r--r--test/rss/test_setup_maker_1.0.rb106
-rw-r--r--test/rss/test_setup_maker_2.0.rb75
10 files changed, 251 insertions, 205 deletions
diff --git a/test/rss/test_maker_0.9.rb b/test/rss/test_maker_0.9.rb
index d855688..820d567 100644
--- a/test/rss/test_maker_0.9.rb
+++ b/test/rss/test_maker_0.9.rb
@@ -82,12 +82,14 @@ module RSS
maker.channel.lastBuildDate = lastBuildDate
skipDays.each do |day|
- new_day = maker.channel.skipDays.new_day
- new_day.content = day
+ maker.channel.skipDays.new_day do |new_day|
+ new_day.content = day
+ end
end
skipHours.each do |hour|
- new_hour = maker.channel.skipHours.new_hour
- new_hour.content = hour
+ maker.channel.skipHours.new_hour do |new_hour|
+ new_hour.content = hour
+ end
end
end
channel = rss.channel
@@ -261,10 +263,11 @@ module RSS
rss = RSS::Maker.make("0.91") do |maker|
setup_dummy_channel(maker)
- item = maker.items.new_item
- item.title = title
- item.link = link
- # item.description = description
+ maker.items.new_item do |item|
+ item.title = title
+ item.link = link
+ # item.description = description
+ end
end
assert_equal(1, rss.channel.items.size)
item = rss.channel.items.first
@@ -278,10 +281,11 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |item|
+ item.title = "#{title}#{i}"
+ item.link = "#{link}#{i}"
+ item.description = "#{description}#{i}"
+ end
end
maker.items.do_sort = true
end
@@ -296,10 +300,11 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |item|
+ item.title = "#{title}#{i}"
+ item.link = "#{link}#{i}"
+ item.description = "#{description}#{i}"
+ end
end
maker.items.do_sort = Proc.new do |x, y|
y.title[-1] <=> x.title[-1]
diff --git a/test/rss/test_maker_1.0.rb b/test/rss/test_maker_1.0.rb
index 9d90f3b..e154321 100644
--- a/test/rss/test_maker_1.0.rb
+++ b/test/rss/test_maker_1.0.rb
@@ -203,10 +203,11 @@ module RSS
rss = RSS::Maker.make("1.0") do |maker|
setup_dummy_channel(maker)
- item = maker.items.new_item
- item.title = title
- item.link = link
- # item.description = description
+ maker.items.new_item do |item|
+ item.title = title
+ item.link = link
+ # item.description = description
+ end
end
assert_equal(1, rss.items.size)
item = rss.items.first
@@ -221,10 +222,11 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |item|
+ item.title = "#{title}#{i}"
+ item.link = "#{link}#{i}"
+ item.description = "#{description}#{i}"
+ end
end
maker.items.do_sort = true
end
@@ -240,10 +242,11 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |item|
+ item.title = "#{title}#{i}"
+ item.link = "#{link}#{i}"
+ item.description = "#{description}#{i}"
+ end
end
maker.items.do_sort = Proc.new do |x, y|
y.title[-1] <=> x.title[-1]
@@ -262,10 +265,11 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |item|
+ item.title = "#{title}#{i}"
+ item.link = "#{link}#{i}"
+ item.description = "#{description}#{i}"
+ end
end
maker.items.max_size = max_size
end
@@ -282,10 +286,11 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |item|
+ item.title = "#{title}#{i}"
+ item.link = "#{link}#{i}"
+ item.description = "#{description}#{i}"
+ end
end
maker.items.max_size = max_size
end
@@ -296,10 +301,11 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |item|
+ item.title = "#{title}#{i}"
+ item.link = "#{link}#{i}"
+ item.description = "#{description}#{i}"
+ end
end
maker.items.max_size = max_size
end
@@ -319,18 +325,20 @@ module RSS
rss = RSS::Maker.make("1.0") do |maker|
setup_dummy_channel(maker)
- item = maker.items.new_item
- # item.title = title
- item.link = link
+ maker.items.new_item do |item|
+ # item.title = title
+ item.link = link
+ end
end
assert(rss.items.empty?)
rss = RSS::Maker.make("1.0") do |maker|
setup_dummy_channel(maker)
- item = maker.items.new_item
- item.title = title
- # item.link = link
+ maker.items.new_item do |item|
+ item.title = title
+ # item.link = link
+ end
end
assert(rss.items.empty?)
end
diff --git a/test/rss/test_maker_2.0.rb b/test/rss/test_maker_2.0.rb
index 2c581f7..ec5f3ab 100644
--- a/test/rss/test_maker_2.0.rb
+++ b/test/rss/test_maker_2.0.rb
@@ -82,17 +82,20 @@ module RSS
maker.channel.lastBuildDate = lastBuildDate
skipDays.each do |day|
- new_day = maker.channel.skipDays.new_day
- new_day.content = day
+ maker.channel.skipDays.new_day do |new_day|
+ new_day.content = day
+ end
end
skipHours.each do |hour|
- new_hour = maker.channel.skipHours.new_hour
- new_hour.content = hour
+ maker.channel.skipHours.new_hour do |new_hour|
+ new_hour.content = hour
+ end
end
categories.each do |category|
- new_category = maker.channel.categories.new_category
- new_category.content = category
+ maker.channel.categories.new_category do |new_category|
+ new_category.content = category
+ end
end
maker.channel.generator = generator
@@ -368,13 +371,14 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
- item.author = "#{author}#{i}"
- item.comments = "#{comments}#{i}"
- item.date = pubDate
+ maker.items.new_item do |item|
+ item.title = "#{title}#{i}"
+ item.link = "#{link}#{i}"
+ item.description = "#{description}#{i}"
+ item.author = "#{author}#{i}"
+ item.comments = "#{comments}#{i}"
+ item.date = pubDate
+ end
end
maker.items.do_sort = true
end
@@ -393,13 +397,14 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
- item.author = "#{author}#{i}"
- item.comments = "#{comments}#{i}"
- item.date = pubDate
+ maker.items.new_item do |item|
+ item.title = "#{title}#{i}"
+ item.link = "#{link}#{i}"
+ item.description = "#{description}#{i}"
+ item.author = "#{author}#{i}"
+ item.comments = "#{comments}#{i}"
+ item.date = pubDate
+ end
end
maker.items.do_sort = Proc.new do |x, y|
y.title[-1] <=> x.title[-1]
@@ -557,9 +562,10 @@ module RSS
setup_dummy_channel(maker)
setup_dummy_item(maker)
- category = maker.items.last.categories.new_category
- category.domain = domain
- category.content = content
+ maker.items.last.categories.new_category do |category|
+ category.domain = domain
+ category.content = content
+ end
end
category = rss.channel.items.last.categories.last
assert_equal(domain, category.domain)
@@ -573,8 +579,9 @@ module RSS
setup_dummy_channel(maker)
setup_dummy_item(maker)
- category = maker.items.last.categories.new_category
- # category.content = content
+ maker.items.last.categories.new_category do |category|
+ # category.content = content
+ end
end
assert(rss.channel.items.last.categories.empty?)
end
diff --git a/test/rss/test_maker_dc.rb b/test/rss/test_maker_dc.rb
index 9f568ed..6266e95 100644
--- a/test/rss/test_maker_dc.rb
+++ b/test/rss/test_maker_dc.rb
@@ -81,8 +81,9 @@ module RSS
elems.each do |name, values, plural|
dc_elems = item.__send__("dc_#{plural}")
values.each do |value|
- elem = dc_elems.__send__("new_#{name}")
- elem.value = value
+ dc_elems.__send__("new_#{name}") do |elem|
+ elem.value = value
+ end
end
end
@@ -102,14 +103,16 @@ module RSS
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
+ maker.channel.dc_dates.new_date do |date|
+ date.value = t2
+ end
setup_dummy_item(maker)
item = maker.items.last
item.date = t2
- date = item.dc_dates.new_date
- date.value = t1
+ item.dc_dates.new_date do |date|
+ date.value = t1
+ end
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})
@@ -131,8 +134,9 @@ module RSS
plural ||= "#{name}s"
dc_elems = target.__send__("dc_#{plural}")
values.each do |value|
- new_dc_elem = dc_elems.__send__("new_#{name}")
- new_dc_elem.value = value
+ dc_elems.__send__("new_#{name}") do |new_dc_elem|
+ new_dc_elem.value = value
+ end
end
end
end
diff --git a/test/rss/test_maker_taxo.rb b/test/rss/test_maker_taxo.rb
index 1c7d284..8feb4e1 100644
--- a/test/rss/test_maker_taxo.rb
+++ b/test/rss/test_maker_taxo.rb
@@ -56,14 +56,16 @@ module RSS
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
+ maker.channel.dc_dates.new_date do |date|
+ date.value = t2
+ end
setup_dummy_item(maker)
item = maker.items.last
item.date = t2
- date = item.dc_dates.new_date
- date.value = t1
+ item.dc_dates.new_date do |date|
+ date.value = t1
+ end
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})
diff --git a/test/rss/test_maker_trackback.rb b/test/rss/test_maker_trackback.rb
index e90bb60..58705c6 100644
--- a/test/rss/test_maker_trackback.rb
+++ b/test/rss/test_maker_trackback.rb
@@ -25,8 +25,9 @@ module RSS
item = maker.items.last
item.trackback_ping = @elements[:ping]
@elements[:abouts].each do |about|
- new_about = item.trackback_abouts.new_about
- new_about.value = about
+ item.trackback_abouts.new_about do |new_about|
+ new_about.value = about
+ end
end
end
assert_trackback(@elements, rss.items.last)
diff --git a/test/rss/test_maker_xml-stylesheet.rb b/test/rss/test_maker_xml-stylesheet.rb
index bbdfdc6..c380f21 100644
--- a/test/rss/test_maker_xml-stylesheet.rb
+++ b/test/rss/test_maker_xml-stylesheet.rb
@@ -14,14 +14,15 @@ module RSS
alternate = 'yes'
rss = RSS::Maker.make("1.0") do |maker|
- xss = maker.xml_stylesheets.new_xml_stylesheet
- xss.href = href
- xss.type = type
- xss.title = title
- xss.media = media
- xss.charset = charset
- xss.alternate = alternate
-
+ maker.xml_stylesheets.new_xml_stylesheet do |xss|
+ xss.href = href
+ xss.type = type
+ xss.title = title
+ xss.media = media
+ xss.charset = charset
+ xss.alternate = alternate
+ end
+
setup_dummy_channel(maker)
end
@@ -37,9 +38,10 @@ module RSS
href = 'http://example.com/index.xsl'
type = 'text/xsl'
rss = RSS::Maker.make("1.0") do |maker|
- xss = maker.xml_stylesheets.new_xml_stylesheet
- xss.href = href
-
+ maker.xml_stylesheets.new_xml_stylesheet do |xss|
+ xss.href = href
+ end
+
setup_dummy_channel(maker)
end
@@ -53,19 +55,21 @@ module RSS
type = "text/xsl"
rss = RSS::Maker.make("1.0") do |maker|
- xss = maker.xml_stylesheets.new_xml_stylesheet
- # xss.href = href
- xss.type = type
-
+ maker.xml_stylesheets.new_xml_stylesheet do |xss|
+ # xss.href = href
+ xss.type = type
+ end
+
setup_dummy_channel(maker)
end
assert(rss.xml_stylesheets.empty?)
rss = RSS::Maker.make("1.0") do |maker|
- xss = maker.xml_stylesheets.new_xml_stylesheet
- xss.href = href
- # xss.type = type
-
+ maker.xml_stylesheets.new_xml_stylesheet do |xss|
+ xss.href = href
+ # xss.type = type
+ end
+
setup_dummy_channel(maker)
end
assert(rss.xml_stylesheets.empty?)
diff --git a/test/rss/test_setup_maker_0.9.rb b/test/rss/test_setup_maker_0.9.rb
index 086065c..9408728 100644
--- a/test/rss/test_setup_maker_0.9.rb
+++ b/test/rss/test_setup_maker_0.9.rb
@@ -40,12 +40,14 @@ module RSS
maker.channel.lastBuildDate = lastBuildDate
skipDays.each do |day|
- new_day = maker.channel.skipDays.new_day
- new_day.content = day
+ maker.channel.skipDays.new_day do |new_day|
+ new_day.content = day
+ end
end
skipHours.each do |hour|
- new_hour = maker.channel.skipHours.new_hour
- new_hour.content = hour
+ maker.channel.skipHours.new_hour do |new_hour|
+ new_hour.content = hour
+ end
end
end
@@ -149,10 +151,11 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |item|
+ item.title = "#{title}#{i}"
+ item.link = "#{link}#{i}"
+ item.description = "#{description}#{i}"
+ end
end
end
@@ -196,14 +199,15 @@ module RSS
maker.encoding = encoding
maker.standalone = standalone
- xss = maker.xml_stylesheets.new_xml_stylesheet
- xss.href = href
- xss.type = type
- xss.title = title
- xss.media = media
- xss.charset = charset
- xss.alternate = alternate
-
+ maker.xml_stylesheets.new_xml_stylesheet do |xss|
+ xss.href = href
+ xss.type = type
+ xss.title = title
+ xss.media = media
+ xss.charset = charset
+ xss.alternate = alternate
+ end
+
setup_dummy_channel(maker)
end
diff --git a/test/rss/test_setup_maker_1.0.rb b/test/rss/test_setup_maker_1.0.rb
index 95d8b31..51a4d14 100644
--- a/test/rss/test_setup_maker_1.0.rb
+++ b/test/rss/test_setup_maker_1.0.rb
@@ -195,23 +195,25 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
-
- @dc_elems.each do |var, value|
- item.__send__("dc_#{var}=", value)
- end
-
- @content_elems.each do |var, value|
- item.__send__("content_#{var}=", value)
- end
-
- item.trackback_ping = @trackback_elems[:ping]
- @trackback_elems[:about].each do |value|
- new_about = item.trackback_abouts.new_about
- new_about.value = value
+ maker.items.new_item do |item|
+ item.title = "#{title}#{i}"
+ item.link = "#{link}#{i}"
+ item.description = "#{description}#{i}"
+
+ @dc_elems.each do |var, value|
+ item.__send__("dc_#{var}=", value)
+ end
+
+ @content_elems.each do |var, value|
+ item.__send__("content_#{var}=", value)
+ end
+
+ item.trackback_ping = @trackback_elems[:ping]
+ @trackback_elems[:about].each do |value|
+ item.trackback_abouts.new_about do |new_about|
+ new_about.value = value
+ end
+ end
end
end
end
@@ -321,14 +323,15 @@ module RSS
maker.encoding = encoding
maker.standalone = standalone
- xss = maker.xml_stylesheets.new_xml_stylesheet
- xss.href = href
- xss.type = type
- xss.title = title
- xss.media = media
- xss.charset = charset
- xss.alternate = alternate
-
+ maker.xml_stylesheets.new_xml_stylesheet do |xss|
+ xss.href = href
+ xss.type = type
+ xss.title = title
+ xss.media = media
+ xss.charset = charset
+ xss.alternate = alternate
+ end
+
setup_dummy_channel(maker)
end
@@ -384,14 +387,15 @@ module RSS
maker.encoding = encoding
maker.standalone = standalone
- xss = maker.xml_stylesheets.new_xml_stylesheet
- xss.href = href
- xss.type = type
- xss.title = title
- xss.media = media
- xss.charset = charset
- xss.alternate = alternate
-
+ maker.xml_stylesheets.new_xml_stylesheet do |xss|
+ xss.href = href
+ xss.type = type
+ xss.title = title
+ xss.media = media
+ xss.charset = charset
+ xss.alternate = alternate
+ end
+
maker.channel.about = channel_about
maker.channel.title = channel_title
maker.channel.link = channel_link
@@ -418,23 +422,25 @@ module RSS
end
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{item_title}#{i}"
- item.link = "#{item_link}#{i}"
- item.description = "#{item_description}#{i}"
-
- @dc_elems.each do |var, value|
- item.__send__("dc_#{var}=", value)
- end
-
- @content_elems.each do |var, value|
- item.__send__("content_#{var}=", value)
- end
-
- item.trackback_ping = @trackback_elems[:ping]
- @trackback_elems[:about].each do |value|
- new_about = item.trackback_abouts.new_about
- new_about.value = value
+ maker.items.new_item do |item|
+ item.title = "#{item_title}#{i}"
+ item.link = "#{item_link}#{i}"
+ item.description = "#{item_description}#{i}"
+
+ @dc_elems.each do |var, value|
+ item.__send__("dc_#{var}=", value)
+ end
+
+ @content_elems.each do |var, value|
+ item.__send__("content_#{var}=", value)
+ end
+
+ item.trackback_ping = @trackback_elems[:ping]
+ @trackback_elems[:about].each do |value|
+ item.trackback_abouts.new_about do |new_about|
+ new_about.value = value
+ end
+ end
end
end
diff --git a/test/rss/test_setup_maker_2.0.rb b/test/rss/test_setup_maker_2.0.rb
index a35096c..8fb727d 100644
--- a/test/rss/test_setup_maker_2.0.rb
+++ b/test/rss/test_setup_maker_2.0.rb
@@ -46,18 +46,21 @@ module RSS
maker.channel.lastBuildDate = lastBuildDate
skipDays.each do |day|
- new_day = maker.channel.skipDays.new_day
- new_day.content = day
+ maker.channel.skipDays.new_day do |new_day|
+ new_day.content = day
+ end
end
skipHours.each do |hour|
- new_hour = maker.channel.skipHours.new_hour
- new_hour.content = hour
+ maker.channel.skipHours.new_hour do |new_hour|
+ new_hour.content = hour
+ end
end
categories.each do |category|
- new_category = maker.channel.categories.new_category
- new_category.content = category
+ maker.channel.categories.new_category do |new_category|
+ new_category.content = category
+ end
end
maker.channel.generator = generator
@@ -189,27 +192,28 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- item = maker.items.new_item
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
- item.author = "#{author}#{i}"
- item.comments = "#{comments}#{i}"
- item.date = pubDate
-
- item.guid.isPermaLink = guid_isPermaLink
- item.guid.content = guid_content
-
- item.enclosure.url = enclosure_url
- item.enclosure.length = enclosure_length
- item.enclosure.type = enclosure_type
-
- item.source.url = source_url
- item.source.content = source_content
-
- category = item.categories.new_category
- category.domain = category_domain
- category.content = category_content
+ maker.items.new_item do |item|
+ item.title = "#{title}#{i}"
+ item.link = "#{link}#{i}"
+ item.description = "#{description}#{i}"
+ item.author = "#{author}#{i}"
+ item.comments = "#{comments}#{i}"
+ item.date = pubDate
+
+ item.guid.isPermaLink = guid_isPermaLink
+ item.guid.content = guid_content
+
+ item.enclosure.url = enclosure_url
+ item.enclosure.length = enclosure_length
+ item.enclosure.type = enclosure_type
+
+ item.source.url = source_url
+ item.source.content = source_content
+
+ category = item.categories.new_category
+ category.domain = category_domain
+ category.content = category_content
+ end
end
end
@@ -270,14 +274,15 @@ module RSS
maker.encoding = encoding
maker.standalone = standalone
- xss = maker.xml_stylesheets.new_xml_stylesheet
- xss.href = href
- xss.type = type
- xss.title = title
- xss.media = media
- xss.charset = charset
- xss.alternate = alternate
-
+ maker.xml_stylesheets.new_xml_stylesheet do |xss|
+ xss.href = href
+ xss.type = type
+ xss.title = title
+ xss.media = media
+ xss.charset = charset
+ xss.alternate = alternate
+ end
+
setup_dummy_channel(maker)
end