summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rexml/test_contrib.rb8
-rw-r--r--test/rexml/test_lightparser.rb2
-rw-r--r--test/rexml/test_pullparser.rb4
-rw-r--r--test/rexml/test_xpath.rb8
-rw-r--r--test/rexml/test_xpathtext.rb2
-rw-r--r--test/rss/rss-assertions.rb2
-rw-r--r--test/rss/rss-testcase.rb2
-rw-r--r--test/rss/test_1.0.rb54
-rw-r--r--test/rss/test_2.0.rb54
-rw-r--r--test/rss/test_atom.rb24
-rw-r--r--test/rss/test_maker_2.0.rb8
11 files changed, 92 insertions, 76 deletions
diff --git a/test/rexml/test_contrib.rb b/test/rexml/test_contrib.rb
index 7d00202c95..db7c18d027 100644
--- a/test/rexml/test_contrib.rb
+++ b/test/rexml/test_contrib.rb
@@ -221,7 +221,7 @@ DELIMITER
<type>Book</type>
<year>2000</year>
</entry>"
- desired_result_tree = Document.new desired_result_string
+ Document.new desired_result_string
xpath = "/biblio/entry[not(author)]"
result = XPath.first(doc, xpath)
assert_equal desired_result_string, result.to_s
@@ -438,7 +438,7 @@ EOF
end
def test_whitespace_after_xml_decl
- d = Document.new <<EOL
+ Document.new <<EOL
<?xml version='1.0'?>
<blo>
<wak>
@@ -506,7 +506,7 @@ EOL
b << c
a << b
- REXML::Formatters::Pretty.new.write(a,s="")
+ REXML::Formatters::Pretty.new.write(a,"")
end
def test_pos
@@ -523,7 +523,7 @@ EOL
testfile.puts testdata
testfile.rewind
assert_nothing_raised do
- d = REXML::Document.new(testfile)
+ REXML::Document.new(testfile)
end
testfile.close(true)
end
diff --git a/test/rexml/test_lightparser.rb b/test/rexml/test_lightparser.rb
index ee33dc08fd..1728921434 100644
--- a/test/rexml/test_lightparser.rb
+++ b/test/rexml/test_lightparser.rb
@@ -7,6 +7,6 @@ class LightParserTester < Test::Unit::TestCase
def test_parsing
f = File.new(fixture_path("documentation.xml"))
parser = REXML::Parsers::LightParser.new( f )
- root = parser.parse
+ parser.parse
end
end
diff --git a/test/rexml/test_pullparser.rb b/test/rexml/test_pullparser.rb
index bfce60f268..03c95642e4 100644
--- a/test/rexml/test_pullparser.rb
+++ b/test/rexml/test_pullparser.rb
@@ -33,7 +33,7 @@ class PullParserTester < Test::Unit::TestCase
source = "<a><b></a>"
parser = REXML::Parsers::PullParser.new(source)
assert_raise(ParseException, "Parsing should have failed") {
- results = parser.pull while parser.has_next?
+ parser.pull while parser.has_next?
}
end
@@ -63,7 +63,7 @@ class PullParserTester < Test::Unit::TestCase
def test_peek_unshift
source = "<a><b/></a>"
- pp = REXML::Parsers::PullParser.new(source)
+ REXML::Parsers::PullParser.new(source)
# FINISH ME!
end
diff --git a/test/rexml/test_xpath.rb b/test/rexml/test_xpath.rb
index ad09fcafb2..4ccd4edeaf 100644
--- a/test/rexml/test_xpath.rb
+++ b/test/rexml/test_xpath.rb
@@ -219,7 +219,7 @@ class XPathTester < Test::Unit::TestCase
for line in File.new(xpathtests)
line.strip!
begin
- rt = doc.root
+ doc.root
#puts "#"*80
#print "\nDoing #{line} " ; $stdout.flush
doc.elements.each(line) do |el|
@@ -332,7 +332,7 @@ class XPathTester < Test::Unit::TestCase
</foo>
EOF
doc = Document.new source
- result = XPath.each( doc, "//bar" ) {
+ XPath.each( doc, "//bar" ) {
fail "'bar' should match nothing in this case"
}
@@ -523,7 +523,7 @@ class XPathTester < Test::Unit::TestCase
# examples from http://www.w3.org/TR/xpath#function-substring
doc = Document.new('<test string="12345" />')
- d = Document.new("<a b='1'/>")
+ Document.new("<a b='1'/>")
#puts XPath.first(d, 'node()[0 + 1]')
#d = Document.new("<a b='1'/>")
#puts XPath.first(d, 'a[0 mod 0]')
@@ -589,7 +589,7 @@ class XPathTester < Test::Unit::TestCase
def test_name
assert_raise( UndefinedNamespaceException, "x should be undefined" ) {
- d = REXML::Document.new("<a x='foo'><b/><x:b/></a>")
+ REXML::Document.new("<a x='foo'><b/><x:b/></a>")
}
d = REXML::Document.new("<a xmlns:x='foo'><b/><x:b/></a>")
assert_equal 1, d.root.elements.to_a('*[name() = "b"]').size
diff --git a/test/rexml/test_xpathtext.rb b/test/rexml/test_xpathtext.rb
index c3393987f2..87441cb6d5 100644
--- a/test/rexml/test_xpathtext.rb
+++ b/test/rexml/test_xpathtext.rb
@@ -14,7 +14,7 @@ class XpathTestCase < Test::Unit::TestCase
def test_text_as_element
node1 = REXML::Element.new('a', @doc)
node2 = REXML::Element.new('b', node1)
- textnode = REXML::Text.new('test', false, node2)
+ REXML::Text.new('test', false, node2)
assert_equal(1, @doc.elements.size, "doc owns 1 element node1")
assert_same(node1, @doc.elements[1], "doc owns 1 element node1")
assert_equal(1, node1.elements.size, "node1 owns 1 element node2")
diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb
index 86f9dd87c0..090980a650 100644
--- a/test/rss/rss-assertions.rb
+++ b/test/rss/rss-assertions.rb
@@ -972,7 +972,7 @@ EOA
feed_readers) do |maker|
yield maker
targets = chain_reader(maker, maker_readers)
- target = targets.new_child
+ targets.new_child
end
end
diff --git a/test/rss/rss-testcase.rb b/test/rss/rss-testcase.rb
index 6a7093a8da..4943fc9017 100644
--- a/test/rss/rss-testcase.rb
+++ b/test/rss/rss-testcase.rb
@@ -186,7 +186,7 @@ EORSS
elems = ["<link>#{res}</link>"]
elems << "<title>title of #{res}</title>"
elems = elems.join("\n")
- item = "<item>\n#{elems}\n</item>"
+ "<item>\n#{elems}\n</item>"
end.join("\n")
end
diff --git a/test/rss/test_1.0.rb b/test/rss/test_1.0.rb
index 4b496adfcd..cb9f715eec 100644
--- a/test/rss/test_1.0.rb
+++ b/test/rss/test_1.0.rb
@@ -54,9 +54,6 @@ module RSS
def test_channel
about = "http://hoge.com"
- title = "fugafuga"
- link = "http://hoge.com"
- description = "fugafugafugafuga"
resource = "http://hoge.com/hoge.png"
item_title = "item title"
@@ -72,9 +69,18 @@ module RSS
rss_item.link = item_link
rss_item.about = item_link
+ h = {
+ 'title' => "fugafuga",
+ 'link' => "http://hoge.com",
+ 'description' => "fugafugafugafuga",
+ 'image' => image,
+ 'items' => items,
+ 'textinput' => textinput,
+ }
+
channel = RDF::Channel.new(about)
%w(title link description image items textinput).each do |x|
- channel.__send__("#{x}=", instance_eval(x))
+ channel.__send__("#{x}=", h[x])
end
doc = REXML::Document.new(make_RDF(<<-EOR))
@@ -96,7 +102,7 @@ EOR
assert_equal(@rdf_uri, res.namespace)
value = res.value
else
- excepted = instance_eval(x)
+ excepted = h[x]
value = elem.text
end
assert_equal(excepted, value)
@@ -199,13 +205,15 @@ EOR
def test_image
about = "http://hoge.com"
- title = "fugafuga"
- url = "http://hoge.com/hoge"
- link = "http://hoge.com/fuga"
+ h = {
+ 'title' => "fugafuga",
+ 'url' => "http://hoge.com/hoge",
+ 'link' => "http://hoge.com/fuga",
+ }
image = RDF::Image.new(about)
%w(title url link).each do |x|
- image.__send__("#{x}=", instance_eval(x))
+ image.__send__("#{x}=", h[x])
end
doc = REXML::Document.new(make_RDF(image.to_s))
@@ -216,19 +224,21 @@ EOR
elem = i.elements[x]
assert_equal(x, elem.name)
assert_equal(@uri, elem.namespace)
- assert_equal(instance_eval(x), elem.text)
+ assert_equal(h[x], elem.text)
end
end
def test_item
about = "http://hoge.com"
- title = "fugafuga"
- link = "http://hoge.com/fuga"
- description = "hogehogehoge"
+ h = {
+ 'title' => "fugafuga",
+ 'link' => "http://hoge.com/fuga",
+ 'description' => "hogehogehoge",
+ }
item = RDF::Item.new(about)
%w(title link description).each do |x|
- item.__send__("#{x}=", instance_eval(x))
+ item.__send__("#{x}=", h[x])
end
doc = REXML::Document.new(make_RDF(item.to_s))
@@ -239,20 +249,22 @@ EOR
elem = i.elements[x]
assert_equal(x, elem.name)
assert_equal(@uri, elem.namespace)
- assert_equal(instance_eval(x), elem.text)
+ assert_equal(h[x], elem.text)
end
end
def test_textinput
about = "http://hoge.com"
- title = "fugafuga"
- link = "http://hoge.com/fuga"
- name = "foo"
- description = "hogehogehoge"
+ h = {
+ 'title' => "fugafuga",
+ 'link' => "http://hoge.com/fuga",
+ 'name' => "foo",
+ 'description' => "hogehogehoge",
+ }
textinput = RDF::Textinput.new(about)
%w(title link name description).each do |x|
- textinput.__send__("#{x}=", instance_eval(x))
+ textinput.__send__("#{x}=", h[x])
end
doc = REXML::Document.new(make_RDF(textinput.to_s))
@@ -263,7 +275,7 @@ EOR
elem = t.elements[x]
assert_equal(x, elem.name)
assert_equal(@uri, elem.namespace)
- assert_equal(instance_eval(x), elem.text)
+ assert_equal(h[x], elem.text)
end
end
diff --git a/test/rss/test_2.0.rb b/test/rss/test_2.0.rb
index ed83ca6cf7..5695110e81 100644
--- a/test/rss/test_2.0.rb
+++ b/test/rss/test_2.0.rb
@@ -53,16 +53,22 @@ module RSS
end
def test_channel
- title = "fugafuga"
- link = "http://hoge.com"
- description = "fugafugafugafuga"
-
- language = "en-us"
- copyright = "Copyright 2002, Spartanburg Herald-Journal"
- managingEditor = "geo@herald.com (George Matesky)"
- webMaster = "betty@herald.com (Betty Guernsey)"
- pubDate = Time.parse("Sat, 07 Sep 2002 00:00:01 GMT")
- lastBuildDate = Time.parse("Sat, 07 Sep 2002 09:42:31 GMT")
+ h = {
+ 'title' => "fugafuga",
+ 'link' => "http://hoge.com",
+ 'description' => "fugafugafugafuga",
+
+ 'language' => "en-us",
+ 'copyright' => "Copyright 2002, Spartanburg Herald-Journal",
+ 'managingEditor' => "geo@herald.com (George Matesky)",
+ 'webMaster' => "betty@herald.com (Betty Guernsey)",
+ 'pubDate' => Time.parse("Sat, 07 Sep 2002 00:00:01 GMT"),
+ 'lastBuildDate' => Time.parse("Sat, 07 Sep 2002 09:42:31 GMT"),
+ 'generator' => "MightyInHouse Content System v2.3",
+ 'docs' => "http://blogs.law.harvard.edu/tech/rss",
+ 'ttl' => "60",
+ '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))',
+ }
categories = [
{
:content => "Newspapers",
@@ -72,12 +78,6 @@ module RSS
:content => "1765",
}
]
- generator = "MightyInHouse Content System v2.3"
- docs = "http://blogs.law.harvard.edu/tech/rss"
-
- ttl = "60"
-
- 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,7 @@ module RSS
managingEditor webMaster pubDate lastBuildDate
generator docs ttl rating)
elems.each do |x|
- value = instance_eval(x)
+ value = h[x]
value = value.rfc822 if %w(pubDate lastBuildDate).include?(x)
channel.__send__("#{x}=", value)
end
@@ -101,7 +101,7 @@ module RSS
elem = c.elements[x]
assert_equal(x, elem.name)
assert_equal("", elem.namespace)
- expected = instance_eval(x)
+ expected = h[x]
case x
when "pubDate", "lastBuildDate"
assert_equal(expected, Time.parse(elem.text))
@@ -236,10 +236,14 @@ module RSS
end
def test_item
- title = "fugafuga"
- link = "http://hoge.com/"
- description = "text hoge fuga"
- author = "oprah@oxygen.net"
+ h = {
+ 'title' => "fugafuga",
+ 'link' => "http://hoge.com/",
+ 'description' => "text hoge fuga",
+ 'author' => "oprah@oxygen.net",
+ 'comments' => "http://www.myblog.org/cgi-local/mt/mt-comments.cgi?entry_id=290",
+ 'pubDate' => Time.parse("Sat, 07 Sep 2002 00:00:01 GMT"),
+ }
categories = [
{
:content => "Newspapers",
@@ -249,8 +253,6 @@ module RSS
:content => "1765",
}
]
- comments = "http://www.myblog.org/cgi-local/mt/mt-comments.cgi?entry_id=290"
- pubDate = Time.parse("Sat, 07 Sep 2002 00:00:01 GMT")
channel = Rss::Channel.new
channel.title = "title"
@@ -262,7 +264,7 @@ module RSS
elems = %w(title link description author comments pubDate)
elems.each do |x|
- value = instance_eval(x)
+ value = h[x]
value = value.rfc822 if x == "pubDate"
item.__send__("#{x}=", value)
end
@@ -279,7 +281,7 @@ module RSS
elem = item_elem.elements[x]
assert_equal(x, elem.name)
assert_equal("", elem.namespace)
- expected = instance_eval(x)
+ expected = h[x]
case x
when "pubDate"
assert_equal(expected, Time.parse(elem.text))
diff --git a/test/rss/test_atom.rb b/test/rss/test_atom.rb
index 80da69bd94..e0ae108698 100644
--- a/test/rss/test_atom.rb
+++ b/test/rss/test_atom.rb
@@ -453,11 +453,13 @@ module RSS
def assert_atom_link_to_s(target_class)
_wrap_assertion do
href = "http://example.com/atom.xml"
- rel = "self"
- type = "application/atom+xml"
- hreflang = "ja"
- title = "Atom Feed"
- length = "801"
+ optvs = {
+ 'rel' => "self",
+ 'type' => "application/atom+xml",
+ 'hreflang' => "ja",
+ 'title' => "Atom Feed",
+ 'length' => "801",
+ }
link = target_class.new
assert_equal("", link.to_s)
@@ -472,24 +474,24 @@ module RSS
rest = optional_arguments.reject {|x| x == name}
link = target_class.new
- link.__send__("#{name}=", eval(name))
+ link.__send__("#{name}=", optvs[name])
assert_equal("", link.to_s)
rest.each do |n|
- link.__send__("#{n}=", eval(n))
+ link.__send__("#{n}=", optvs[n])
assert_equal("", link.to_s)
end
link = target_class.new
link.href = href
- link.__send__("#{name}=", eval(name))
- attrs = [["href", href], [name, eval(name)]]
+ link.__send__("#{name}=", optvs[name])
+ attrs = [["href", href], [name, optvs[name]]]
xml = REXML::Document.new(link.to_s).root
assert_rexml_element([], attrs, nil, xml)
rest.each do |n|
- link.__send__("#{n}=", eval(n))
- attrs << [n, eval(n)]
+ link.__send__("#{n}=", optvs[n])
+ attrs << [n, optvs[n]]
xml = REXML::Document.new(link.to_s).root
assert_rexml_element([], attrs, nil, xml)
end
diff --git a/test/rss/test_maker_2.0.rb b/test/rss/test_maker_2.0.rb
index 705270df4e..530c3cc85f 100644
--- a/test/rss/test_maker_2.0.rb
+++ b/test/rss/test_maker_2.0.rb
@@ -445,7 +445,7 @@ module RSS
def test_pubDate_without_description
title = "TITLE"
link = "http://hoge.com/"
- description = "text hoge fuga"
+ # description = "text hoge fuga"
author = "oprah@oxygen.net"
pubDate = Time.now
@@ -529,13 +529,13 @@ module RSS
end
def test_not_valid_guid
- content = "http://inessential.com/2002/09/01.php#a2"
+ # content = "http://inessential.com/2002/09/01.php#a2"
rss = RSS::Maker.make("2.0") do |maker|
setup_dummy_channel(maker)
setup_dummy_item(maker)
- guid = maker.items.last.guid
+ # guid = maker.items.last.guid
# guid.content = content
end
assert_nil(rss.channel.items.last.guid)
@@ -662,7 +662,7 @@ module RSS
end
def test_not_valid_category
- content = "Grateful Dead"
+ # content = "Grateful Dead"
rss = RSS::Maker.make("2.0") do |maker|
setup_dummy_channel(maker)