test/functional/ft_41_participants.rb in ruote-2.1.11 vs test/functional/ft_41_participants.rb in ruote-2.2.0

- old
+ new

@@ -8,27 +8,27 @@ require File.join(File.dirname(__FILE__), 'base') require 'ruote/part/local_participant' -class FtMiscParticipantTest < Test::Unit::TestCase +class FtParticipantsTest < Test::Unit::TestCase include FunctionalBase class MyParticipant include Ruote::LocalParticipant - def consume (workitem) + def consume(workitem) workitem.fields['seen'] = true reply_to_engine(workitem) end end class MyMessageParticipant include Ruote::LocalParticipant - def initialize (opts) + def initialize(opts) @opts = opts end - def consume (workitem) + def consume(workitem) workitem.fields['message'] = @opts['message'] reply_to_engine(workitem) end end @@ -58,8 +58,34 @@ end) r = wait_for(wfid) assert_equal 'hi', r['workitem']['fields']['message'] + end + + class MyOtherParticipant + include Ruote::LocalParticipant + def consume(wi) + wi.fields['hello'] = 'kitty' + reply_to_engine(wi) + end + def on_reply(wi) + @context.tracer << wi.fields['hello'] + "\n" + @context.tracer << applied_workitem(wi.fei).fields['hello'] + "\n" + @context.tracer << workitem(wi.fei).fields['hello'] + end + end + + def test_workitem_method + + @engine.register 'alpha', MyOtherParticipant + + #noisy + + wfid = @engine.launch(Ruote.define { alpha }, 'hello' => 'world') + + @engine.wait_for(wfid) + + assert_equal %w[ kitty world world ], @tracer.to_a end end