Sha256: fd5bbab71e5cf23f138ca69211fd64a9927091d2a9c3a948496fcb610c2fef12

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

#
# testing ruote
#
# Tue Sep 15 09:04:36 JST 2009
#

require File.join(File.dirname(__FILE__), 'base')

require 'ruote/part/smtp_participant'


class NftSmtpParticipantTest < Test::Unit::TestCase
  include FunctionalBase

  if RUBY_PLATFORM != 'java'

    require 'mailtrap' # sudo gem install mailtrap

    class Trap < ::Mailtrap
      def puts (s)
        # silent night...
      end
    end
  end

  def test_smtp

    return if RUBY_PLATFORM == 'java'

    pdef = Ruote.process_definition :name => 'test' do
      sequence do
        set 'f:item' => 'cat food'
        alpha
      end
    end

    trapfile = Ruote::WIN ? 'ruote_mailtrap.txt' : '/tmp/ruote_mailtrap.txt'
    FileUtils.rm_f(trapfile)

    Thread.new do
      Trap.new('127.0.0.1', 2525, true, trapfile)
    end
    sleep 0.040
      # give it some time to start listening

    @engine.register_participant(
      :alpha,
      Ruote::SmtpParticipant.new(
        :server => '127.0.0.1',
        :port => 2525,
        :to => 'toto@cloudwhatever.ch',
        :from => 'john@outoftheblue.ch',
        :notification => true,
        :template => %{
  Hello, do you want ${f:item} ?
        }))

    #noisy

    wfid = @engine.launch(pdef)

    sleep 0.450

    assert_match(/cat food/, File.read(trapfile))
    assert_nil @engine.process(wfid)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruote-2.1.7 test/functional/ft_30_smtp_participant.rb