multipart-post 1.1.5 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,57 +0,0 @@
1
- #--
2
- # Copyright (c) 2007-2012 Nick Sieger.
3
- # See the file README.txt included with the distribution for
4
- # software license details.
5
- #++
6
-
7
- require 'test/unit'
8
-
9
- require 'parts'
10
- require 'stringio'
11
- require 'composite_io'
12
-
13
-
14
- MULTIBYTE = File.dirname(__FILE__)+'/multibyte.txt'
15
- TEMP_FILE = "temp.txt"
16
-
17
- module AssertPartLength
18
- def assert_part_length(part)
19
- bytes = part.to_io.read
20
- bytesize = bytes.respond_to?(:bytesize) ? bytes.bytesize : bytes.length
21
- assert_equal bytesize, part.length
22
- end
23
- end
24
-
25
- class FilePartTest < Test::Unit::TestCase
26
- include AssertPartLength
27
-
28
- def setup
29
- File.open(TEMP_FILE, "w") {|f| f << "1234567890"}
30
- io = UploadIO.new(TEMP_FILE, "text/plain")
31
- @part = Parts::FilePart.new("boundary", "afile", io)
32
- end
33
-
34
- def teardown
35
- File.delete(TEMP_FILE) rescue nil
36
- end
37
-
38
- def test_correct_length
39
- assert_part_length @part
40
- end
41
-
42
- def test_multibyte_file_length
43
- assert_part_length Parts::FilePart.new("boundary", "multibyte", UploadIO.new(MULTIBYTE, "text/plain"))
44
- end
45
- end
46
-
47
- class ParamPartTest < Test::Unit::TestCase
48
- include AssertPartLength
49
-
50
- def setup
51
- @part = Parts::ParamPart.new("boundary", "multibyte", File.read(MULTIBYTE))
52
- end
53
-
54
- def test_correct_length
55
- assert_part_length @part
56
- end
57
- end