Sha256: 26d2cc9f091640cd95582fb3582dd00b9e4e751e6ffb34d7f37bcfad2e367c92

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require File.dirname(__FILE__) + "/test_helper"
require 'test/unit'
require 'rubygems'
require 'mms2r'
require 'mms2r/media'
require 'tmail/mail'
require 'logger'

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

  def test_create_should_return_orange_france
    mail = TMail::Mail.parse(load_mail('orangefrance-text-and-image.mail').join)
    mms = MMS2R::Media.create(mail)
    assert_equal MMS2R::OrangeFranceMedia, mms.class, "expected a #{MMS2R::OrangeFranceMedia} and received a #{mms.class}"
  end

  def test_empty_subject
    mail = TMail::Mail.parse(load_mail('orangefrance-text-and-image.mail').join)
    mms = MMS2R::Media.create(mail)
    mms.process
    assert_nil mms.get_subject
  end

  def test_processed_content
    mail = TMail::Mail.parse(load_mail('orangefrance-text-and-image.mail').join)
    mms = MMS2R::Media.create(mail)
    mms.process

    # there should be one text and one image
    assert_equal 2, mms.media.size

    #text
    # there is a text banner that Orange attaches but
    # that should be ignored
    assert_not_nil mms.media['text/plain'] 
    assert_equal 1, mms.media['text/plain'].size
    file = mms.media['text/plain'].first
    assert File::exist?(file), "file #{file} does not exist"
    text = IO.readlines("#{file}").join
    assert_match /Test ma poule/, text

    # image
    assert_not_nil mms.media['image/jpeg'] 
    assert_equal 1, mms.media['image/jpeg'].size
    assert_match /IMAGE.jpeg$/, mms.media['image/jpeg'].first
    assert_file_size mms.media['image/jpeg'].first, 337

    mms.purge
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mms2r-1.1.10 test/test_mms2r_orange_france_media.rb
mms2r-1.1.8 test/test_mms2r_orange_france_media.rb
mms2r-1.1.9 test/test_mms2r_orange_france_media.rb