class Hurley::FilePartTest
Public Instance Methods
test_build_with_content_disposition()
click to toggle source
# File test/multipart_test.rb, line 165 def test_build_with_content_disposition src = IO.read(__FILE__) io = UploadIO.new(__FILE__, "text/plain") part = Multipart::Part.new("boundary", "foo", io, :content_disposition => "attachment") expected = %Q(--boundary\r\n) + %Q(Content-Disposition: attachment; name="foo"; filename="multipart_test.rb"\r\n) + %Q(Content-Length: #{src.size}\r\n) + %Q(Content-Type: text/plain\r\n) + %Q(Content-Transfer-Encoding: binary\r\n) + %Q(\r\n#{src}\r\n) assert_equal expected.size, part.length assert_equal expected, part.to_io.read end
test_build_with_content_id()
click to toggle source
# File test/multipart_test.rb, line 201 def test_build_with_content_id src = IO.read(__FILE__) io = UploadIO.new(__FILE__, "text/plain") part = Multipart::Part.new("boundary", "foo", io, :content_id => "abc123") expected = %Q(--boundary\r\n) + %Q(Content-Disposition: form-data; name="foo"; filename="multipart_test.rb"\r\n) + %Q(Content-Length: #{src.size}\r\n) + %Q(Content-ID: abc123\r\n) + %Q(Content-Type: text/plain\r\n) + %Q(Content-Transfer-Encoding: binary\r\n) + %Q(\r\n#{src}\r\n) assert_equal expected.size, part.length assert_equal expected, part.to_io.read end
test_build_with_content_transfer_encoding()
click to toggle source
# File test/multipart_test.rb, line 183 def test_build_with_content_transfer_encoding src = IO.read(__FILE__) io = UploadIO.new(__FILE__, "text/plain") part = Multipart::Part.new("boundary", "foo", io, :content_transfer_encoding => "rofl") expected = %Q(--boundary\r\n) + %Q(Content-Disposition: form-data; name="foo"; filename="multipart_test.rb"\r\n) + %Q(Content-Length: #{src.size}\r\n) + %Q(Content-Type: text/plain\r\n) + %Q(Content-Transfer-Encoding: rofl\r\n) + %Q(\r\n#{src}\r\n) assert_equal expected.size, part.length assert_equal expected, part.to_io.read end
test_build_with_content_type()
click to toggle source
# File test/multipart_test.rb, line 147 def test_build_with_content_type src = IO.read(__FILE__) io = UploadIO.new(__FILE__, "text/plain") part = Multipart::Part.new("boundary", "foo", io, :content_type => "text/ruby") expected = %Q(--boundary\r\n) + %Q(Content-Disposition: form-data; name="foo"; filename="multipart_test.rb"\r\n) + %Q(Content-Length: #{src.size}\r\n) + %Q(Content-Type: text/ruby\r\n) + %Q(Content-Transfer-Encoding: binary\r\n) + %Q(\r\n#{src}\r\n) assert_equal expected.size, part.length assert_equal expected, part.to_io.read end
test_build_without_options()
click to toggle source
# File test/multipart_test.rb, line 130 def test_build_without_options src = IO.read(__FILE__) io = UploadIO.new(__FILE__, "text/plain") part = Multipart::Part.new("boundary", "foo", io, {}) expected = %Q(--boundary\r\n) + %Q(Content-Disposition: form-data; name="foo"; filename="multipart_test.rb"\r\n) + %Q(Content-Length: #{src.size}\r\n) + %Q(Content-Type: text/plain\r\n) + %Q(Content-Transfer-Encoding: binary\r\n) + %Q(\r\n#{src}\r\n) assert_equal expected.size, part.length assert_equal expected, part.to_io.read end