@@ -227,20 +227,24 @@ def test_encoding_length
227
227
228
228
def test_file_encode
229
229
file = Pathname ( __FILE__ )
230
+ fileinput = Orb ::Internal ::Type ::Converter . dump ( Orb ::Internal ::Type ::FileInput , "abc" )
230
231
headers = { "content-type" => "multipart/form-data" }
231
232
cases = {
232
- "abc" => " abc",
233
- StringIO . new ( "abc" ) => " abc",
234
- Orb :: FilePart . new ( "abc" ) => " abc" ,
235
- Orb ::FilePart . new ( StringIO . new ( "abc" ) ) => " abc",
236
- file => /^class Orb/ ,
237
- Orb ::FilePart . new ( file ) => /^class Orb/
233
+ "abc" => [ "" , " abc"] ,
234
+ StringIO . new ( "abc" ) => [ "" , " abc"] ,
235
+ fileinput => %w[ upload abc ] ,
236
+ Orb ::FilePart . new ( StringIO . new ( "abc" ) ) => [ "" , " abc"] ,
237
+ file => [ file . basename . to_path , /^class Orb/ ] ,
238
+ Orb ::FilePart . new ( file , filename : "d o g" ) => [ "d%20o%20g" , /^class Orb/ ]
238
239
}
239
- cases . each do |body , val |
240
+ cases . each do |body , testcase |
241
+ filename , val = testcase
240
242
encoded = Orb ::Internal ::Util . encode_content ( headers , body )
241
243
cgi = FakeCGI . new ( *encoded )
244
+ io = cgi [ "" ]
242
245
assert_pattern do
243
- cgi [ "" ] . read => ^val
246
+ io . original_filename => ^filename
247
+ io . read => ^val
244
248
end
245
249
end
246
250
end
@@ -261,7 +265,14 @@ def test_hash_encode
261
265
cgi = FakeCGI . new ( *encoded )
262
266
testcase . each do |key , val |
263
267
assert_pattern do
264
- cgi [ key ] => ^val
268
+ parsed =
269
+ case ( p = cgi [ key ] )
270
+ in StringIO
271
+ p . read
272
+ else
273
+ p
274
+ end
275
+ parsed => ^val
265
276
end
266
277
end
267
278
end
0 commit comments