maketests.rb
# TODO(raggi): add tests that exercise the FormData API.
add tests that exercise the FormData API.
add tests that exercise the FormData API .
def render(testname, page_charset, form_charset, fields)
  open("tests/#{testname}.html", "w") do |io|
    if page_charset && encoding = Encoding.find(page_charset)
      io.set_encoding(encoding) if encoding
      begin
        fields.each { |f| f.encode(encoding) }
      rescue Encoding::UndefinedConversionError
        $stderr.puts "Cannot encode fields for #{testname} in #{encoding}"
        next
      end
    end
    etestname = page_charset ? testname.encode(page_charset, :xml => :text) : testname
    quote = testname.include?('"') ? "'" : '"'
    io.write <<-HTML
<!doctype html>
<html>
<head>
<title>#{etestname}</title>
#{"<meta charset='#{page_charset}'>" if page_charset}
</head>
<body>
<form action=#{quote}/dump/#{etestname}#{quote} method=POST enctype="multipart/form-data" #{"accept-charset='#{form_charset}'" if form_charset}>
  #{fields.join("\n  ")}
  <input type="submit">
</form>
</body>
</html>
    HTML
  end
end
def render ( testname , page_charset , form_charset , fields ) open ( "tests/#{testname}.html" , "w" ) do | io | if page_charset && encoding = Encoding . find ( page_charset ) io . set_encoding ( encoding ) if encoding begin fields . each { | f | f . encode ( encoding ) } rescue Encoding :: UndefinedConversionError $stderr . puts "Cannot encode fields for #{testname} in #{encoding}" next end end etestname = page_charset ? testname . encode ( page_charset , :xml => :text ) : testname quote = testname . include? ( '"' ) ? "'" : '"' io . write <<-HTML 
<!doctype html>
<html>
<head>
<title> #{ etestname } </title>
 #{ "<meta charset='#{page_charset}'>" if page_charset } 
</head>
<body>
<form action= #{ quote } /dump/ #{ etestname } #{ quote }  method=POST enctype="multipart/form-data"  #{ "accept-charset='#{form_charset}'" if form_charset } >
   #{ fields . join ( "\n  " ) } 
  <input type="submit">
</form>
</body>
</html>
     HTML end end
TODO(raggi): add tests that exercise the FormData API.
TODO ( raggi ) : add tests that exercise the FormData API .
testname
page_charset
form_charset
fields