Methods
Public Instance methods
[ show source ]
# File test/quoting_test.rb, line 9
9: def test_quote_multibyte_chars
10: original = "\303\246 \303\270 and \303\245"
11:
12: result = execute_in_sandbox("$:.unshift(File.dirname(__FILE__) + \"/../lib/\")\n$KCODE = 'u'\nrequire 'jcode'\nrequire 'action_mailer/quoting'\ninclude ActionMailer::Quoting\nquoted_printable(\#{original.inspect}, \"UTF-8\")\n")
13:
14: unquoted = TMail::Unquoter.unquote_and_convert_to(result, nil)
15: assert_equal unquoted, original
16: end
Private Instance methods
This whole thing could be much simpler, but I don’t think Tempfile, popen and others exist on all platforms (like Windows).
[ show source ]
# File test/quoting_test.rb, line 30
30: def execute_in_sandbox(code)
31: test_name = "#{File.dirname(__FILE__)}/am-quoting-test.#{$$}.rb"
32: res_name = "#{File.dirname(__FILE__)}/am-quoting-test.#{$$}.out"
33:
34: File.open(test_name, "w+") do |file|
35: file.write("block = Proc.new do\n\#{code}\nend\nputs block.call\n")
36: end
37:
38: system("ruby #{test_name} > #{res_name}") or raise "could not run test in sandbox"
39: File.read(res_name)
40: ensure
41: File.delete(test_name) rescue nil
42: File.delete(res_name) rescue nil
43: end