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

- old
+ new

@@ -86,11 +86,18 @@ end end #noisy - assert_trace('><', pdef) + wfid = @engine.launch(pdef) + + @engine.wait_for(wfid) + + assert_equal( + "#<ArgumentError: 'ruby_eval_allowed' is set to false, cannot evaluate" + + " >1 + 2< (http://ruote.rubyforge.org/dollar.html)>", + @engine.errors.first.message) end def test_r pdef = Ruote.process_definition do @@ -165,11 +172,11 @@ wfid = @engine.launch(pdef) @engine.wait_for(wfid) - assert_equal "0_0_0!!#{wfid}\n#{wfid}", @tracer.to_s + assert_match /^0_0_0![^!]+!#{wfid}\n#{wfid}$/, @tracer.to_s end def test_direct_access_to_fields pdef = Ruote.process_definition do @@ -182,8 +189,80 @@ @engine.context['ruby_eval_allowed'] = true #noisy assert_trace 'alpha/bravo/charly', pdef + end + + def test_dollar_quote + + pdef = Ruote.define do + set 'f:a' => 'alpha' + set 'f:b' => 'bra vo' + echo '${"f:a}' + echo "${'f:a}" + echo 'ok', :if => "${'f:b} == 'bra vo'" + end + + assert_trace %w[ "alpha" "alpha" ok ], pdef + end + + def test_literally + + pdef = Ruote.define do + set 'f:a' => %w[ A B C ] + set 'f:b' => 'a' + set 'v:c' => %w[ venture capitalist ] + set 'f:A' => '$f:a' + set 'f:B' => '$f:${b}' + set 'f:C' => '$v:c' + set 'f:D' => '$f:nada' + set 'f:E' => '$v:nada' + set 'f:F' => '$a' + set 'f:G' => '$nada' + set 'f:H' => '$a ' + filter :f => /^[a-c]$/, :del => true + end + + #noisy + + wfid = @engine.launch(pdef) + + r = @engine.wait_for(wfid) + + assert_equal( + { + 'A' => %w[ A B C ], + 'B' => %w[ A B C ], + 'C' => %w[ venture capitalist ], + 'D' => '$f:nada', + 'E' => '$v:nada', + 'F' => %w[ A B C ], + 'G' => '$nada', + 'H' => '$a ' + }, + r['workitem']['fields']) + end + + def test_literally_and_participant_params + + pdef = Ruote.define do + set 'f:a' => %w[ A B C ] + alpha :b => '$f:a' + end + + @engine.register_participant :alpha do |wi| + wi.fields['parameters'] = wi.fields['params'] + end + + #noisy + + wfid = @engine.launch(pdef) + + r = @engine.wait_for(wfid) + + assert_equal( + { 'b' => %w[ A B C ], 'ref' => 'alpha' }, + r['workitem']['fields']['parameters']) end end