Sha256: ab8861a02107d23776721dc7a6c9058678e29d18b99dac15ff11d9c0737ad1dc

Contents?: true

Size: 1.83 KB

Versions: 8

Compression:

Stored size: 1.83 KB

Contents

require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
require File.join(File.dirname(__FILE__), "test_helper")
require 'test/unit'
require 'rubygems'
require 'mocha'
gem 'tmail', '>= 1.2.1'
require 'tmail'

class TestMmsMyhelioCom < Test::Unit::TestCase
  include MMS2R::TestHelper

  def test_only_valid_content_should_be_retained_for_mms_with_image_and_text
    mail = TMail::Mail.parse(load_mail('helio-image-01.mail').join)
    mms = MMS2R::Media.new(mail)
    assert_equal 2, mms.media.size
    assert_equal 1, mms.media['image/jpeg'].size
    assert_equal 1, mms.media['text/plain'].size
  end

  def test_only_valid_content_should_be_retained_for_mms_with_text
    mail = TMail::Mail.parse(load_mail('helio-message-01.mail').join)
    mms = MMS2R::Media.new(mail)
    assert_equal 1, mms.media.size
    assert_equal 1, mms.media['text/plain'].size
  end

  def test_number_should_return_correct_number
    mail = TMail::Mail.parse(load_mail('helio-image-01.mail').join)
    mms = MMS2R::Media.new(mail)
    number = mms.number()
    assert_equal number, 5551234.to_s
    mms.purge
  end

  def test_subject_should_return_correct_subject
    mail = TMail::Mail.parse(load_mail('helio-image-01.mail').join)
    mms = MMS2R::Media.new(mail)
    title = mms.subject()
    assert_equal title, "Test image"
    mms.purge
  end

  def test_body_should_return_correct_body
    mail = TMail::Mail.parse(load_mail('helio-image-01.mail').join)
    mms = MMS2R::Media.new(mail)
    body = mms.body()
    assert_equal body, "Test image"
    mms.purge
  end

  def test_attachment_should_return_jpeg
    mail = TMail::Mail.parse(load_mail('helio-image-01.mail').join)
    mms = MMS2R::Media.new(mail)
    image = mms.default_media()
    assert_not_nil mms.media['image/jpeg'][0]
    assert_match(/0628070005.jpg$/, mms.media['image/jpeg'][0])
    mms.purge
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mms2r-2.0.0 test/test_mms_myhelio_com.rb
mms2r-2.0.1 test/test_mms_myhelio_com.rb
mms2r-2.0.2 test/test_mms_myhelio_com.rb
mms2r-2.0.3 test/test_mms_myhelio_com.rb
mms2r-2.0.4 test/test_mms_myhelio_com.rb
mms2r-2.0.5 test/test_mms_myhelio_com.rb
mms2r-2.1.0 test/test_mms_myhelio_com.rb
mms2r-2.1.1 test/test_mms_myhelio_com.rb