Sha256: 9ea064931bcef6931ce61f12f31e121e0cf12c84cdda31bcd49ed5d908b4d385
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
require File.expand_path('../../spec_helper', __FILE__) describe Mail::Part do it 'responds to +to_postmark+' do Mail::Part.new.must_respond_to(:to_postmark) end describe :to_postmark do it 'returns body hash if part is not an attachment' do part = Mail::Part.new do body "Think of me like Yoda, but instead of being little and green I wear suits and I'm awesome. I'm your bro-I'm Broda!" content_type 'text/plain' end content = "Think of me like Yoda, but instead of being little and green I wear suits and I'm awesome. I'm your bro-I'm Broda!" part.to_postmark.must_equal('Name' => nil, 'Content' => content, 'ContentType' => 'text/plain') end it 'returns body hash if part is not an attachment' do part = Mail::Part.new do body "<p>Think of me like Yoda, but instead of being little and green I wear suits and I'm awesome.<br /><br />I'm your bro-I'm Broda!</p>" content_type 'text/html' end content = "<p>Think of me like Yoda, but instead of being little and green I wear suits and I'm awesome.<br /><br />I'm your bro-I'm Broda!</p>" part.to_postmark.must_equal('Name' => nil, 'Content' => content, 'ContentType' => 'text/html') end it 'returns base64-encoded file-content hash if part is an attachment' do file = File.join(File.dirname(__FILE__), '..', 'thebrocode.jpg') part = Mail::Part.new.tap do |mail| mail.add_file(file) end.attachments.first content = [File.read(file)].pack('m') part.to_postmark.must_equal('Name' => 'thebrocode.jpg', 'Content' => content, 'ContentType' => 'image/jpeg') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple_postmark-0.4.3 | spec/mail_ext/part_spec.rb |
simple_postmark-0.4.2 | spec/mail_ext/part_spec.rb |