Sha256: fd622ff3bec0a77cfb6ed87f8fb564d691b7b1d00c32ce2ce3266b4ff5c763b5
Contents?: true
Size: 1.53 KB
Versions: 9
Compression:
Stored size: 1.53 KB
Contents
#!/usr/bin/ruby -w $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') require 'test/unit' require 'feedparser' class TextWrappedOutputTest < Test::Unit::TestCase if File::directory?('test/source') SRCDIR = 'test/source' DSTDIR = 'test/textwrapped_output' elsif File::directory?('source') SRCDIR = 'source' DSTDIR = 'textwrapped_output' else raise 'source directory not found.' end Dir.foreach(SRCDIR) do |f| next if f !~ /.xml$/ testname = 'test_' + File.basename(f).gsub(/\W/, '_') define_method(testname) do str = File::read(SRCDIR + '/' + f) chan = FeedParser::Feed::new(str) chanstr = chan.to_text(false, 72) # localtime set to false if File::exist?(DSTDIR + '/' + f.gsub(/.xml$/, '.output')) output = File::read(DSTDIR + '/' + f.gsub(/.xml$/, '.output')) if output != chanstr File::open(DSTDIR + '/' + f.gsub(/.xml$/, '.output.new'), "w") do |fd| fd.print(chanstr) end assert( false, [ "Test failed for #{f}.", " Check: diff -u #{DSTDIR + '/' + f.gsub(/.xml$/, '.output')}{,.new}", " Commit: mv -f #{DSTDIR + '/' + f.gsub(/.xml$/, '.output')}{.new,}", ].join("\n") ) end else File::open(DSTDIR + '/' + f.gsub(/.xml$/, '.output'), "w") do |f| f.print(chanstr) end assert(false, "Missing #{DSTDIR + '/' + f.gsub(/.xml$/, '.output')}. Writing it, but check manually!") end end end end
Version data entries
9 entries across 9 versions & 1 rubygems