Sha256: 2833d473828a3d80513b5469c6889ec19965d92eff82bc6d20d6073aab91e283

Contents?: true

Size: 1.45 KB

Versions: 7

Compression:

Stored size: 1.45 KB

Contents

#
# testing ruote
#
# Mon Sep 14 19:31:37 JST 2009
#

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

require 'ruote/participant'
require 'ruote/part/template'


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

  class MyParticipant
    include Ruote::LocalParticipant
    include Ruote::TemplateMixin

    def initialize (opts={}, &block)

      @block_template = block
      @template = opts[:template]
    end

    def consume (workitem)

      @context['s_tracer'] << render_template(
        Ruote::Exp::FlowExpression.fetch(@context, workitem.fei.to_h), workitem)
      @context['s_tracer'] << "\n"

      reply_to_engine(workitem)
    end

    def cancel (fei, flavour)
    end
  end

  def test_template

    pdef = Ruote.process_definition :name => 'def0' do
      set 'v:var0' => 'v_value'
      set 'f:field0' => 'f_value'
      alpha
      echo 'done.'
    end

    #noisy

    @engine.register_participant(
      :alpha,
      MyParticipant.new(:template => "0:${v:var0}\n1:${f:field0}"))

    assert_trace pdef, %w[ 0:v_value 1:f_value done. ]
  end

  def test_block_template

    pdef = Ruote.process_definition :name => 'def0' do
      set 'v:var0' => 'v_value'
      set 'f:field0' => 'f_value'
      alpha
      echo 'done.'
    end

    #noisy

    @engine.register_participant(
      :alpha,
      MyParticipant.new {
        "0:${v:var0}\n1:${f:field0}"
      })

    assert_trace pdef, %w[ 0:v_value 1:f_value done. ]
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruote-2.1.7 test/functional/ft_29_part_template.rb
ruote-2.1.6 test/functional/ft_29_part_template.rb
ruote-2.1.5 test/functional/ft_29_part_template.rb
ruote-2.1.4 test/functional/ft_29_part_template.rb
ruote-2.1.3 test/functional/ft_29_part_template.rb
ruote-2.1.2 test/functional/ft_29_part_template.rb
ruote-2.1.1 test/functional/ft_29_part_template.rb