0
# This is based off of Sam Ruby's xml_filetest.rb
0
# I've adapted it for rfeedparser
0
# http://intertwingly.net/blog/2005/10/30/Testing-FeedTools-Dynamically/
0
require File.join(File.dirname(__FILE__),'rfeedparser_test_helper')
0
-# default methods to be public
0
-# add one unit test for each file
0
-Dir["#{File.dirname(__FILE__)}/**/*.xml"].each do |xmlfile|
0
- methname = "tests_"+xmlfile.gsub('./', '').gsub('/','_').sub('.xml','')
0
- XMLTests.send(:define_method, methname) {
0
- options[:compatible] = true
0
- # This keeps compatibility with 4.1 feedparser tests (i.e. no
0
- # smart stripping of styles). This is not (yet) required, as
0
- # rfeedparser is compatible by default.
0
+class XMLTests < Test::Unit::TestCase
0
+ # Some tests are known to fail because we're copying the Python
0
+ # version's feed suite verbatim, and we have minor implementation
0
+ # details that don't constitute brokenness but are still
0
+ # different. By default we should skip them to reduce line noise. If
0
+ # you want to leave them in, use `rake test all=yes'
0
+ # Additionally if you want to run a single test, run:
0
+ # rake test n=test_tests_wellformed_encoding_x80macroman
0
+ return false if ENV['all']
0
+ return ENV['n'] != name if ENV['n']
0
+ @to_skip ||= YAML.load(File.open(File.dirname(__FILE__) + '/to_skip.yml'))
0
+ @to_skip.include? name
0
+ Dir["#{File.dirname(__FILE__)}/**/*.xml"].each do |xmlfile|
0
+ name = "test_#{xmlfile.gsub('./', '').gsub('/','_').sub('.xml','')}"
0
- fp = FeedParser.parse("http://127.0.0.1:#{$PORT}/#{xmlfile}", options)
0
- # I should point out that the 'compatible' arg is not necessary,
0
- # but probably will be in the future if we decide to change the default.
0
+ XMLTests.send(:define_method, name) do
0
+ fp = FeedParser.parse("http://127.0.0.1:#{$PORT}/#{xmlfile}", :compatible => true)
0
+ # I should point out that the 'compatible' arg is not necessary,
0
+ # but probably will be in the future if we decide to change the default.
0
- description, evalString = scrape_assertion_strings(xmlfile)
0
- assert fp.instance_eval(evalString), description.inspect
0
+ description, evalString = scrape_assertion_strings(xmlfile)
0
+ assert fp.instance_eval(evalString), description
0
# Start up the mongrel server and tell it how to send the tests
0
server = Mongrel::HttpServer.new("0.0.0.0",$PORT)
0
Mongrel::DirHandler::add_mime_type('.xml','application/xml')
Comments
No one has commented yet.