Sha256: 6ef9e5483538988661683267299e7d80ea2499d08a80355b11ec704b1e69f35f

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require_relative '../test_helper'

class Mail::PartTest < MiniTest::Unit::TestCase
  def test_responds_to_to_postmark
    assert_respond_to Mail::Part.new, :to_postmark
  end


  def test_to_postmark_text_part
    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 = Mail::Part.new
    part.body = content
    part.content_type = 'text/plain'

    assert_equal Hash['Name' => nil, 'Content' => content, 'ContentType' => 'text/plain'], part.to_postmark
  end


  def test_to_postmark_mail_part
    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 = Mail::Part.new
    part.body = content
    part.content_type = 'text/html'

    assert_equal Hash['Name' => nil, 'Content' => content, 'ContentType' => 'text/html'], part.to_postmark
  end


  def test_to_postmark_file_part
    part = Mail::Part.new
    part.add_file BROCODE
    attachment = part.attachments.first

    assert_equal Hash['Name' => 'thebrocode.jpg', 'Content' => [File.read(BROCODE)].pack('m'), 'ContentType' => 'image/jpeg'], attachment.to_postmark
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_postmark-0.7.0 test/mail/part_test.rb