rtml 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. data/History.txt +3 -0
  2. data/Manifest.txt +51 -13
  3. data/Rakefile +6 -1
  4. data/builtin/controllers/rtml_controller.rb +12 -1
  5. data/builtin/models/rtml/document.rb +24 -18
  6. data/builtin/models/rtml/document_model_object.rb +6 -0
  7. data/builtin/models/rtml/dom/collections/element_set.rb +6 -0
  8. data/builtin/models/rtml/dom/collections/property_set.rb +11 -0
  9. data/builtin/models/rtml/dom/element.rb +79 -27
  10. data/builtin/models/rtml/dom/frontend_element.rb +41 -20
  11. data/builtin/models/rtml/dom/property.rb +43 -26
  12. data/builtin/models/rtml/dom/screen_element.rb +13 -0
  13. data/builtin/widgets/document_variable_processing.rb +42 -18
  14. data/builtin/widgets/element_builder.rb +4 -4
  15. data/builtin/widgets/screen_variable_processing.rb +2 -2
  16. data/builtin/widgets/screen_variants.rb +31 -4
  17. data/builtin/widgets/screens.rb +13 -1
  18. data/builtin/widgets/static_content.rb +20 -6
  19. data/do_profile.rb +15 -0
  20. data/lib/extensions/action_controller/response.rb +0 -18
  21. data/lib/extensions/action_controller/routing/route_set.rb +28 -18
  22. data/lib/extensions/hpricot/doc.rb +3 -3
  23. data/lib/extensions/hpricot/elem.rb +3 -3
  24. data/lib/extensions/string.rb +2 -18
  25. data/lib/rtml.rb +0 -12
  26. data/lib/rtml/assigns.rb +32 -0
  27. data/lib/rtml/controller/document_generator.rb +9 -0
  28. data/lib/rtml/controller/render_helpers.rb +42 -18
  29. data/lib/rtml/controller/state.rb +2 -1
  30. data/lib/rtml/dependencies.rb +20 -15
  31. data/lib/rtml/dsl.rb +10 -10
  32. data/lib/rtml/environment.rb +13 -1
  33. data/lib/rtml/errors/application_error.rb +5 -0
  34. data/lib/rtml/errors/simulation_error.rb +4 -0
  35. data/lib/rtml/errors/variable_error.rb +5 -0
  36. data/lib/rtml/high_level/variable_manager.rb +11 -7
  37. data/lib/rtml/inherited_instance_variables.rb +8 -1
  38. data/lib/rtml/links.rb +17 -0
  39. data/lib/rtml/rules/dom_validation.rb +1 -0
  40. data/lib/rtml/test/builtin_variables.rb +33 -0
  41. data/lib/rtml/test/resemblance_test.rb +97 -0
  42. data/lib/rtml/test/screen.rb +126 -0
  43. data/lib/rtml/test/simulator.rb +240 -0
  44. data/lib/rtml/test/simulator_post_processors/base.rb +7 -0
  45. data/lib/rtml/test/simulator_post_processors/card_parsers.rb +32 -0
  46. data/lib/rtml/test/simulator_post_processors/receipt.rb +15 -0
  47. data/lib/rtml/test/simulator_post_processors/submit.rb +15 -0
  48. data/lib/rtml/test/spec.rb +14 -7
  49. data/lib/rtml/test/spec/matchers.rb +24 -0
  50. data/lib/rtml/test/tml_application.rb +331 -0
  51. data/lib/rtml/test/unit.rb +13 -0
  52. data/lib/rtml/test/variable_scope.rb +146 -0
  53. data/lib/rtml/version.rb +1 -1
  54. data/lib/rtml/widget.rb +26 -14
  55. data/lib/rtml/widget_core/class_methods.rb +8 -4
  56. data/lib/rtml/widget_core/widget_accessor_instance_methods.rb +6 -6
  57. data/lib/rtml/widgets.rb +22 -3
  58. data/lib/rtml_routes.rb +1 -1
  59. data/rails_generators/rtml/rtml_generator.rb +3 -0
  60. data/rails_generators/rtml/templates/db/migrate/20100513165226_add_options_to_rtml_documents.rb +9 -0
  61. data/rails_generators/rtml/templates/db/migrate/20100513165242_remove_dom_elements_mirror.rb +16 -0
  62. data/rails_generators/rtml/templates/db/migrate/20100513165249_remove_dom_properties_mirror.rb +16 -0
  63. data/rails_generators/rtml/templates/lib/tasks/rtml.rake +1 -1
  64. data/rtml.gemspec +65 -0
  65. data/spec/controllers/rtml_controller_spec.rb +1 -1
  66. data/spec/integration/post_tests_spec.rb +8 -0
  67. data/spec/lib/rtml/high_level/variable_manager_spec.rb +8 -0
  68. data/spec/lib/rtml/routes_spec.rb +23 -22
  69. data/spec/lib/rtml/test/simulator/receipt_spec.rb +18 -0
  70. data/spec/lib/rtml/test/simulator_spec.rb +185 -0
  71. data/spec/lib/rtml/test/tml_application_spec.rb +119 -0
  72. data/spec/lib/rtml/test/variable_scope_spec.rb +65 -0
  73. data/spec/lib/rtml/widget_spec.rb +1 -0
  74. data/spec/lib/rtml/widgets_spec.rb +30 -0
  75. data/spec/models/rtml/document_spec.rb +8 -0
  76. data/spec/models/rtml/dom/screen_element_spec.rb +15 -0
  77. data/spec/models/rtml/instruction_spec.rb +2 -2
  78. data/spec/rtml_action_spec.rb +25 -0
  79. data/spec/spec_helper.rb +31 -1
  80. data/spec/support/app/controllers/post_tests_controller.rb +11 -0
  81. data/spec/support/app/views/inherited/instance_variables_test/display.rtml.erb +1 -0
  82. data/spec/support/config/boot.rb +1 -0
  83. data/spec/support/config/routes.rb +3 -2
  84. data/spec/support/db/rtml_test_db.sqlite3 +0 -0
  85. data/spec/support/raw_tml/avs.tml +27 -0
  86. data/spec/support/raw_tml/document_level_events.tml +18 -0
  87. data/spec/support/raw_tml/empty_screen.tml +15 -0
  88. data/spec/support/raw_tml/enter_amount.tml +40 -0
  89. data/spec/support/raw_tml/foreign_receiver.tml +10 -0
  90. data/spec/support/raw_tml/foreign_reference.tml +10 -0
  91. data/spec/support/raw_tml/hello_world.tml +13 -0
  92. data/spec/support/raw_tml/loop_x_times.tml +39 -0
  93. data/spec/support/raw_tml/one_screen_with_setvar.tml +8 -0
  94. data/spec/support/raw_tml/receipt.tml +15 -0
  95. data/spec/support/raw_tml/simulator.tml +122 -0
  96. data/spec/support/raw_tml/tmlvar_reference.tml +34 -0
  97. data/spec/support/raw_tml/user_input.tml +47 -0
  98. data/spec/support/raw_tml/valid_document.tml +6 -0
  99. data/spec/support/rspec/example_groups.rb +1 -1
  100. data/spec/support/rspec/matchers.rb +0 -11
  101. data/spec/widgets/document_variable_processing_spec.rb +25 -39
  102. data/spec/widgets/element_builder_spec.rb +4 -0
  103. data/spec/widgets/event_listener_spec.rb +9 -0
  104. data/spec/widgets/highlevel_variable_processing_spec.rb +27 -2
  105. data/spec/widgets/screen_variable_processing_spec.rb +34 -0
  106. data/spec/widgets/screens_spec.rb +22 -0
  107. data/spec/widgets/simulator_post_processors/card_parsers_spec.rb +70 -0
  108. data/spec/widgets/simulator_post_processors/submit_spec.rb +44 -0
  109. data/tasks/stats.rake +10 -0
  110. data/test/test_rtml_generator.rb +3 -0
  111. metadata +55 -49
  112. data/builtin/widgets/subroutine.rb +0 -54
  113. data/lib/rtml/high_level/subroutine.rb +0 -22
  114. data/lib/rtml/reverse_engineering/crawler.rb +0 -58
  115. data/lib/rtml/reverse_engineering/simulator.rb +0 -269
  116. data/lib/rtml/reverse_engineering/simulator/casting.rb +0 -9
  117. data/lib/rtml/reverse_engineering/simulator/snapshot.rb +0 -18
  118. data/lib/rtml/reverse_engineering/simulator/variable_lookup.rb +0 -32
  119. data/lib/rtml/reverse_engineering/simulator/variable_value.rb +0 -105
  120. data/spec/lib/rtml/reverse_engineering/crawler_spec.rb +0 -24
  121. data/spec/lib/rtml/reverse_engineering/simulator/variable_value_spec.rb +0 -120
  122. data/spec/lib/rtml/reverse_engineering/simulator_spec.rb +0 -96
  123. data/spec/support/config/tml_dom_ruleset.rb +0 -82
  124. data/spec/widgets/subroutine_spec.rb +0 -109
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <tml xmlns="http://www.ingenico.co.uk/tml" cache="deny">
3
+ <head />
4
+
5
+ <screen id="init">
6
+ <setvar name='payment.amount' lo='100' />
7
+ </screen>
8
+ </tml>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <tml cache="allow" xmlns="http://www.ingenico.co.uk/tml">
3
+ <head />
4
+ <!--app_start--> <screen id="app_start">
5
+ <next uri="#receipt" />
6
+ <display>
7
+ start here
8
+ </display>
9
+ </screen>
10
+ <!--receipt--> <screen id="receipt">
11
+ <print>
12
+ <h1>This is printed content.</h1>
13
+ </print>
14
+ </screen>
15
+ </tml>
@@ -0,0 +1,122 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <tml xmlns="http://www.ingenico.co.uk/tml" cache="deny">
3
+ <head />
4
+
5
+ <vardcl name="counter" type="integer" />
6
+
7
+
8
+ <!-- For circular path testing and basic analysis -->
9
+ <screen id="init" next="#main">
10
+ <setvar name="txn.amount" lo="0" />
11
+ </screen>
12
+
13
+ <screen id="main" cancel="emb://embedded.tml">
14
+ <next uri="#init">
15
+
16
+ </next>
17
+
18
+ <display>
19
+ <h1>Hello, World!</h1>
20
+ </display>
21
+ </screen>
22
+
23
+
24
+ <!-- For simulator noninteraction testing -->
25
+ <screen id="nointerstart" next="#nointer1">
26
+ <setvar name="counter" lo="0" />
27
+ </screen>
28
+
29
+ <screen id="nointer1">
30
+ <setvar name="counter" lo="tmlvar:counter" op="plus" ro="1" />
31
+ <next uri="#nointer1">
32
+
33
+ <variant uri="#nointerdone" lo="tmlvar:counter" op="equal" ro="5" />
34
+ </next>
35
+ <display>
36
+ Counting: <getvar name="counter" />
37
+ </display>
38
+ </screen>
39
+
40
+ <screen id="nointerdone" next="#nointerstart">
41
+ <display>
42
+
43
+ Done.<br/>
44
+ <a href="#init">Restart Application</a> |
45
+ <a href="#nointerstart">Restart Count</a>
46
+ </display>
47
+ </screen>
48
+
49
+
50
+ <!-- For variant testing -->
51
+
52
+ <screen id="variantstart" next="#variantcheck">
53
+ <setvar name="counter" lo="0" />
54
+ </screen>
55
+
56
+ <screen id="variantcheck">
57
+ <setvar name="counter" lo="tmlvar:counter" op="plus" ro="1" />
58
+ <next uri="#variantcheck">
59
+ <variant uri="#variantdone" lo="tmlvar:counter" op="equal" ro="5" />
60
+ <variant uri="#variantto" timeout="3" />
61
+
62
+ <variant uri="#varianthk" key="00" />
63
+ </next>
64
+ <display><a href="#variantcancl">Cancel</a></display>
65
+ </screen>
66
+
67
+ <screen id="variantdone">
68
+ <next uri="#variantstart" />
69
+ <display>Counted 5 times!</display>
70
+
71
+ </screen>
72
+
73
+ <screen id="variantcancl">
74
+ <display>Cancelled.</display>
75
+ </screen>
76
+
77
+ <screen id="variantto">
78
+ <display>Timed out.</display>
79
+ </screen>
80
+
81
+ <screen id="varianthk">
82
+ <display>Interrupted!</display>
83
+ </screen>
84
+
85
+
86
+ <!-- For dead-end testing -->
87
+ <screen id="dead_start" next="#dead_middle">
88
+ <display>First</display>
89
+
90
+ </screen>
91
+
92
+ <screen id="dead_middle">
93
+ <next uri="#dead_end">
94
+
95
+ </next>
96
+ <display>Second</display>
97
+ </screen>
98
+
99
+ <screen id="dead_end">
100
+
101
+ <display>Third - Program End.</display>
102
+ </screen>
103
+
104
+ <!-- for cardswipe testing -->
105
+ <screen id="cardswipe" next="#init">
106
+ <tform>
107
+ <card parser="mag" params="read_data" />
108
+ </tform>
109
+ </screen>
110
+
111
+ <!-- For assertion failure testing -->
112
+ <screen id="assert_start" next="#assert">
113
+ <display>First</display>
114
+ </screen>
115
+
116
+ <screen id="assert" next="#init">
117
+ <display>
118
+ Assertion Failure
119
+ </display>
120
+
121
+ </screen>
122
+ </tml>
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <tml xmlns="http://www.ingenico.co.uk/tml" cache="deny">
3
+ <head />
4
+
5
+ <vardcl name='on_menu' type='string' />
6
+ <vardcl name="value" />
7
+ <vardcl name="submit_to" />
8
+
9
+ <screen id="idle" next="#idle" menu="tmlvar:on_menu">
10
+ <setvar name='on_menu' lo='spec/support/raw_tml/foreign_receiver.tml' />
11
+ <display>
12
+ Hello, World!
13
+ </display>
14
+ </screen>
15
+
16
+ <screen id="submit_scr" next="#err">
17
+ <setvar name="submit_to" lo="#submitted_to" />
18
+ <submit tgt="tmlvar:submit_to" econn="#err">
19
+ <getvar name='value' />
20
+ </submit>
21
+ </screen>
22
+
23
+ <screen id="submitted_to">
24
+ <display>
25
+ done
26
+ </display>
27
+ </screen>
28
+
29
+ <screen id="err">
30
+ <display>
31
+ error
32
+ </display>
33
+ </screen>
34
+ </tml>
@@ -0,0 +1,47 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <tml xmlns="http://www.ingenico.co.uk/tml" cache="deny">
3
+ <head />
4
+
5
+ <screen id="init" next="#main">
6
+ <!-- maybe some init here one day? maybe not... -->
7
+ </screen>
8
+
9
+ <!-- #main doubles as a hyperlink test -->
10
+ <screen id="main" next="#main">
11
+ <display>
12
+ Choose a test:
13
+ <a href="#hyperlinks">hyperlinks</a><br/>
14
+ <a href="#hotkeys">hotkeys</a><br/>
15
+ </display>
16
+ </screen>
17
+
18
+ <!-- conclusion of the epic Hyperlink series... -->
19
+ <screen id="hyperlinks" next="#hyperlinks">
20
+ <display>
21
+ The hyperlink worked...
22
+ </display>
23
+ </screen>
24
+
25
+ <!-- hotkey test -->
26
+ <screen id="hotkeys">
27
+ <next uri="#hotkeys">
28
+ <variant uri="#init" key="1" />
29
+ </next>
30
+ <display>
31
+ Press 1 to leave.
32
+ </display>
33
+ </screen>
34
+
35
+ <!-- menu and cancel button test -->
36
+ <screen id="test_menu" cancel="#on_cancel" menu="#on_menu">
37
+ <display>
38
+ Press MENU for menu.
39
+ </display>
40
+ </screen>
41
+ <screen id="on_menu" />
42
+ <screen id="on_cancel">
43
+ <next uri="#test_menu">
44
+ <variant uri="#main" key="1" />
45
+ </next>
46
+ </screen>
47
+ </tml>
@@ -94,6 +94,12 @@
94
94
  <display>Third - Program End.</display>
95
95
  </screen>
96
96
 
97
+ <!-- for cardswipe testing -->
98
+ <screen id="cardswipe" next="#init">
99
+ <tform>
100
+ <card parser="mag" params="read_data" />
101
+ </tform>
102
+ </screen>
97
103
 
98
104
  <!-- For assertion failure testing -->
99
105
  <screen id="assert_start" next="#assert">
@@ -1,3 +1,3 @@
1
1
  require 'rtml/test/spec'
2
2
 
3
- Spec::Example::ExampleGroupFactory.default(RtmlExampleGroup)
3
+ Spec::Example::ExampleGroupFactory.default(Rtml::Test::Spec::RtmlExampleGroup)
@@ -4,17 +4,6 @@ Spec::Matchers.define :contain do |item|
4
4
  end
5
5
  end
6
6
 
7
- Spec::Matchers.define :resemble do |item|
8
- match do |doc|
9
- case doc
10
- when ActionController::Response, String
11
- doc.tml_should_resemble(item)
12
- else
13
- doc.to_tml.tml_should_resemble(item)
14
- end
15
- end
16
- end
17
-
18
7
  class ResponseContainsErrors
19
8
  def initialize(exception_class = nil)
20
9
  @exception_class = exception_class
@@ -1,31 +1,15 @@
1
1
  require File.join(__FILE__.gsub(/(.*)?\/spec\/.*$/, '\1'), 'spec/spec_helper')
2
2
 
3
3
  describe Rtml::Widgets::DocumentVariableProcessing do
4
- context "with an existing document" do
5
- before :each do
6
- Rtml::Document.create!(:name => 'test')
7
- @doc = Rtml::Document.find_by_name('test')
8
- end
9
-
10
- it "should raise InvalidOptionError if options contain any invalid keys" do
11
- assert_raises Rtml::Errors::InvalidOptionError do
12
- @doc.declare_variable :varname, :some_invalid_key => 1234
13
- end
14
- end
15
-
16
- it "should raise InvalidOptionError if type is invalid" do
17
- assert_raises Rtml::Errors::InvalidOptionError do
18
- @doc.declare_variable :varname, :type => :invalid_type_name
19
- end
20
- end
21
-
4
+ shared_examples_for "a variable processor" do
22
5
  %w(string integer datetime opaque binary).each do |type|
23
6
  line = __LINE__ + 2
24
7
  code = <<-end_code
25
8
  it "should declare and define one TML #{type}" do
9
+ start = @doc.defined_variables(#{type.inspect}).count
26
10
  @doc.#{type} :#{type}
27
11
  @doc.#{type.pluralize}.should have(1).item
28
- @doc.defined_variables(#{type.inspect}).should have(1).item
12
+ @doc.defined_variables(#{type.inspect}).should have(start+1).item
29
13
  end
30
14
  end_code
31
15
  eval code, binding, __FILE__, line
@@ -33,18 +17,22 @@ describe Rtml::Widgets::DocumentVariableProcessing do
33
17
  line = __LINE__ + 2
34
18
  code = <<-end_code
35
19
  it "should declare and define multiple TML #{type.pluralize}" do
20
+ start = @doc.defined_variables(#{type.inspect}).count
36
21
  @doc.#{type.pluralize} :#{type}1, :#{type}2
37
22
  @doc.#{type.pluralize}.should have(2).items
38
- @doc.defined_variables(#{type.inspect}).should have(2).items
23
+ @doc.defined_variables(#{type.inspect}).should have(start+2).items
39
24
  end
40
25
  end_code
41
26
  eval code, binding, __FILE__, line
42
27
  end
43
28
  end
44
29
 
45
- context "with a new document" do
30
+ context "with an existing document" do
31
+ it_should_behave_like "a variable processor"
32
+
46
33
  before :each do
47
- @doc = Rtml::Document.new
34
+ Rtml::Document.create!(:name => 'test')
35
+ @doc = Rtml::Document.find_by_name('test')
48
36
  end
49
37
 
50
38
  it "should raise InvalidOptionError if options contain any invalid keys" do
@@ -58,27 +46,25 @@ describe Rtml::Widgets::DocumentVariableProcessing do
58
46
  @doc.declare_variable :varname, :type => :invalid_type_name
59
47
  end
60
48
  end
49
+ end
61
50
 
62
- %w(string integer datetime opaque binary).each do |type|
63
- line = __LINE__ + 2
64
- code = <<-end_code
65
- it "should declare and define one TML #{type}" do
66
- @doc.#{type} :#{type}
67
- @doc.#{type.pluralize}.should have(1).item
68
- @doc.defined_variables(#{type.inspect}).should have(1).item
51
+ context "with a new document" do
52
+ it_should_behave_like "a variable processor"
53
+
54
+ before :each do
55
+ @doc = Rtml::Document.new
56
+ end
57
+
58
+ it "should raise InvalidOptionError if options contain any invalid keys" do
59
+ assert_raises Rtml::Errors::InvalidOptionError do
60
+ @doc.declare_variable :varname, :some_invalid_key => 1234
69
61
  end
70
- end_code
71
- eval code, binding, __FILE__, line
62
+ end
72
63
 
73
- line = __LINE__ + 2
74
- code = <<-end_code
75
- it "should declare and define multiple TML #{type.pluralize}" do
76
- @doc.#{type.pluralize} :#{type}1, :#{type}2
77
- @doc.#{type.pluralize}.should have(2).items
78
- @doc.defined_variables(#{type.inspect}).should have(2).items
64
+ it "should raise InvalidOptionError if type is invalid" do
65
+ assert_raises Rtml::Errors::InvalidOptionError do
66
+ @doc.declare_variable :varname, :type => :invalid_type_name
79
67
  end
80
- end_code
81
- eval code, binding, __FILE__, line
82
68
  end
83
69
  end
84
70
  end
@@ -7,6 +7,10 @@ describe Rtml::Widgets::ElementBuilder do
7
7
  @doc = Rtml::Document.find_by_name("Test Document")
8
8
  end
9
9
 
10
+ after(:each) do
11
+ Rtml::Document.destroy_all
12
+ end
13
+
10
14
  it "should make sure to assign a parent to each element" do
11
15
  @doc.build :tml do
12
16
  build :screen do
@@ -26,6 +26,15 @@ describe Rtml::Widgets::EventListener do
26
26
 
27
27
  context "at screen level" do
28
28
  before(:each) { @scr = @doc.screen :main }
29
+
30
+ it "should merge multiple calls" do
31
+ @scr.on 1 => :on_cancel
32
+ @scr.on 2 => :on_menu
33
+ @scr.on 3 => :on_key
34
+ @scr.to_tml.should have_selector(:variant, :uri => "#on_cancel", :key => "1")
35
+ @scr.to_tml.should have_selector(:variant, :uri => "#on_menu", :key => "2")
36
+ @scr.to_tml.should have_selector(:variant, :uri => "#on_key", :key => "3")
37
+ end
29
38
 
30
39
  it "should raise an error given an invalid key" do
31
40
  proc { @scr.on :invalid_key => 'invalid_destination' }.should raise_error(Rtml::Errors::RulesViolationError)
@@ -8,6 +8,32 @@ describe Rtml::Widgets::HighlevelVariableProcessing do
8
8
  @doc.integer :sale
9
9
  end
10
10
 
11
+ context "with name mangling" do
12
+ before(:each) do
13
+ prefix = "swipe_card"
14
+ next_screen_name = "read_card"
15
+
16
+ @doc.screen "#{prefix}_risk_management", "#{prefix}_trans_reject" do
17
+ _if(tvars['card.parser.type'] == 'mag') { goto "#{prefix}_risk_check" }
18
+ _elsif(tvars['card.input_type'] == 3) { goto "#{prefix}_risk_check" }
19
+ end
20
+
21
+ @doc.screen "#{prefix}_risk_check", next_screen_name do
22
+ build :tform do
23
+ build :card, :parser => :mag, :parser_params => :risk_mgmt
24
+ end
25
+ end
26
+
27
+ @doc.screen "#{prefix}_trans_reject", :init, :timeout => '3' do
28
+ display "Transaction Rejected: <getvar name='card.parser.reject_reason' />"
29
+ end
30
+ end
31
+
32
+ it "" do
33
+ # puts @doc.to_tml
34
+ end
35
+ end
36
+
11
37
  context "using periods instead of array operators" do
12
38
  context "with one TML variable assigned to another" do
13
39
  before :each do
@@ -79,9 +105,8 @@ describe Rtml::Widgets::HighlevelVariableProcessing do
79
105
  end
80
106
 
81
107
  it "should generate a :uri pointing to an anchor" do
82
- #puts @tml
83
108
  @nxt.property('uri').should_not be_nil
84
- @nxt.properties.first.to_tml[5].should == ?#
109
+ @nxt.properties.first.to_tml.should =~ /uri="#init_else"/
85
110
  end
86
111
 
87
112
  context "with 2 generated variants" do
@@ -5,6 +5,40 @@ describe Rtml::Widgets::ScreenVariableProcessing do
5
5
  @doc = Rtml::Document.new
6
6
  end
7
7
 
8
+ it "should convert long screen IDs that are symbols into short ones" do
9
+ @doc.strings :scrid
10
+
11
+ scr = @doc.screen :screen_with_long_screen_id do
12
+ set :scrid => :screen_with_long_screen_id
13
+ end
14
+
15
+ sets = scr / "setvar"
16
+ sets.first.find_property('lo').tml_value.should =~ /screen_with?[0-9]+/
17
+ end
18
+
19
+ it "should convert long screen IDs that are strings with hash marks into short ones" do
20
+ @doc.strings :scrid
21
+
22
+ scr = @doc.screen :screen_with_long_screen_id do
23
+ set :scrid => '#screen_with_long_screen_id'
24
+ end
25
+
26
+ sets = scr / "setvar"
27
+ sets.first.find_property('lo').tml_value.should =~ /screen_with?[0-9]+/
28
+ end
29
+
30
+ it "should not convert long screen IDs that are strings without hash marks into short ones" do
31
+ @doc.strings :scrid
32
+
33
+ scr = @doc.screen :screen_with_long_screen_id do
34
+ set :scrid => 'screen_with_long_screen_id'
35
+ end
36
+
37
+ sets = scr / "setvar"
38
+ # updated: do not shorten reference unless it begins with "#" or is a symbol
39
+ sets.first.find_property('lo').tml_value.should_not =~ /screen_with?[0-9]+/
40
+ end
41
+
8
42
  it "should convert true and false into integers" do
9
43
  @doc.boolean :is_sale
10
44
  @doc.boolean :initialized