Methods
Public Instance methods
test_email_quoted_with_0d0a()

test an email that has been created using \r\n newlines, instead of \n newlines.

    # File test/quoting_test.rb, line 25
25:   def test_email_quoted_with_0d0a
26:     mail = TMail::Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_quoted_with_0d0a"))
27:     assert_match %r{Elapsed time}, mail.body
28:   end
test_email_with_partially_quoted_subject()
    # File test/quoting_test.rb, line 30
30:   def test_email_with_partially_quoted_subject
31:     mail = TMail::Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_partially_quoted_subject"))
32:     assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject
33:   end
test_quote_multibyte_chars()
    # File test/quoting_test.rb, line 6
 6:   def test_quote_multibyte_chars
 7:     original = "\303\246 \303\270 and \303\245"
 8: 
 9:     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")
10: 
11:     unquoted = TMail::Unquoter.unquote_and_convert_to(result, nil)
12:     assert_equal unquoted, original
13:   end
Private Instance methods
execute_in_sandbox(code)

This whole thing could be much simpler, but I don’t think Tempfile, popen and others exist on all platforms (like Windows).

    # File test/quoting_test.rb, line 39
39:     def execute_in_sandbox(code)
40:       test_name = "#{File.dirname(__FILE__)}/am-quoting-test.#{$$}.rb"
41:       res_name = "#{File.dirname(__FILE__)}/am-quoting-test.#{$$}.out"
42: 
43:       File.open(test_name, "w+") do |file|
44:         file.write("block = Proc.new do\n\#{code}\nend\nputs block.call\n")
45:       end
46: 
47:       system("ruby #{test_name} > #{res_name}") or raise "could not run test in sandbox"
48:       File.read(res_name).chomp
49:     ensure
50:       File.delete(test_name) rescue nil
51:       File.delete(res_name) rescue nil
52:     end