test/functional/eft_20_save.rb in ruote-2.2.0 vs test/functional/eft_20_save.rb in ruote-2.3.0

- old
+ new

@@ -3,11 +3,11 @@ # testing ruote # # Mon Aug 3 12:13:11 JST 2009 # -require File.join(File.dirname(__FILE__), 'base') +require File.expand_path('../base', __FILE__) require 'ruote/participant' class EftSaveTest < Test::Unit::TestCase @@ -20,19 +20,19 @@ alpha end #noisy - @engine.register_participant :alpha, Ruote::StorageParticipant + @dashboard.register_participant :alpha, Ruote::StorageParticipant - wfid = @engine.launch(pdef) + wfid = @dashboard.launch(pdef) wait_for(:alpha) - ps = @engine.process(wfid) + ps = @dashboard.process(wfid) - assert_equal Hash, ps.variables['v'].class + assert ps.variables['v'].kind_of?(Hash) end def test_save_to_field pdef = Ruote.process_definition :name => 'test' do @@ -41,13 +41,13 @@ alpha end #noisy - alpha = @engine.register_participant :alpha, Ruote::StorageParticipant + alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant - wfid = @engine.launch(pdef) + wfid = @dashboard.launch(pdef) wait_for(:alpha) assert_equal 'surf', alpha.first.fields['f']['nada'] end @@ -61,16 +61,58 @@ alpha end #noisy - alpha = @engine.register_participant :alpha, Ruote::StorageParticipant + alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant - wfid = @engine.launch(pdef) + wfid = @dashboard.launch(pdef) wait_for(:alpha) #p alpha.first.fields assert_equal 'surf', alpha.first.fields['h']['wi_as_before']['nada'] + end + + # sfo -> fra + + def test_save_to_f # and deep f + + pdef = Ruote.process_definition do + set 'f:x' => 'val0' + set 'f:h' => {} + save :to => 'f:h.deep' + save :to => 'f:a' + end + + #@dashboard.noisy = true + + wfid = @dashboard.launch(pdef) + + fields = @dashboard.wait_for(wfid)['workitem']['fields'] + Ruote.delete_all(fields, '__result__') + + assert_equal( + { 'deep' => { 'x' => 'val0', 'h' => {} } }, + fields['h']) + assert_equal( + { 'x' => 'val0', 'h' => { 'deep' => { 'x' => 'val0', 'h' => { } } } }, + fields['a']) + end + + def test_save_to_v + + pdef = Ruote.process_definition do + set 'f:x' => 'val0' + save :to => 'v:a' + set 'f:y' => '$v:a' + end + + #@dashboard.noisy = true + + wfid = @dashboard.launch(pdef) + fields = @dashboard.wait_for(wfid)['workitem']['fields'] + + assert_equal({ 'x' => 'val0', '__result__' => 'val0' }, fields['y']) end end