test/functional/eft_14_cursor.rb in ruote-2.2.0 vs test/functional/eft_14_cursor.rb in ruote-2.3.0
- old
+ new
@@ -3,11 +3,11 @@
# testing ruote
#
# Mon Jun 29 18:34:02 JST 2009
#
-require File.join(File.dirname(__FILE__), 'base')
+require File.expand_path('../base', __FILE__)
require 'ruote/part/no_op_participant'
class EftCursorTest < Test::Unit::TestCase
@@ -145,14 +145,14 @@
alpha
end
end
end
- @engine.register_participant :alpha do |workitem|
+ @dashboard.register_participant :alpha do |workitem|
workitem.fields['counter'] += 1
workitem.fields['rewind'] = workitem.fields['counter'] < 5
- @tracer << "a\n"
+ tracer << "a\n"
end
#noisy
assert_trace(%w[ a ] * 5, pdef)
@@ -167,21 +167,21 @@
jump :to => 'author', :if => '${not_ok}'
publisher
end
end
- @engine.register_participant :author do |workitem|
- @tracer << "a\n"
- stash[:count] ||= 0
- stash[:count] += 1
+ @dashboard.register_participant :author do |workitem|
+ tracer << "a\n"
+ context.stash[:count] ||= 0
+ context.stash[:count] += 1
end
- @engine.register_participant :reviewer do |workitem|
- @tracer << "r\n"
- workitem.fields['not_ok'] = (stash[:count] < 3)
+ @dashboard.register_participant :reviewer do |workitem|
+ tracer << "r\n"
+ workitem.fields['not_ok'] = (context.stash[:count] < 3)
end
- @engine.register_participant :publisher do |workitem|
- @tracer << "p\n"
+ @dashboard.register_participant :publisher do |workitem|
+ tracer << "p\n"
end
#noisy
assert_trace %w[ a r a r a r p ], pdef
@@ -200,11 +200,11 @@
end
end
#noisy
- wfid = @engine.launch(pdef)
+ wfid = @dashboard.launch(pdef)
wait_for(14)
#p @tracer.to_s
@@ -224,23 +224,23 @@
alpha
end
end
end
- @engine.register_participant :alpha, Ruote::NoOpParticipant
+ @dashboard.register_participant :alpha, Ruote::NoOpParticipant
#noisy
- wfid = @engine.launch(pdef)
+ wfid = @dashboard.launch(pdef)
wait_for(:alpha)
wait_for(wfid)
#p @tracer.to_s
assert_equal %w[ a a a ], @tracer.to_a[0, 3]
- assert_nil @engine.process(wfid)
+ assert_nil @dashboard.process(wfid)
end
def test_nested_break
pdef = Ruote.process_definition :name => 'test' do
@@ -317,11 +317,11 @@
echo 'done.'
end
#noisy
- @engine.register do
+ @dashboard.register do
alpha EftCursorTest::Alpha
bravo EftCursorTest::Bravo
end
assert_trace "in\ndone.", pdef
@@ -333,17 +333,17 @@
cursor do
rewind
end
end
- #@engine.noisy = true
+ #@dashboard.noisy = true
- wfid = @engine.launch(pdef)
+ wfid = @dashboard.launch(pdef)
- @engine.wait_for(9)
+ @dashboard.wait_for(9)
- assert_not_nil @engine.process(wfid)
+ assert_not_nil @dashboard.process(wfid)
end
class Charly
include Ruote::LocalParticipant
def initialize(opts)
@@ -369,11 +369,11 @@
def test_workitem_command_and_jump_array
#noisy
- @engine.register do
+ @dashboard.register do
charly EftCursorTest::Charly, 'command' => [ 'jump', 'delta' ]
catchall Ruote::NoOpParticipant
end
assert_trace "top\nbottom", JUMP_DEF
@@ -381,11 +381,11 @@
def test_workitem_command_and_jump_string
#noisy
- @engine.register do
+ @dashboard.register do
charly EftCursorTest::Charly, 'command' => 'jump delta'
catchall Ruote::NoOpParticipant
end
assert_trace "top\nbottom", JUMP_DEF
@@ -393,14 +393,64 @@
def test_workitem_command_and_jump_to_string
#noisy
- @engine.register do
+ @dashboard.register do
charly EftCursorTest::Charly, 'command' => 'jump to delta'
catchall Ruote::NoOpParticipant
end
assert_trace "top\nbottom", JUMP_DEF
+ end
+
+ def test_reset
+
+ pdef = Ruote.define do
+ cursor do
+ alpha
+ set 'f:toto' => 'oops'
+ reset
+ end
+ end
+
+ @dashboard.register { catchall }
+
+ #@dashboard.noisy = true
+
+ wfid = @dashboard.launch(pdef)
+ @dashboard.wait_for(:alpha)
+
+ assert_nil @dashboard.storage_participant.first.fields['toto']
+
+ @dashboard.storage_participant.proceed(@dashboard.storage_participant.first)
+ @dashboard.wait_for(:alpha)
+
+ assert_nil @dashboard.storage_participant.first.fields['toto']
+ end
+
+ def test_reset_if
+
+ pdef = Ruote.define do
+ cursor :reset_if => '${f:reset} == true' do
+ alpha
+ set 'f:toto' => 'oops'
+ set 'f:reset' => true
+ end
+ end
+
+ @dashboard.register { catchall }
+
+ #@dashboard.noisy = true
+
+ wfid = @dashboard.launch(pdef)
+ @dashboard.wait_for(:alpha)
+
+ assert_nil @dashboard.storage_participant.first.fields['toto']
+
+ @dashboard.storage_participant.proceed(@dashboard.storage_participant.first)
+ @dashboard.wait_for(:alpha)
+
+ assert_nil @dashboard.storage_participant.first.fields['toto']
end
end