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,65 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{rtml}
5
+ s.version = "2.0.4"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Colin MacKenzie IV"]
9
+ s.date = %q{2010-07-07}
10
+ s.default_executable = %q{rtml}
11
+ s.description = %q{RubyTML (or just RTML) is a Ruby framework for communicating with Ingenico's Incendo-based payment devices.}
12
+ s.email = ["colin.mackenzie4@ingenico.com"]
13
+ s.executables = ["rtml"]
14
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt"]
15
+ s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "app_generators/rtml/USAGE", "app_generators/rtml/rtml_generator.rb", "app_generators/rtml/templates/rtml_template.rb", "bin/rtml", "builtin/controllers/rtml_controller.rb", "builtin/models/rtml/document.rb", "builtin/models/rtml/document_model_object.rb", "builtin/models/rtml/dom/collections/element_set.rb", "builtin/models/rtml/dom/collections/property_set.rb", "builtin/models/rtml/dom/element.rb", "builtin/models/rtml/dom/frontend_element.rb", "builtin/models/rtml/dom/property.rb", "builtin/models/rtml/dom/screen_element.rb", "builtin/models/rtml/instruction.rb", "builtin/models/rtml/instruction/follow_class_methods.rb", "builtin/models/rtml/state.rb", "builtin/models/rtml/state/variable_mapping.rb", "builtin/models/rtml/view.rb", "builtin/rtml_helpers/rtml/get_state.rb", "builtin/rtml_helpers/rtml/rescue_action.rb", "builtin/views/rtml/rescue_action_in_public.rtml.erb", "builtin/views/rtml/rescue_action_locally.rtml.erb", "builtin/widgets/default_document.rb", "builtin/widgets/document_variable_processing.rb", "builtin/widgets/element_builder.rb", "builtin/widgets/event_listener.rb", "builtin/widgets/frontend.rb", "builtin/widgets/highlevel_variable_processing.rb", "builtin/widgets/screen_variable_processing.rb", "builtin/widgets/screen_variants.rb", "builtin/widgets/screens.rb", "builtin/widgets/shorthand.rb", "builtin/widgets/static_content.rb", "do_profile.rb", "generators/rtml_widget/USAGE", "generators/rtml_widget/rtml_widget_generator.rb", "generators/rtml_widget/templates/default_widget.erb", "generators/rtml_widget/templates/default_widget.feature.erb", "generators/rtml_widget/templates/default_widget_spec.erb", "generators/rtml_widget/templates/default_widget_test.erb", "lib/extensions/action_controller/response.rb", "lib/extensions/action_controller/routing/route_set.rb", "lib/extensions/active_support/test_case.rb", "lib/extensions/hpricot/doc.rb", "lib/extensions/hpricot/elem.rb", "lib/extensions/string.rb", "lib/rtml.rb", "lib/rtml/assigns.rb", "lib/rtml/configuration.rb", "lib/rtml/controller/before_filters.rb", "lib/rtml/controller/cache_helpers.rb", "lib/rtml/controller/class_methods/rtml_action_helpers.rb", "lib/rtml/controller/document_generator.rb", "lib/rtml/controller/render_helpers.rb", "lib/rtml/controller/rtml_helpers.rb", "lib/rtml/controller/state.rb", "lib/rtml/controller/template_helpers.rb", "lib/rtml/controller/url_helpers.rb", "lib/rtml/dependencies.rb", "lib/rtml/dsl.rb", "lib/rtml/environment.rb", "lib/rtml/errors/application_error.rb", "lib/rtml/errors/invalid_format.rb", "lib/rtml/errors/invalid_operation.rb", "lib/rtml/errors/invalid_option_error.rb", "lib/rtml/errors/missing_document_error.rb", "lib/rtml/errors/missing_variable_error.rb", "lib/rtml/errors/multiple_roots_error.rb", "lib/rtml/errors/processing_error.rb", "lib/rtml/errors/rules_violation_error.rb", "lib/rtml/errors/screen_not_found.rb", "lib/rtml/errors/screen_variant_error.rb", "lib/rtml/errors/simulation_error.rb", "lib/rtml/errors/sti_type_error.rb", "lib/rtml/errors/subprocessing_not_supported.rb", "lib/rtml/errors/unknown_rtml_action.rb", "lib/rtml/errors/variable_error.rb", "lib/rtml/high_level/managed_variable.rb", "lib/rtml/high_level/variable_manager.rb", "lib/rtml/inherited_instance_variables.rb", "lib/rtml/init.rb", "lib/rtml/rules/dom_ruleset.rb", "lib/rtml/rules/dom_tag.rb", "lib/rtml/rules/dom_validation.rb", "lib/rtml/rules/tml_param_parser.rb", "lib/rtml/test/builtin_variables.rb", "lib/rtml/test/resemblance_test.rb", "lib/rtml/test/screen.rb", "lib/rtml/test/simulator.rb", "lib/rtml/test/simulator_post_processors/base.rb", "lib/rtml/test/simulator_post_processors/card_parsers.rb", "lib/rtml/test/simulator_post_processors/receipt.rb", "lib/rtml/test/simulator_post_processors/submit.rb", "lib/rtml/test/spec.rb", "lib/rtml/test/spec/matchers.rb", "lib/rtml/test/tml_application.rb", "lib/rtml/test/unit.rb", "lib/rtml/test/variable_scope.rb", "lib/rtml/tmlized_conditions.rb", "lib/rtml/version.rb", "lib/rtml/widget.rb", "lib/rtml/widget_core/class_methods.rb", "lib/rtml/widget_core/gui_configuration.rb", "lib/rtml/widget_core/widget_accessor_class_methods.rb", "lib/rtml/widget_core/widget_accessor_instance_methods.rb", "lib/rtml/widget_core/widget_proxy.rb", "lib/rtml/widgets.rb", "lib/rtml_routes.rb", "rails/init.rb", "rails_generators/rtml/USAGE", "rails_generators/rtml/rtml_generator.rb", "rails_generators/rtml/templates/config/initializers/rtml.rb", "rails_generators/rtml/templates/config/tml_dom_ruleset.rb", "rails_generators/rtml/templates/db/migrate/20100108163703_create_rtml_dom_elements.rb", "rails_generators/rtml/templates/db/migrate/20100108163827_create_rtml_dom_properties.rb", "rails_generators/rtml/templates/db/migrate/20100108165127_create_rtml_documents.rb", "rails_generators/rtml/templates/db/migrate/20100110060124_create_rtml_instructions.rb", "rails_generators/rtml/templates/db/migrate/20100110071920_add_parent_id_to_rtml_instructions.rb", "rails_generators/rtml/templates/db/migrate/20100113131401_add_options_to_properties.rb", "rails_generators/rtml/templates/db/migrate/20100127173146_add_parent_type_to_rtml_dom_elements.rb", "rails_generators/rtml/templates/db/migrate/20100208114234_create_rtml_states.rb", "rails_generators/rtml/templates/db/migrate/20100303021609_add_x_and_y_to_rtml_instructions.rb", "rails_generators/rtml/templates/db/migrate/20100513165226_add_options_to_rtml_documents.rb", "rails_generators/rtml/templates/db/migrate/20100513165242_remove_dom_elements_mirror.rb", "rails_generators/rtml/templates/db/migrate/20100513165249_remove_dom_properties_mirror.rb", "rails_generators/rtml/templates/doc/io_tml-application-development-guidelines.pdf", "rails_generators/rtml/templates/lib/tasks/rtml.rake", "rails_generators/rtml_action/USAGE", "rails_generators/rtml_action/rtml_action_generator.rb", "rails_generators/rtml_action/templates/action.erb", "rails_generators/rtml_action/templates/view.erb", "rails_generators/widget/USAGE", "rails_generators/widget/templates/default_widget.erb", "rails_generators/widget/templates/default_widget.feature.erb", "rails_generators/widget/templates/default_widget_spec.erb", "rails_generators/widget/templates/default_widget_test.erb", "rails_generators/widget/widget_generator.rb", "script/console", "script/destroy", "script/generate", "script/server", "spec/controllers/inherited_controller_spec.rb", "spec/controllers/rtml_controller_spec.rb", "spec/lib/extensions/hpricot/doc_spec.rb", "spec/lib/extensions/hpricot/elem_spec.rb", "spec/lib/extensions/string_spec.rb", "spec/lib/rtml/extensions_spec.rb", "spec/lib/rtml/high_level/variable_manager_spec.rb", "spec/lib/rtml/routes_spec.rb", "spec/lib/rtml/rules/dom_ruleset_spec.rb", "spec/lib/rtml/rules/dom_validation_spec.rb", "spec/lib/rtml/test/simulator/receipt_spec.rb", "spec/lib/rtml/test/simulator_spec.rb", "spec/lib/rtml/test/tml_application_spec.rb", "spec/lib/rtml/test/variable_scope_spec.rb", "spec/lib/rtml/widget_core/generic_widget_consumer_spec.rb", "spec/lib/rtml/widget_core/gui_configuration_spec.rb", "spec/lib/rtml/widget_core/widget_proxy_spec.rb", "spec/lib/rtml/widget_spec.rb", "spec/lib/rtml/widgets_spec.rb", "spec/models/rtml/document_spec.rb", "spec/models/rtml/dom/element_spec.rb", "spec/models/rtml/dom/frontend_element_spec.rb", "spec/models/rtml/dom/property_spec.rb", "spec/models/rtml/dom/screen_element_spec.rb", "spec/models/rtml/instruction_spec.rb", "spec/models/rtml/state/variable_mapping_spec.rb", "spec/models/rtml/state_spec.rb", "spec/rcov.opts", "spec/rtml_action_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/support/app/controllers/application_controller.rb", "spec/support/app/controllers/inherited_controller.rb", "spec/support/app/rtml_helpers/inherited/index.rb", "spec/support/app/rtml_helpers/rtml/index.rb", "spec/support/app/views/README.txt", "spec/support/app/views/inherited/instance_variables_test/display.rtml.erb", "spec/support/app/views/layouts/layout.rtml.erb", "spec/support/app/views/magcard/_partial.erb", "spec/support/app/views/magcard/main.rtml.erb", "spec/support/app/views/rtml/index.html.erb", "spec/support/app/views/rtml/index/main.rtml.erb", "spec/support/config/database.yml", "spec/support/config/environment.rb", "spec/support/config/environments/development.rb", "spec/support/config/initializers/rtml.rb", "spec/support/config/routes.rb", "spec/support/db/rtml_test_db.sqlite3", "spec/support/db/schema.rb", "spec/support/lib/rtml/widgets/test_widget1.rb", "spec/support/lib/rtml/widgets/test_widget2.rb", "spec/support/rails.rb", "spec/support/raw_tml/avs.tml", "spec/support/raw_tml/document_level_events.tml", "spec/support/raw_tml/empty_screen.tml", "spec/support/raw_tml/enter_amount.tml", "spec/support/raw_tml/foreign_receiver.tml", "spec/support/raw_tml/foreign_reference.tml", "spec/support/raw_tml/hello_world.tml", "spec/support/raw_tml/loop_x_times.tml", "spec/support/raw_tml/one_screen_with_setvar.tml", "spec/support/raw_tml/receipt.tml", "spec/support/raw_tml/simulator.tml", "spec/support/raw_tml/tmlvar_reference.tml", "spec/support/raw_tml/user_input.tml", "spec/support/raw_tml/valid_document.tml", "spec/support/rspec/example_groups.rb", "spec/support/rspec/matchers.rb", "spec/support/vendor/gems/rtml-bootstrapper-2.0.0/.specification", "spec/support/vendor/gems/rtml-bootstrapper-2.0.0/lib/init_rtml_working_copy.rb", "spec/support/vendor/gems/rtml-bootstrapper-2.0.0/rtml.gemspec", "spec/widgets/document_variable_processing_spec.rb", "spec/widgets/element_builder_spec.rb", "spec/widgets/event_listener_spec.rb", "spec/widgets/frontend_spec.rb", "spec/widgets/highlevel_variable_processing_spec.rb", "spec/widgets/screen_variable_processing_spec.rb", "spec/widgets/screen_variants_spec.rb", "spec/widgets/screens_spec.rb", "spec/widgets/simulator_post_processors/card_parsers_spec.rb", "spec/widgets/simulator_post_processors/submit_spec.rb", "spec/widgets/static_content_spec.rb", "tasks/db.rake", "tasks/rspec.rake", "tasks/rtml.rake", "tasks/stats.rake", "test/test_generator_helper.rb", "test/test_helper.rb", "test/test_rtml_action_generator.rb", "test/test_rtml_generator.rb", "test/test_rtml_widget_generator.rb", "test/test_widget_generator.rb", "update.rb"]
16
+ s.homepage = %q{http://www.rubytml.com}
17
+ s.post_install_message = %q{After adding config.gem 'rtml' to your Rails app, don't forget to run
18
+
19
+ script/generate rtml
20
+
21
+ in order to generate rake tasks, etc.
22
+
23
+ Further documentation is available at http://www.rubytml.com
24
+ }
25
+ s.rdoc_options = ["--main", "README.rdoc"]
26
+ s.require_paths = ["lib"]
27
+ s.rubyforge_project = %q{rtml}
28
+ s.rubygems_version = %q{1.3.6}
29
+ s.summary = %q{RubyTML (or just RTML) is a Ruby framework for communicating with Ingenico's Incendo-based payment devices.}
30
+ s.test_files = ["test/test_rtml_action_generator.rb", "test/test_widget_generator.rb", "test/test_rtml_generator.rb", "test/test_helper.rb", "test/test_rtml_widget_generator.rb", "test/test_generator_helper.rb"]
31
+
32
+ if s.respond_to? :specification_version then
33
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
34
+ s.specification_version = 3
35
+
36
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
37
+ s.add_runtime_dependency(%q<rails>, [">= 2.3.5"])
38
+ s.add_runtime_dependency(%q<hpricot>, [">= 0.8.2"])
39
+ s.add_runtime_dependency(%q<sc-core-ext>, [">= 1.1.1"])
40
+ s.add_runtime_dependency(%q<rubigen>, [">= 1.5.2"])
41
+ s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
42
+ s.add_development_dependency(%q<rspec-rails>, [">= 1.3.2"])
43
+ s.add_development_dependency(%q<webrat>, [">= 0.7.0"])
44
+ s.add_development_dependency(%q<hoe>, [">= 2.5.0"])
45
+ else
46
+ s.add_dependency(%q<rails>, [">= 2.3.5"])
47
+ s.add_dependency(%q<hpricot>, [">= 0.8.2"])
48
+ s.add_dependency(%q<sc-core-ext>, [">= 1.1.1"])
49
+ s.add_dependency(%q<rubigen>, [">= 1.5.2"])
50
+ s.add_dependency(%q<rspec>, [">= 1.3.0"])
51
+ s.add_dependency(%q<rspec-rails>, [">= 1.3.2"])
52
+ s.add_dependency(%q<webrat>, [">= 0.7.0"])
53
+ s.add_dependency(%q<hoe>, [">= 2.5.0"])
54
+ end
55
+ else
56
+ s.add_dependency(%q<rails>, [">= 2.3.5"])
57
+ s.add_dependency(%q<hpricot>, [">= 0.8.2"])
58
+ s.add_dependency(%q<sc-core-ext>, [">= 1.1.1"])
59
+ s.add_dependency(%q<rubigen>, [">= 1.5.2"])
60
+ s.add_dependency(%q<rspec>, [">= 1.3.0"])
61
+ s.add_dependency(%q<rspec-rails>, [">= 1.3.2"])
62
+ s.add_dependency(%q<webrat>, [">= 0.7.0"])
63
+ s.add_dependency(%q<hoe>, [">= 2.5.0"])
64
+ end
65
+ end
@@ -61,7 +61,7 @@ describe RtmlController do
61
61
 
62
62
  it "get_state should include TML submit structure" do
63
63
  get :get_state
64
- response.tml_should_resemble :screen => { :submit => [ :getvar ] }
64
+ response.should resemble_tml(:screen => { :submit => [ :getvar ] })
65
65
  end
66
66
 
67
67
  it "should not override existing rtml helpers" do
@@ -0,0 +1,8 @@
1
+ require File.join(__FILE__.gsub(/(.*)?\/spec\/.*$/, '\1'), 'spec/spec_helper')
2
+
3
+ describe "PostTests" do
4
+ it "should still be able to POST data" do
5
+ post post_tests_path, {}
6
+ response.body.should_not contain("No action responded to index")
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require File.join(__FILE__.gsub(/(.*)?\/spec\/.*$/, '\1'), 'spec/spec_helper')
2
+
3
+ describe Rtml::HighLevel::VariableManager do
4
+ it "should include the built-in TML variables" do
5
+ proc { subject['card.pan'] }.should_not raise_error(Rtml::Errors::MissingVariableError)
6
+ proc { subject['card.input_type'] }.should_not raise_error(Rtml::Errors::MissingVariableError)
7
+ end
8
+ end
@@ -21,31 +21,32 @@ describe "routes" do
21
21
  end
22
22
  end
23
23
 
24
- context "with double connection" do
25
- before(:each) do
26
- ActionController::Routing::Routes.reload!
27
- ActionController::Routing::Routes.draw { |map| map.connect_rtml :controller => 'another' }
28
- end
29
-
30
- after(:each) do
31
- ActionController::Routing::Routes.reload!
32
- end
33
-
34
- # removed since it doesn't really matter in the long run -- this stuff all gets optimized by rails.
35
- # it "should not double connect generic routes" do
36
- # matches = []
37
- # ActionController::Routing::Routes.routes.each do |route|
38
- # matches.should_not include(route.segments.to_s)
39
- # matches << route.segments.to_s
40
- # end
24
+ # Turns out this was not possible, because Rails freezes the route objects.
25
+ # context "with double connection" do
26
+ # before(:each) do
27
+ # ActionController::Routing::Routes.reload!
28
+ # ActionController::Routing::Routes.draw { |map| map.connect_rtml :controller => 'another' }
41
29
  # end
42
-
43
- it "should update nongeneric routes" do
30
+ #
31
+ # after(:each) do
32
+ # ActionController::Routing::Routes.reload!
33
+ # end
34
+ #
35
+ # # removed since it doesn't really matter in the long run -- this stuff all gets optimized by rails.
36
+ ## it "should not double connect generic routes" do
37
+ ## matches = []
38
+ ## ActionController::Routing::Routes.routes.each do |route|
39
+ ## matches.should_not include(route.segments.to_s)
40
+ ## matches << route.segments.to_s
41
+ ## end
42
+ ## end
43
+ #
44
+ # it "should update nongeneric routes" do
44
45
  # route("/index.tml")[:controller].should == 'another'
45
- end
46
- end
46
+ # end
47
+ # end
47
48
 
48
49
  it "should match /index.tml" do
49
- route("/index.tml").should == { :controller => 'rtml', :action => 'index', :format => 'rtml' }
50
+ route("/index.tml").should == { :controller => 'inherited', :action => 'index', :format => 'rtml' }
50
51
  end
51
52
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rtml::Test::Simulator do
4
+ context "with a receipt" do
5
+ subject { Rtml::Test::Simulator.new(File.join(File.dirname(__FILE__), '../../../../support/raw_tml/receipt.tml')) }
6
+
7
+ it "should clear the receipt buffer" do
8
+ subject.press(:enter)
9
+ subject.receipt.clear
10
+ subject.receipt.should be_blank
11
+ end
12
+
13
+ it "should assign the printer output to the receipt" do
14
+ subject.press(:enter)
15
+ subject.receipt.strip.should == "<h1>This is printed content.</h1>"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,185 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rtml::Test::Simulator do
4
+ subject do
5
+ Rtml::Test::Simulator.new(File.join(File.dirname(__FILE__), '../../../support/raw_tml/enter_amount.tml'))
6
+ end
7
+
8
+ context "with AVS" do
9
+ subject { Rtml::Test::Simulator.new(File.join(File.dirname(__FILE__), '../../../support/raw_tml/avs.tml')) }
10
+
11
+ it "should load" do
12
+ subject
13
+ end
14
+ end
15
+
16
+ context "supplying input after execution has completed" do
17
+ subject { Rtml::Test::Simulator.new(File.join(File.dirname(__FILE__), '../../../support/raw_tml/empty_screen.tml'))}
18
+
19
+ it "should raise a comprehensible error" do
20
+ proc { subject.press(:enter) }.should raise_error(Rtml::Errors::ApplicationError)
21
+ end
22
+ end
23
+
24
+ it "should let you set HTTP headers" do
25
+ subject.header("ITID", '100')
26
+ subject.headers['ITID'].should == '100'
27
+ subject.should_receive(:get).with('/?ignore_state=true', {}, {'ITID' => '100'})
28
+ subject.visit("/")
29
+ end
30
+
31
+ it "should define state in the controller" do
32
+ subject.header("ITID", "100")
33
+ subject.visit("/rtml/index.rtml")
34
+ subject.response.template.controller.state.itid.should == '100'
35
+ end
36
+
37
+ context "with a reference to another document" do
38
+ subject do
39
+ Rtml::Test::Simulator.new(File.join(File.dirname(__FILE__), '../../../support/raw_tml/foreign_reference.tml'))
40
+ end
41
+
42
+ it "should catch :new_document and use it to make a new request" do
43
+ subject.press(:menu)
44
+ subject.current_screen_id.should == "main_menu"
45
+ end
46
+ end
47
+
48
+ context "with a reference to a TML variable" do
49
+ subject do
50
+ Rtml::Test::Simulator.new(File.join(File.dirname(__FILE__), '../../../support/raw_tml/tmlvar_reference.tml'))
51
+ end
52
+
53
+ it "should follow the reference" do
54
+ subject.press(:menu)
55
+ subject.current_screen_id.should == "main_menu"
56
+ end
57
+
58
+ context "in a submit attribute" do
59
+ subject do
60
+ Rtml::Test::Simulator.new(File.join(File.dirname(__FILE__), '../../../support/raw_tml/tmlvar_reference.tml'))
61
+ end
62
+
63
+ it "should follow the reference" do
64
+ subject.should_receive(:post_data).with("#submitted_to", {"value"=>nil})
65
+ subject.visit(:submit_scr)
66
+ end
67
+ end
68
+ end
69
+
70
+ context "with document level events" do
71
+ subject do
72
+ Rtml::Test::Simulator.new(File.join(File.dirname(__FILE__), '../../../support/raw_tml/document_level_events.tml'))
73
+ end
74
+
75
+ it "should process menu presses" do
76
+ subject.press(:menu)
77
+ subject.current_screen_id.should == 'on_menu'
78
+ end
79
+
80
+ it "should process cancel presses" do
81
+ subject.press(:cancel)
82
+ subject.current_screen_id.should == 'on_cancel'
83
+ end
84
+ end
85
+
86
+ it "should raise on document-level menu presses" do
87
+ subject.visit "#enter_amt"
88
+ proc { subject.press(:menu) }.should raise_error(Rtml::Errors::ApplicationError)
89
+ end
90
+
91
+ it "should raise on document-level cancel presses" do
92
+ subject.visit "#enter_amt"
93
+ proc { subject.press(:cancel) }.should raise_error(Rtml::Errors::ApplicationError)
94
+ end
95
+
96
+ it "should load a static TML file" do
97
+ subject
98
+ end
99
+
100
+ it "should be waiting for input" do
101
+ subject.current_screen_id.should == "idle"
102
+ subject.should be_waiting_for_input
103
+ end
104
+
105
+ it "should allow to fill in forms" do
106
+ subject.visit "#enter_amt"
107
+ subject.fill_in "payment.amount", '100'
108
+ subject.variables['payment.amount'].should == 100
109
+ end
110
+
111
+ it "should raise if form does not contain element for specified variable" do
112
+ subject.visit "#enter_amt"
113
+ proc { subject.fill_in "missing_field", '100' }.should raise_error(Rtml::Errors::SimulationError)
114
+ end
115
+
116
+ it "should allow to follow hyperlinks by inner text, case insensitive" do
117
+ subject.follow_link("make a payment")
118
+ subject.current_screen_id.should == "enter_amt"
119
+ end
120
+
121
+ it "should allow to follow hyperlinks by href" do
122
+ subject.follow_link("#enter_amt")
123
+ subject.current_screen_id.should == "enter_amt"
124
+ end
125
+
126
+ it "should raise if link is not found" do
127
+ proc { subject.follow_link("missing_link") }.should raise_error(Rtml::Errors::SimulationError)
128
+ end
129
+
130
+ it "should allow to press a key" do
131
+ subject.visit "#enter_amt"
132
+ subject.press("OK")
133
+ subject.current_screen_id.should_not == "#enter_amt"
134
+ end
135
+
136
+ it "should pause at card parsers" do
137
+ subject.visit "#enter_amt"
138
+ subject.press("OK")
139
+ subject.continue(:ignore_display => true)
140
+ subject.current_screen_id.should == "swipe"
141
+ end
142
+
143
+ context "at a screen with a properly configured card reader" do
144
+ before(:each) { subject.visit "#swipe" }
145
+ context "when :visa card is swiped" do
146
+ before(:each) { subject.swipe_card(:visa) }
147
+
148
+ it "should set variables" do
149
+ subject.variables['card.pan'].should == 4111111111111111
150
+ subject.variables['card.scheme'].should == 'VISA'
151
+ end
152
+
153
+ it "should continue execution" do
154
+ subject.current_screen_id.should_not == "swipe"
155
+ end
156
+ end
157
+ end
158
+
159
+ it "should not allow card swipes without properly configured card reader" do
160
+ subject.visit "#risk"
161
+ proc { subject.swipe_card(:visa) }.should raise_error(Rtml::Errors::SimulationError)
162
+ end
163
+
164
+ it "should raise if visiting a missing screen" do
165
+ proc { subject.visit "#missingscrn" }.should raise_error(Rtml::Errors::ApplicationError)
166
+ end
167
+
168
+ it "should not allow card swipes without card parsers" do
169
+ subject.visit "#enter_amt"
170
+ proc { subject.swipe_card(:visa) }.should raise_error(Rtml::Errors::SimulationError)
171
+ end
172
+
173
+ # this is really where Cucumber should start to come in handy.
174
+ context "after selecting 'make a payment'" do
175
+ before(:each) { subject.follow_link("Make a payment") }
176
+
177
+ context "after filling in 'amount' with '$1.00'" do
178
+ before(:each) { subject.fill_in "payment.amount", '100'; subject.press("OK") }
179
+
180
+ it "should display the amount" do
181
+ subject.current_screen.to_s.should match(/Amount Due:/)
182
+ end
183
+ end
184
+ end
185
+ end
@@ -0,0 +1,119 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rtml::Test::Simulator do
4
+ def tml_file(name)
5
+ name = "#{name}.tml" unless name[/\.tml$/]
6
+ File.read(File.join(File.dirname(__FILE__), '../../../support/raw_tml', name))
7
+ end
8
+
9
+ context "with a hello world app" do
10
+ subject { Rtml::Test::TmlApplication.new(tml_file("hello_world")) }
11
+
12
+ it "should have 2 screens" do
13
+ subject.screens.should have(2).elements
14
+ end
15
+
16
+ it "should start at the first screen in the document" do
17
+ subject.current_screen_id.should == "init"
18
+ end
19
+
20
+ it "should allow stepping through 1 screen at a time" do
21
+ subject.step
22
+ subject.current_screen_id.should == "idle"
23
+ end
24
+
25
+ it "should detect circular references and return :looping from #continue" do
26
+ subject.continue(:ignore_display => true).should == :looping
27
+ end
28
+
29
+ it "should detect circular references and wait at the end of the loop" do
30
+ subject.continue
31
+ # if it actually followed the directive, it'd be at #init again.
32
+ subject.current_screen_id.should == "idle"
33
+ end
34
+ end
35
+
36
+ context "testing variable processing" do
37
+ context "with a single operand" do
38
+ subject { Rtml::Test::TmlApplication.new(tml_file("one_screen_with_setvar")) }
39
+
40
+ before(:each) do
41
+ subject.continue
42
+ end
43
+
44
+ it "should have assigned a value" do
45
+ subject.variable_scope['payment.amount'].should == 100
46
+ end
47
+ end
48
+
49
+ context "within a loop" do
50
+ subject { Rtml::Test::TmlApplication.new(tml_file("loop_x_times")) }
51
+ before(:each) do
52
+ subject.continue
53
+ subject.variable_scope.update('target', 5)
54
+ subject.current_screen_id.should == "idle"
55
+ subject.step_forward
56
+ end
57
+
58
+ it "should complete with counter == 5" do
59
+ subject.continue(:complete)
60
+ subject.current_screen_id.should == "complete"
61
+ subject.variable_scope['counter'].should == 5
62
+ end
63
+ end
64
+ end
65
+
66
+ context "testing user input" do
67
+ subject { Rtml::Test::TmlApplication.new(tml_file("user_input")) }
68
+
69
+ context "via hotkeys" do
70
+ before(:each) { subject.jump_to_screen :hotkeys }
71
+
72
+ it "should start at the #hotkeys screen" do
73
+ subject.current_screen_id.should == "hotkeys"
74
+ end
75
+
76
+ it "should return :waiting from continue" do
77
+ subject.continue.should == :waiting
78
+ end
79
+ end
80
+
81
+ context "for screen level" do
82
+ context "menu and cancel" do
83
+ before(:each) { subject.jump_to_screen(:test_menu) }
84
+
85
+ it "should follow to #on_menu on menu press" do
86
+ subject.trigger_button_press(:menu)
87
+ subject.current_screen_id.should == "on_menu"
88
+ end
89
+
90
+ it "should follow to #on_cancel on cancel press" do
91
+ subject.trigger_button_press(:cancel)
92
+ subject.current_screen_id.should == "on_cancel"
93
+ end
94
+
95
+ it "should follow 1 to #main" do
96
+ subject.trigger_button_press(:cancel)
97
+ subject.trigger_button_press(1)
98
+ subject.current_screen_id.should == "main"
99
+ end
100
+ end
101
+ end
102
+
103
+ context "via hyperlinks" do
104
+ it "should pause at #main" do
105
+ subject.continue
106
+ subject.current_screen_id.should == "main"
107
+ end
108
+
109
+ it "should return :waiting when continuing into #main" do
110
+ subject.continue.should == :waiting
111
+ end
112
+
113
+ it "should return :waiting when stepping out of #main" do
114
+ subject.step # step out of #init
115
+ subject.step.should == :waiting # stepping out of #main
116
+ end
117
+ end
118
+ end
119
+ end