instiki/vendor/RedCloth-3.0.3/run-tests.rb

27 lines
730 B
Ruby
Raw Permalink Normal View History

2005-01-15 20:26:54 +00:00
#!/usr/bin/env ruby
2005-02-10 23:11:47 +00:00
require 'lib/redcloth'
2005-01-15 20:26:54 +00:00
require 'yaml'
Dir["tests/*.yml"].each do |testfile|
YAML::load_documents( File.open( testfile ) ) do |doc|
if doc['in'] and doc['out']
2005-02-10 23:11:47 +00:00
red = RedCloth.new( doc['in'] )
html = if testfile =~ /markdown/
red.to_html( :markdown )
else
red.to_html
end
2005-01-15 20:26:54 +00:00
puts "---"
2005-02-10 23:11:47 +00:00
html.gsub!( /\n+/, "\n" )
doc['out'].gsub!( /\n+/, "\n" )
2005-01-15 20:26:54 +00:00
if html == doc['out']
puts "success: true"
else
puts "out: "; p html
puts "expected: "; p doc['out']
end
end
end
end