Sha256: 06907ffdd234a961775eb9a9e116c7cd13fb46a5d511bcc267646f9da4408148
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
require_relative "spec_helper" module Nyara describe Part do it "bottom case" do p = Part.new({}) p.final assert_equal '', p['data'] end it "parses base64" do p = Part.new\ 'Content-Type' => 'image/jpeg; bla bla', 'Content-Disposition' => "inline; fiLename *= gbk'zh-CN'%C8%CB%B2%CE.jpg; namE= \"file\"", 'Content-Transfer-Encoding' => 'base64' # total length a multiple to 8 data = [ "fNfaX7SRKfEfXMcYmHT/AHRXw94r0", 'G', 'xXxTqQFlaAC6l/5Yr/AHz7V6nAtam414yhf3', 'jhzqEoODUt0f/Z' ] data.each do |datum| p.update datum.dup end p.final assert_equal 'base64', p['mechanism'] assert_equal 'image/jpeg', p['type'] assert_equal '人参.jpg', p['filename'] assert_equal 'file', p['name'] assert_equal data.join, Base64.strict_encode64(p['data']) end it "parses 7bit data" do p = Part.new\ 'Content-Transfer-Encoding' => '7bit' p.update 'foo bar' assert_equal 'foo bar', p['data'] end it "parses QP data" do p = Part.new\ 'Content-Transfer-Encoding' => 'quoted-PrintaBle' p.update "a =3F =" p.update "04" p.final assert_equal "a \x3F \x04", p['data'] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nyara-0.0.1.pre.8 | spec/part_spec.rb |
nyara-0.0.1.pre.6 | spec/part_spec.rb |