public
Description: Koz's rails git-svn clone
Homepage: http://www.rubyonrails.org
Clone URL: git://github.com/NZKoz/koz-rails.git
Ruby 1.9 compat: compare with same encoding


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9218 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
bitsweat (author)
Thu Apr 03 10:28:05 -0700 2008
commit  140f828ddc83ef154f437c526683baa0e9bfcb5a
tree    58ef741cfe97d5512b08b40feee259d2897a7006
parent  a9ba9947ffcec594d4ff19e7a7f6481f98fe581b
...
840
841
842
843
 
 
 
 
 
844
845
846
...
840
841
842
 
843
844
845
846
847
848
849
850
0
@@ -840,7 +840,11 @@ EOF
0
     fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email8")
0
     mail = TMail::Mail.parse(fixture)
0
     attachment = mail.attachments.last
0
- assert_equal "01 Quien Te Dij\212at. Pitbull.mp3", attachment.original_filename
0
+
0
+ expected = "01 Quien Te Dij\212at. Pitbull.mp3"
0
+ expected.force_encoding(Encoding::ASCII_8BIT) if expected.respond_to?(:force_encoding)
0
+
0
+ assert_equal expected, attachment.original_filename
0
   end
0
 
0
   def test_wrong_mail_header
...
73
74
75
76
77
78
79
 
 
 
80
81
82
83
 
 
84
85
86
87
88
89
90
...
107
108
109
110
111
 
 
 
 
 
 
 
 
112
113
...
73
74
75
 
 
 
 
76
77
78
79
 
 
 
80
81
82
83
84
 
85
86
87
...
104
105
106
 
 
107
108
109
110
111
112
113
114
115
116
0
@@ -73,18 +73,15 @@ class QuotingTest < Test::Unit::TestCase
0
     assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject
0
   end
0
 
0
- def test_decode
0
- encoded, decoded = expected_base64_strings
0
- assert_equal decoded, TMail::Base64.decode(encoded)
0
- end
0
+ def test_base64_encoding
0
+ encoded = read_fixture('raw_base64_encoded_string')
0
+ decoded = read_fixture('raw_base64_decoded_string')
0
 
0
- def test_encode
0
- encoded, decoded = expected_base64_strings
0
- assert_equal encoded.length, TMail::Base64.encode(decoded).length
0
+ assert_equal encoded, TMail::Base64.encode(decoded)
0
+ assert_equal decoded, TMail::Base64.decode(encoded)
0
   end
0
 
0
   private
0
-
0
     # This whole thing *could* be much simpler, but I don't think Tempfile,
0
     # popen and others exist on all platforms (like Windows).
0
     def execute_in_sandbox(code)
0
@@ -107,7 +104,13 @@ class QuotingTest < Test::Unit::TestCase
0
       File.delete(res_name) rescue nil
0
     end
0
 
0
- def expected_base64_strings
0
- [ File.read("#{File.dirname(__FILE__)}/fixtures/raw_base64_encoded_string"), File.read("#{File.dirname(__FILE__)}/fixtures/raw_base64_decoded_string") ]
0
+ if RUBY_VERSION >= '1.9'
0
+ def read_fixture(name)
0
+ File.open("#{File.dirname(__FILE__)}/fixtures/raw_base64_encoded_string", 'r:ascii-8bit') { |f| f.read }
0
+ end
0
+ else
0
+ def read_fixture(name)
0
+ File.read("#{File.dirname(__FILE__)}/fixtures/raw_base64_encoded_string")
0
+ end
0
     end
0
 end

Comments

    No one has commented yet.