fortitude 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec-local +4 -0
- data/.travis.yml +26 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README-erector.md +246 -0
- data/README.md +15 -0
- data/Rakefile +67 -0
- data/ext/FortitudeJrubyNativeExtService.java +11 -0
- data/ext/com/fortituderuby/ext/fortitude/FortitudeNativeLibrary.java +223 -0
- data/ext/fortitude_native_ext/extconf.rb +4 -0
- data/ext/fortitude_native_ext/fortitude_native_ext.c +333 -0
- data/fortitude.gemspec +37 -0
- data/lib/fortitude/assign_locals_from_template.rb.smpl +22 -0
- data/lib/fortitude/assigns_proxy.rb +75 -0
- data/lib/fortitude/class_inheritable_attributes.rb +96 -0
- data/lib/fortitude/doctypes/base.rb +38 -0
- data/lib/fortitude/doctypes/html4.rb +20 -0
- data/lib/fortitude/doctypes/html4_frameset.rb +18 -0
- data/lib/fortitude/doctypes/html4_strict.rb +17 -0
- data/lib/fortitude/doctypes/html4_tags_frameset.rb +52 -0
- data/lib/fortitude/doctypes/html4_tags_strict.rb +273 -0
- data/lib/fortitude/doctypes/html4_tags_transitional.rb +114 -0
- data/lib/fortitude/doctypes/html4_transitional.rb +18 -0
- data/lib/fortitude/doctypes/html5.rb +372 -0
- data/lib/fortitude/doctypes/unknown_doctype.rb +19 -0
- data/lib/fortitude/doctypes/xhtml10.rb +19 -0
- data/lib/fortitude/doctypes/xhtml10_frameset.rb +17 -0
- data/lib/fortitude/doctypes/xhtml10_strict.rb +17 -0
- data/lib/fortitude/doctypes/xhtml10_transitional.rb +17 -0
- data/lib/fortitude/doctypes/xhtml11.rb +29 -0
- data/lib/fortitude/doctypes.rb +46 -0
- data/lib/fortitude/errors.rb +153 -0
- data/lib/fortitude/fortitude_ruby_ext.rb +71 -0
- data/lib/fortitude/instance_variable_set.rb +74 -0
- data/lib/fortitude/need_assignment_template.rb.smpl +16 -0
- data/lib/fortitude/need_method_template.rb.smpl +4 -0
- data/lib/fortitude/non_rails_widget_methods.rb +15 -0
- data/lib/fortitude/partial_tag_placeholder.rb +17 -0
- data/lib/fortitude/rails/helpers.rb +153 -0
- data/lib/fortitude/rails/renderer.rb +43 -0
- data/lib/fortitude/rails/template_handler.rb +23 -0
- data/lib/fortitude/rails/widget_methods.rb +17 -0
- data/lib/fortitude/rails/yielded_object_outputter.rb +31 -0
- data/lib/fortitude/railtie.rb +254 -0
- data/lib/fortitude/rendering_context.rb +205 -0
- data/lib/fortitude/simple_template.rb +45 -0
- data/lib/fortitude/staticized_method.rb +85 -0
- data/lib/fortitude/tag.rb +162 -0
- data/lib/fortitude/tag_method_template.rb.smpl +68 -0
- data/lib/fortitude/tag_return_value.rb +11 -0
- data/lib/fortitude/tag_store.rb +48 -0
- data/lib/fortitude/tag_support.rb +48 -0
- data/lib/fortitude/tags_module.rb +14 -0
- data/lib/fortitude/text_method_template.rb.smpl +17 -0
- data/lib/fortitude/tilt/fortitude_template.rb +169 -0
- data/lib/fortitude/version.rb +3 -0
- data/lib/fortitude/widget.rb +904 -0
- data/lib/fortitude/widgets/html4_frameset.rb +9 -0
- data/lib/fortitude/widgets/html4_strict.rb +9 -0
- data/lib/fortitude/widgets/html4_transitional.rb +9 -0
- data/lib/fortitude/widgets/html5.rb +9 -0
- data/lib/fortitude/widgets/xhtml10_frameset.rb +9 -0
- data/lib/fortitude/widgets/xhtml10_strict.rb +9 -0
- data/lib/fortitude/widgets/xhtml10_transitional.rb +9 -0
- data/lib/fortitude/widgets/xhtml11.rb +9 -0
- data/lib/fortitude.rb +93 -0
- data/lib/fortitude_jruby_native_ext.jar +0 -0
- data/spec/helpers/global_helper.rb +8 -0
- data/spec/helpers/rails_helpers.rb +85 -0
- data/spec/helpers/rails_server.rb +386 -0
- data/spec/helpers/system_helpers.rb +117 -0
- data/spec/rails/basic_rails_system_spec.rb +7 -0
- data/spec/rails/capture_system_spec.rb +75 -0
- data/spec/rails/class_loading_system_spec.rb +63 -0
- data/spec/rails/complex_helpers_system_spec.rb +33 -0
- data/spec/rails/data_passing_system_spec.rb +96 -0
- data/spec/rails/default_layout_system_spec.rb +15 -0
- data/spec/rails/development_mode_system_spec.rb +67 -0
- data/spec/rails/erb_integration_system_spec.rb +23 -0
- data/spec/rails/helpers_include_all_off_system_spec.rb +7 -0
- data/spec/rails/helpers_system_spec.rb +79 -0
- data/spec/rails/helpers_unrefined_system_spec.rb +7 -0
- data/spec/rails/layouts_system_spec.rb +60 -0
- data/spec/rails/localization_system_spec.rb +38 -0
- data/spec/rails/production_mode_system_spec.rb +13 -0
- data/spec/rails/rendering_context_system_spec.rb +64 -0
- data/spec/rails/rendering_system_spec.rb +158 -0
- data/spec/rails/rules_system_spec.rb +23 -0
- data/spec/rails/static_method_system_spec.rb +12 -0
- data/spec/rails/templates/base/app/controllers/application_controller.rb +15 -0
- data/spec/rails/templates/base/app/controllers/working_controller.rb +5 -0
- data/spec/rails/templates/base/app/views/layouts/application.html.erb +11 -0
- data/spec/rails/templates/base/config/routes.rb +4 -0
- data/spec/rails/templates/base/config/secrets.yml +22 -0
- data/spec/rails/templates/basic_rails_system_spec/app/controllers/basic_rails_system_spec_controller.rb +8 -0
- data/spec/rails/templates/basic_rails_system_spec/app/views/basic_rails_system_spec/trivial_widget.rb +5 -0
- data/spec/rails/templates/capture_system_spec/app/controllers/capture_system_spec_controller.rb +37 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/_some_erb_partial.html.erb +1 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/another_widget.rb +7 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/capture_erb_from_widget.rb +11 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/capture_widget_from_erb.html.erb +9 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/capture_widget_from_widget.rb +17 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/some_widget.rb +5 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/widget_content_for.rb +19 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/widget_layout_needing_content_yield_with_erb.html.erb +13 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/widget_provide.rb +13 -0
- data/spec/rails/templates/capture_system_spec/app/views/layouts/erb_layout_needing_content.html.erb +15 -0
- data/spec/rails/templates/capture_system_spec/app/views/layouts/widget_layout_needing_content_content_for.rb +23 -0
- data/spec/rails/templates/capture_system_spec/app/views/layouts/widget_layout_needing_content_yield.rb +23 -0
- data/spec/rails/templates/class_loading_system_spec/app/controllers/class_loading_system_spec_controller.rb +74 -0
- data/spec/rails/templates/class_loading_system_spec/app/models/views/app_models_helper.rb +5 -0
- data/spec/rails/templates/class_loading_system_spec/app/models/views/models_widget.rb +5 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/autoload_namespace/autoload_widget.rb +11 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/_loaded_underscore_widget.rb +11 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/_underscore_view.rb +5 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/_underscore_widget.rb +11 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/app_models.rb +6 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/autoload_one_widget_from_another.rb +7 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/class_should_not_load.rb +9 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/lib_views.rb +8 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/use_lib_widget_from_view_widget.rb +9 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/use_models_widget_from_view_widget.rb +7 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/some_namespace/some_other_namespace/.git_keep +0 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/sub_widget.rb +5 -0
- data/spec/rails/templates/class_loading_system_spec/lib/arbitrary_name/some_widget.rb +7 -0
- data/spec/rails/templates/class_loading_system_spec/lib/views/class_loading_system_spec/lib_views_helper.rb +5 -0
- data/spec/rails/templates/class_loading_system_spec/lib/views/class_loading_system_spec/widget_defined_outside_app_views.rb +5 -0
- data/spec/rails/templates/class_loading_system_spec/lib/views/lib_widget.rb +5 -0
- data/spec/rails/templates/complex_helpers_system_spec/app/controllers/complex_helpers_system_spec_controller.rb +14 -0
- data/spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/cache_test.rb +12 -0
- data/spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/fields_for_test.rb +14 -0
- data/spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/form_for_test.rb +14 -0
- data/spec/rails/templates/complex_helpers_system_spec/config/environments/development.rb +31 -0
- data/spec/rails/templates/data_passing_system_spec/app/controllers/data_passing_system_spec_controller.rb +101 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/_erb_to_parallel_widget_handoff_erb.html.erb +3 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/_implicit_erb_to_widget_handoff_erb.html.erb +3 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/_implicit_variable_write_erb.html.erb +1 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/_widget_to_parallel_erb_handoff_erb.html.erb +1 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/erb_copied_variables.html.erb +1 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/erb_to_parallel_widget_handoff.html.erb +2 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/erb_to_parallel_widget_handoff_widget.rb +5 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/explicit_controller_variable_read.rb +6 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/extra_variables.rb +23 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/extra_variables_requested.rb +24 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_erb_to_widget_handoff.html.erb +2 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_erb_to_widget_handoff_widget.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_shared_variable_access.rb +5 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_shared_variable_access_inheritance.rb +6 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_shared_variable_access_inheritance_child_one.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_shared_variable_access_inheritance_child_two.rb +5 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_shared_variable_access_inheritance_parent.rb +3 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_shared_variable_access_inner.rb +8 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_variable_read.rb +5 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_variable_read_inner.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_variable_write.html.erb +2 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_variable_write_widget.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/parent_to_child_passing.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/parent_to_child_passing_child.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/parent_to_child_passing_partial.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/parent_to_child_passing_partial_child.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/passing_data_widget.rb +8 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/passing_locals_and_controller_variables_widget.rb +9 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/passing_locals_widget.rb +8 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/variables_to_layout.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/widget_copied_variables.rb +9 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/widget_to_parallel_erb_handoff.html.erb +2 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/widget_to_parallel_erb_handoff_widget.rb +5 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/layouts/data_layout.rb +14 -0
- data/spec/rails/templates/default_layout_system_spec/app/controllers/default_layout_system_spec_controller.rb +9 -0
- data/spec/rails/templates/default_layout_system_spec/app/views/default_layout_system_spec/erb_with_widget_default_layout.html.erb +1 -0
- data/spec/rails/templates/default_layout_system_spec/app/views/default_layout_system_spec/widget_with_widget_default_layout.rb +5 -0
- data/spec/rails/templates/default_layout_system_spec/app/views/layouts/application.rb +12 -0
- data/spec/rails/templates/development_mode_system_spec/app/controllers/development_mode_system_spec_controller.rb +9 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_system_spec/reload_widget.rb +7 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_system_spec/sample_output.rb +9 -0
- data/spec/rails/templates/erb_integration_system_spec/app/controllers/erb_integration_system_spec_controller.rb +10 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/_erb_partial_from_widget_partial.html.erb +1 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/_fortitude_partial_with_underscore_partial.rb +5 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/_prefers_erb_partial_partial.html.erb +1 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/erb_partial_from_widget.rb +7 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/erb_to_widget_with_render_partial.html.erb +3 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/erb_to_widget_with_render_partial_widget.rb +5 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/fortitude_partial_with_underscore.html.erb +3 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/prefers_erb_partial.html.erb +3 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/prefers_erb_partial_partial.rb +5 -0
- data/spec/rails/templates/helpers_include_all_off_system_spec/app/controllers/helpers_include_all_off_system_spec_controller.rb +13 -0
- data/spec/rails/templates/helpers_include_all_off_system_spec/app/helpers/application_helper.rb +5 -0
- data/spec/rails/templates/helpers_include_all_off_system_spec/app/helpers/some_helper.rb +5 -0
- data/spec/rails/templates/helpers_include_all_off_system_spec/app/views/helpers_include_all_off_system_spec/include_all_off.rb +23 -0
- data/spec/rails/templates/helpers_include_all_off_system_spec/config/application.rb +28 -0
- data/spec/rails/templates/helpers_system_spec/app/controllers/helpers_system_spec_controller.rb +86 -0
- data/spec/rails/templates/helpers_system_spec/app/helpers/some_helper.rb +21 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/automatic_helpers_disabled.rb +37 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/automatic_helpers_inheritance.rb +6 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/automatic_helpers_inheritance_child_one.rb +34 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/automatic_helpers_inheritance_child_two.rb +36 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/automatic_helpers_inheritance_parent.rb +4 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/basic_helpers.rb +13 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/block_helpers.rb +7 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/built_in_outputting_helpers.rb +13 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/built_in_outputting_to_returning.rb +8 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/built_in_returning_to_outputting.rb +10 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/controller_helper_method.rb +5 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/controller_helper_module.rb +5 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/custom_helper_outputs.rb +6 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/custom_helpers_basic.rb +5 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/custom_helpers_with_a_block.rb +6 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/custom_outputting_to_returning.rb +7 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/custom_returning_to_outputting.rb +10 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/helper_settings_inheritance.rb +10 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/helper_settings_inheritance_parent.rb +4 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/helpers_that_output_when_refined.rb +9 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/private_helper_erb.html.erb +1 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/private_helper_fortitude.rb +5 -0
- data/spec/rails/templates/helpers_system_spec/lib/some_stuff.rb +5 -0
- data/spec/rails/templates/helpers_unrefined_system_spec/app/controllers/helpers_unrefined_system_spec_controller.rb +7 -0
- data/spec/rails/templates/helpers_unrefined_system_spec/app/views/helpers_unrefined_system_spec/helpers_that_output_when_refined.rb +9 -0
- data/spec/rails/templates/helpers_unrefined_system_spec/config/environments/production.rb +31 -0
- data/spec/rails/templates/layouts_system_spec/app/controllers/layouts_system_spec_controller.rb +31 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts/alternate.html.erb +11 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts/application.html.erb +26 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts/explicit_yield.rb +12 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts/widget_layout.rb +22 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts_system_spec/erb_inside_widget_layout.html.erb +8 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts_system_spec/the_render_widget.rb +5 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts_system_spec/widget_inside_erb_layout.rb +8 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts_system_spec/widget_inside_widget_layout.rb +8 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts_system_spec/yield_from_widget_explicitly.rb +5 -0
- data/spec/rails/templates/localization_system_spec/app/controllers/localization_system_spec_controller.rb +31 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/content_method.rb +13 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/dot_notation.rb +5 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/explicit_html.rb +13 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/i18n_t.rb +5 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/native_support.rb +7 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/readjust_base.rb +7 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/t.rb +5 -0
- data/spec/rails/templates/localization_system_spec/config/locales/en.yml +21 -0
- data/spec/rails/templates/localization_system_spec/config/locales/fr.yml +14 -0
- data/spec/rails/templates/localization_system_spec/config/locales/pt.yml +2 -0
- data/spec/rails/templates/production_mode_system_spec/app/controllers/production_mode_system_spec_controller.rb +5 -0
- data/spec/rails/templates/production_mode_system_spec/app/views/production_mode_system_spec/sample_output.rb +9 -0
- data/spec/rails/templates/rendering_context_system_spec/app/controllers/rendering_context_system_spec_controller.rb +72 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/_start_end_widget_through_partials_partial.html.erb +1 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/_uses_direct_context_for_all_widgets_partial.html.erb +1 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/_uses_specified_context_through_nesting_partial.html.erb +2 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/render_widget.rb +5 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/start_end_widget_basic.rb +12 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/start_end_widget_basic_inner.rb +7 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/start_end_widget_through_partials.rb +16 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/start_end_widget_through_partials_partial_widget.rb +7 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_direct_context_for_all_widgets.rb +7 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_direct_context_for_all_widgets_widget.rb +5 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_direct_context_in_view.rb +5 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_specified_context_in_partials.html.erb +3 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_specified_context_in_partials_partial.rb +5 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_specified_context_in_view.rb +5 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_specified_context_through_nesting.rb +6 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_specified_context_through_nesting_inner_partial.rb +5 -0
- data/spec/rails/templates/rendering_context_system_spec/lib/simple_rc.rb +17 -0
- data/spec/rails/templates/rendering_system_spec/app/controllers/rendering_system_spec_controller.rb +111 -0
- data/spec/rails/templates/rendering_system_spec/app/views/layouts/application.html.erb +19 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/_layout_for_partial.html.erb +3 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/_the_partial.html.erb +1 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/partial_with_layout.rb +5 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_collection.html.erb +3 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_collection_as.html.erb +3 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_file_from_widget.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_html_safe_strings.rb +16 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_inline_from_widget.rb +11 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_object.html.erb +3 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_partial_from_widget.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_partial_with_layout.html.erb +3 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_partial_with_widget_layout.html.erb +3 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_template_from_widget.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_text_from_widget.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/stream_widget.rb +13 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/trivial_widget.rb +5 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/widget_layout_for_partial.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/widget_with_name.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/word.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/widget_to_render.rb +7 -0
- data/spec/rails/templates/rules_system_spec/app/controllers/rules_system_spec_controller.rb +22 -0
- data/spec/rails/templates/rules_system_spec/app/views/layouts/fortitude_layout_with_p.rb +19 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/_intervening_partial_erb_partial.html.erb +1 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/intervening_partial.rb +9 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/intervening_partial_fortitude_partial.rb +9 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/invalid_start_tag_in_partial.html.erb +3 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/invalid_start_tag_in_partial_partial.rb +9 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/invalid_start_tag_in_view.rb +9 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/invalidly_nested_tag.rb +11 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/invalidly_nested_tag_in_partial.html.erb +3 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/invalidly_nested_tag_in_partial_partial.rb +11 -0
- data/spec/rails/templates/static_method_system_spec/app/controllers/static_method_system_spec_controller.rb +15 -0
- data/spec/rails/templates/static_method_system_spec/app/helpers/some_helper.rb +10 -0
- data/spec/rails/templates/static_method_system_spec/app/views/static_method_system_spec/allows_helper_access.rb +8 -0
- data/spec/rails/templates/static_method_system_spec/app/views/static_method_system_spec/localization.rb +7 -0
- data/spec/rails/templates/static_method_system_spec/config/locales/en.yml +4 -0
- data/spec/rails/templates/static_method_system_spec/config/locales/fr.yml +4 -0
- data/spec/system/around_content_system_spec.rb +399 -0
- data/spec/system/assigns_system_spec.rb +316 -0
- data/spec/system/attribute_rules_system_spec.rb +227 -0
- data/spec/system/basic_system_spec.rb +9 -0
- data/spec/system/content_inheritance_system_spec.rb +13 -0
- data/spec/system/convenience_methods_system_spec.rb +30 -0
- data/spec/system/doctypes_system_spec.rb +213 -0
- data/spec/system/erector_compatibility_system_spec.rb +84 -0
- data/spec/system/escaping_system_spec.rb +43 -0
- data/spec/system/formatting_system_spec.rb +63 -0
- data/spec/system/helpers_system_spec.rb +235 -0
- data/spec/system/id_uniqueness_system_spec.rb +205 -0
- data/spec/system/localization_system_spec.rb +94 -0
- data/spec/system/method_precedence_system_spec.rb +48 -0
- data/spec/system/needs_system_spec.rb +368 -0
- data/spec/system/other_outputters_system_spec.rb +117 -0
- data/spec/system/rails_not_available_spec.rb +11 -0
- data/spec/system/rebuild_notifications_system_spec.rb +208 -0
- data/spec/system/rendering_context_system_spec.rb +83 -0
- data/spec/system/setting_inheritance_system_spec.rb +585 -0
- data/spec/system/shared_variable_system_spec.rb +120 -0
- data/spec/system/start_end_comments_system_spec.rb +363 -0
- data/spec/system/static_method_system_spec.rb +348 -0
- data/spec/system/tag_rendering_system_spec.rb +253 -0
- data/spec/system/tag_return_value_system_spec.rb +41 -0
- data/spec/system/tag_rules_system_spec.rb +196 -0
- data/spec/system/tag_updating_system_spec.rb +171 -0
- data/spec/system/tilt_system_spec.rb +378 -0
- data/spec/system/unparsed_data_system_spec.rb +16 -0
- data/spec/system/void_tags_system_spec.rb +51 -0
- data/spec/system/widget_return_values_system_spec.rb +89 -0
- metadata +736 -0
@@ -0,0 +1,378 @@
|
|
1
|
+
require "tilt"
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
describe "Fortitude Tilt integration", :type => :system do
|
5
|
+
def tempdir
|
6
|
+
@tempdir ||= begin
|
7
|
+
out = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'tmp', 'spec', 'tilt_system_spec')
|
8
|
+
FileUtils.rm_rf(out)
|
9
|
+
FileUtils.mkdir_p(out)
|
10
|
+
out
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def splat!(filename, text)
|
15
|
+
full_path = File.join(tempdir, filename)
|
16
|
+
FileUtils.mkdir_p(File.dirname(full_path))
|
17
|
+
File.open(full_path, 'w') { |f| f << text }
|
18
|
+
full_path
|
19
|
+
end
|
20
|
+
|
21
|
+
def render_with_tilt(full_path, evaluation_scope = context_object, variables = { }, options = { }, &block)
|
22
|
+
template = Tilt.new(full_path, options)
|
23
|
+
template.render(evaluation_scope, variables, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
def render_text_with_tilt(filename, text, evaluation_scope = context_object, variables = { }, options = { }, &block)
|
27
|
+
full_path = splat!(filename, text)
|
28
|
+
render_with_tilt(full_path, evaluation_scope, variables, options, &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should render a very simple template via Tilt" do
|
32
|
+
text = <<-EOS
|
33
|
+
class SimpleTemplate < Fortitude::Widgets::Html5
|
34
|
+
def content
|
35
|
+
text "this is"
|
36
|
+
p "a simple widget"
|
37
|
+
text "!"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
EOS
|
41
|
+
|
42
|
+
expect(render_text_with_tilt("simple_template.rb", text)).to eq("this is<p>a simple widget</p>!")
|
43
|
+
end
|
44
|
+
|
45
|
+
SIMPLE_TEMPLATE_WITH_VARIABLES = <<-EOS
|
46
|
+
class SimpleTemplateWithVariables < Fortitude::Widgets::Html5
|
47
|
+
needs :foo, :bar => 'whatever'
|
48
|
+
|
49
|
+
def content
|
50
|
+
text "foo: \#{foo}, bar: \#{bar}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
EOS
|
54
|
+
|
55
|
+
SIMPLE_TEMPLATE_WITH_VARIABLES_NO_EXTRA_ASSIGNS = <<-EOS
|
56
|
+
class SimpleTemplateWithVariablesNoExtraAssigns < Fortitude::Widgets::Html5
|
57
|
+
extra_assigns :error
|
58
|
+
needs :foo, :bar => 'whatever'
|
59
|
+
|
60
|
+
def content
|
61
|
+
text "foo: \#{foo}, bar: \#{bar}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
EOS
|
65
|
+
|
66
|
+
SIMPLE_TEMPLATE_WITH_VARIABLES_WANTS_EXTRA_ASSIGNS = <<-EOS
|
67
|
+
class SimpleTemplateWithVariablesWantsExtraAssigns < Fortitude::Widgets::Html5
|
68
|
+
extra_assigns :use
|
69
|
+
needs :foo, :bar => 'whatever'
|
70
|
+
|
71
|
+
def content
|
72
|
+
text "foo: \#{foo}, bar: \#{bar}, baz: \#{assigns[:baz] || 'nil'}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
EOS
|
76
|
+
|
77
|
+
it "should pass explicit locals to the template" do
|
78
|
+
result = render_text_with_tilt("simple_template_with_variables.rb", SIMPLE_TEMPLATE_WITH_VARIABLES, context_object, { :foo => 'the_foo', :bar => 'the_bar' })
|
79
|
+
expect(result).to eq("foo: the_foo, bar: the_bar")
|
80
|
+
end
|
81
|
+
|
82
|
+
def context_object(variable_mappings = { }, klass = Object.class, &block)
|
83
|
+
out = klass.new
|
84
|
+
variable_mappings.each do |name, value|
|
85
|
+
out.instance_variable_set("@#{name}", value)
|
86
|
+
end
|
87
|
+
out.instance_eval(&block) if block
|
88
|
+
out
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should make variables defined on the context object available to the template as needs" do
|
92
|
+
co = context_object(:foo => 'the_foo', :bar => 'the_bar')
|
93
|
+
|
94
|
+
result = render_text_with_tilt("simple_template_with_variables.rb", SIMPLE_TEMPLATE_WITH_VARIABLES, co, { })
|
95
|
+
expect(result).to eq("foo: the_foo, bar: the_bar")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should allow passing locals as strings, and overriding context-object variables" do
|
99
|
+
co = context_object(:foo => 'co_foo', :bar => 'co_bar')
|
100
|
+
result = render_text_with_tilt("simple_template_with_variables.rb", SIMPLE_TEMPLATE_WITH_VARIABLES, co, { 'bar' => 'local_bar' })
|
101
|
+
expect(result).to eq("foo: co_foo, bar: local_bar")
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should allow passing locals as symbols, and overriding context-object variables" do
|
105
|
+
co = context_object(:foo => 'co_foo', :bar => 'co_bar')
|
106
|
+
result = render_text_with_tilt("simple_template_with_variables.rb", SIMPLE_TEMPLATE_WITH_VARIABLES, co, { :bar => 'local_bar' })
|
107
|
+
expect(result).to eq("foo: co_foo, bar: local_bar")
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should ignore passed locals that the template doesn't actually need" do
|
111
|
+
result = render_text_with_tilt("simple_template_with_variables_no_extra_assigns.rb", SIMPLE_TEMPLATE_WITH_VARIABLES_NO_EXTRA_ASSIGNS,
|
112
|
+
context_object, { :foo => 'the_foo', :baz => 'baz!'})
|
113
|
+
expect(result).to eq("foo: the_foo, bar: whatever")
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should pass extra locals if the template wants extra assigns" do
|
117
|
+
result = render_text_with_tilt("simple_template_with_variables_wants_extra_assigns.rb", SIMPLE_TEMPLATE_WITH_VARIABLES_WANTS_EXTRA_ASSIGNS,
|
118
|
+
context_object, { :foo => 'the_foo', :baz => 'baz!'})
|
119
|
+
expect(result).to eq("foo: the_foo, bar: whatever, baz: baz!")
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should ignore context-object instance variables that the template doesn't actually need" do
|
123
|
+
result = render_text_with_tilt("simple_template_with_variables_no_extra_assigns.rb", SIMPLE_TEMPLATE_WITH_VARIABLES_NO_EXTRA_ASSIGNS,
|
124
|
+
context_object(:foo => 'the_foo', :baz => 'baz!'), { })
|
125
|
+
expect(result).to eq("foo: the_foo, bar: whatever")
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should pass extra context-object instance variables if the template wants extra assigns" do
|
129
|
+
result = render_text_with_tilt("simple_template_with_variables_wants_extra_assigns.rb", SIMPLE_TEMPLATE_WITH_VARIABLES_WANTS_EXTRA_ASSIGNS,
|
130
|
+
context_object(:foo => 'the_foo', :baz => 'baz!'), { })
|
131
|
+
expect(result).to eq("foo: the_foo, bar: whatever, baz: baz!")
|
132
|
+
end
|
133
|
+
|
134
|
+
SHARED_VARIABLE_ACCESS = <<-EOS
|
135
|
+
class SharedVariableAccess < Fortitude::Widgets::Html5
|
136
|
+
def content
|
137
|
+
data = shared_variables[:foo]
|
138
|
+
text "foo is: \#{data}"
|
139
|
+
shared_variables[:foo] = 'new_foo'
|
140
|
+
end
|
141
|
+
end
|
142
|
+
EOS
|
143
|
+
|
144
|
+
it "should allow instance variables on the context object to be accessed via #shared_variables" do
|
145
|
+
co = context_object(:foo => 'the_foo')
|
146
|
+
result = render_text_with_tilt("shared_variable_access.rb", SHARED_VARIABLE_ACCESS, co, { })
|
147
|
+
expect(result).to eq("foo is: the_foo")
|
148
|
+
expect(co.instance_variable_get("@foo")).to eq("new_foo")
|
149
|
+
end
|
150
|
+
|
151
|
+
IMPLICIT_SHARED_VARIABLE_ACCESS = <<-EOS
|
152
|
+
class ImplicitSharedVariableAccess < Fortitude::Widgets::Html5
|
153
|
+
implicit_shared_variable_access true
|
154
|
+
def content
|
155
|
+
text "foo is: \#{@foo}"
|
156
|
+
@foo = "new_foo"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
EOS
|
160
|
+
|
161
|
+
it "should allow instance variables on the context object to be read and written implicitly if implicit_shared_variable_access is set" do
|
162
|
+
co = context_object(:foo => 'the_foo')
|
163
|
+
result = render_text_with_tilt("implicit_shared_variable_access.rb", IMPLICIT_SHARED_VARIABLE_ACCESS, co, { })
|
164
|
+
expect(result).to eq("foo is: the_foo")
|
165
|
+
expect(co.instance_variable_get("@foo")).to eq("new_foo")
|
166
|
+
end
|
167
|
+
|
168
|
+
WIDGET_WITH_BLOCK = <<-EOS
|
169
|
+
class WidgetWithBlock < Fortitude::Widgets::Html5
|
170
|
+
def content
|
171
|
+
data = yield("foo")
|
172
|
+
text "data is: \#{data}"
|
173
|
+
end
|
174
|
+
end
|
175
|
+
EOS
|
176
|
+
|
177
|
+
it "should forward the passed block to the widget" do
|
178
|
+
result = render_text_with_tilt("widget_with_block.rb", WIDGET_WITH_BLOCK,
|
179
|
+
context_object, { }) { |a| "xx#{a}yy" }
|
180
|
+
expect(result).to eq("data is: xxfooyy")
|
181
|
+
end
|
182
|
+
|
183
|
+
WIDGET_CALLING_FOO = <<-EOS
|
184
|
+
class WidgetCallingFoo < Fortitude::Widgets::Html5
|
185
|
+
def content
|
186
|
+
val = foo("xxx")
|
187
|
+
text "val is: \#{val}"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
EOS
|
191
|
+
|
192
|
+
it "should allow helpers defined on the context object to be invoked via automatic helper support" do
|
193
|
+
co = context_object do
|
194
|
+
def foo(x)
|
195
|
+
"foo#{x}foo"
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
result = render_text_with_tilt("widget_calling_foo.rb", WIDGET_CALLING_FOO, co, { })
|
200
|
+
expect(result).to eq("val is: fooxxxfoo")
|
201
|
+
end
|
202
|
+
|
203
|
+
WIDGET_CALLING_FOO_AHA_OFF = <<-EOS
|
204
|
+
class WidgetCallingFooAhaOff < Fortitude::Widgets::Html5
|
205
|
+
automatic_helper_access false
|
206
|
+
|
207
|
+
def content
|
208
|
+
val = invoke_helper(:foo, "yyy")
|
209
|
+
text "val is: \#{val}"
|
210
|
+
end
|
211
|
+
end
|
212
|
+
EOS
|
213
|
+
|
214
|
+
it "should allow helpers defined on the context object to be invoked via explicit helper support" do
|
215
|
+
co = context_object do
|
216
|
+
def foo(x)
|
217
|
+
"foo#{x}foo"
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
result = render_text_with_tilt("widget_calling_foo_aha_off.rb", WIDGET_CALLING_FOO_AHA_OFF, co, { })
|
222
|
+
expect(result).to eq("val is: fooyyyfoo")
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should not require the class name to match the filename of the widget at all" do
|
226
|
+
result = render_text_with_tilt("foo_bar.rb", SIMPLE_TEMPLATE_WITH_VARIABLES, context_object, { :foo => 'the_foo', :bar => 'the_bar' })
|
227
|
+
expect(result).to eq("foo: the_foo, bar: the_bar")
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should still render a widget that's directly in a module (class Foo::Bar::Baz < Fortitude::Widget)" do
|
231
|
+
eval("module Spec1; module Bar; end; end")
|
232
|
+
|
233
|
+
text = <<-EOS
|
234
|
+
class Spec1::Bar::Baz < Fortitude::Widgets::Html5
|
235
|
+
def content
|
236
|
+
text "hello from spec1"
|
237
|
+
end
|
238
|
+
end
|
239
|
+
EOS
|
240
|
+
|
241
|
+
expect(render_text_with_tilt("random_#{rand(1_000_000)}.rb", text, context_object, { })).to eq("hello from spec1")
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should still render a widget that's directly in a module, of a subclass of Widget (class Foo::Bar::Baz < MyWidget)" do
|
245
|
+
eval("module Spec2; module Bar; end; end")
|
246
|
+
eval("class Spec2::Spec2Superclass < Fortitude::Widgets::Html5; end")
|
247
|
+
|
248
|
+
text = <<-EOS
|
249
|
+
class Spec2::Bar::Baz < Spec2::Spec2Superclass
|
250
|
+
def content
|
251
|
+
text "hello from spec2"
|
252
|
+
end
|
253
|
+
end
|
254
|
+
EOS
|
255
|
+
|
256
|
+
expect(render_text_with_tilt("random_#{rand(1_000_000)}.rb", text, context_object, { })).to eq("hello from spec2")
|
257
|
+
end
|
258
|
+
|
259
|
+
it "should still render a widget that's in a module via namespace nesting (module Foo; module Bar; Baz < Fortitude::Widget)" do
|
260
|
+
text = <<-EOS
|
261
|
+
module Spec3
|
262
|
+
module Bar
|
263
|
+
class Baz < Fortitude::Widgets::Html5
|
264
|
+
def content
|
265
|
+
text "hello from spec3"
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
EOS
|
271
|
+
|
272
|
+
expect(render_text_with_tilt("random_#{rand(1_000_000)}.rb", text, context_object, { })).to eq("hello from spec3")
|
273
|
+
end
|
274
|
+
|
275
|
+
it "should still render a widget that's in a module via namespace nesting, of a subclass of Widget (module Foo; module Bar; Baz < MyWidget)" do
|
276
|
+
eval("module Spec4; class Spec4Superclass < Fortitude::Widgets::Html5; end; end")
|
277
|
+
|
278
|
+
text = <<-EOS
|
279
|
+
module Spec4
|
280
|
+
module Bar
|
281
|
+
class Baz < Fortitude::Widgets::Html5
|
282
|
+
def content
|
283
|
+
text "hello from spec4"
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
EOS
|
289
|
+
|
290
|
+
expect(render_text_with_tilt("random_#{rand(1_000_000)}.rb", text, context_object, { })).to eq("hello from spec4")
|
291
|
+
end
|
292
|
+
|
293
|
+
def impossible_to_find_class_name_text(num, insert="")
|
294
|
+
text = <<-EOS
|
295
|
+
klass_name = "Spec#{num}" + "TheClass"
|
296
|
+
c = Class.new(Fortitude::Widgets::Html5) do
|
297
|
+
#{insert}
|
298
|
+
def content
|
299
|
+
text "hello from spec#{num}"
|
300
|
+
end
|
301
|
+
end
|
302
|
+
::Object.const_set(klass_name, c)
|
303
|
+
EOS
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should fail with a nice message if it can't figure out which class to render" do
|
307
|
+
e = capture_exception(Fortitude::Tilt::CannotDetermineTemplateClassError) do
|
308
|
+
render_text_with_tilt("random_#{rand(1_000_000)}.rb", impossible_to_find_class_name_text(5), context_object, { })
|
309
|
+
end
|
310
|
+
|
311
|
+
expect(e).to be
|
312
|
+
expect(e.tried_class_names).to eq([ ])
|
313
|
+
expect(e.message).to match(/\#\!fortitude_tilt_class/)
|
314
|
+
expect(e.message).to match(/:fortitude_class/)
|
315
|
+
end
|
316
|
+
|
317
|
+
it "should allow overriding the class that's defined in the module explicitly with an option" do
|
318
|
+
result = render_text_with_tilt("random_#{rand(1_000_000)}.rb", impossible_to_find_class_name_text(6), context_object, { },
|
319
|
+
{ :fortitude_class => "Spec6TheClass" })
|
320
|
+
expect(result).to eq("hello from spec6")
|
321
|
+
end
|
322
|
+
|
323
|
+
it "should fail with a nice message if you tell it to use something that doesn't exist, using an option" do
|
324
|
+
e = capture_exception(Fortitude::Tilt::NotATemplateClassError) do
|
325
|
+
render_text_with_tilt("random_#{rand(1_000_000)}.rb", impossible_to_find_class_name_text(7), context_object, { },
|
326
|
+
{ :fortitude_class => "NonExistent" })
|
327
|
+
end
|
328
|
+
expect(e.class_name).to eq("NonExistent")
|
329
|
+
expect(e.actual_object).to be_nil
|
330
|
+
expect(e.message).to match(/NonExistent/)
|
331
|
+
end
|
332
|
+
|
333
|
+
it "should fail with a nice message if you tell it to use something that isn't a class, using an option" do
|
334
|
+
e = capture_exception(Fortitude::Tilt::NotATemplateClassError) do
|
335
|
+
render_text_with_tilt("random_#{rand(1_000_000)}.rb", impossible_to_find_class_name_text(8), context_object, { },
|
336
|
+
{ :fortitude_class => 12345 })
|
337
|
+
end
|
338
|
+
expect(e.class_name).to eq(12345)
|
339
|
+
expect(e.actual_object).to eq(12345)
|
340
|
+
expect(e.message).to match(/12345/)
|
341
|
+
end
|
342
|
+
|
343
|
+
it "should fail with a nice message if you tell it to use something that isn't a widget class, using an option" do
|
344
|
+
e = capture_exception(Fortitude::Tilt::NotATemplateClassError) do
|
345
|
+
render_text_with_tilt("random_#{rand(1_000_000)}.rb", impossible_to_find_class_name_text(9), context_object, { },
|
346
|
+
{ :fortitude_class => "String" })
|
347
|
+
end
|
348
|
+
expect(e.class_name).to eq("String")
|
349
|
+
expect(e.actual_object).to eq(String)
|
350
|
+
expect(e.message).to match(/String/)
|
351
|
+
end
|
352
|
+
|
353
|
+
it "should allow overriding the class that's defined in the module explicitly with a comment in the template" do
|
354
|
+
result = render_text_with_tilt("random_#{rand(1_000_000)}.rb",
|
355
|
+
impossible_to_find_class_name_text(10, "#!fortitude_tilt_class: Spec10TheClass"), context_object, { })
|
356
|
+
expect(result).to eq("hello from spec10")
|
357
|
+
end
|
358
|
+
|
359
|
+
it "should fail with a nice message if you tell it to use something that isn't a class, using a comment in the template" do
|
360
|
+
e = capture_exception(Fortitude::Tilt::NotATemplateClassError) do
|
361
|
+
render_text_with_tilt("random_#{rand(1_000_000)}.rb",
|
362
|
+
impossible_to_find_class_name_text(11, "#!fortitude_tilt_class: 12345"), context_object, { })
|
363
|
+
end
|
364
|
+
expect(e.class_name).to eq("12345")
|
365
|
+
expect(e.actual_object).to be_nil
|
366
|
+
expect(e.message).to match(/12345/)
|
367
|
+
end
|
368
|
+
|
369
|
+
it "should fail with a nice message if you tell it to use something that isn't a widget class, using a comment in the template" do
|
370
|
+
e = capture_exception(Fortitude::Tilt::NotATemplateClassError) do
|
371
|
+
render_text_with_tilt("random_#{rand(1_000_000)}.rb",
|
372
|
+
impossible_to_find_class_name_text(12, "#!fortitude_tilt_class: String"), context_object, { })
|
373
|
+
end
|
374
|
+
expect(e.class_name).to eq("String")
|
375
|
+
expect(e.actual_object).to eq(String)
|
376
|
+
expect(e.message).to match(/String/)
|
377
|
+
end
|
378
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
describe "Fortitude unparsed tag types", :type => :system do
|
2
|
+
it "should not escape data inside a <script> tag" do
|
3
|
+
expect(render(widget_class_with_content { script "foo < bar > baz & quux" })).to eq(
|
4
|
+
%{<script>foo < bar > baz & quux</script>})
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should not escape data inside a javascript call" do
|
8
|
+
expect(render(widget_class_with_content { javascript "foo < bar > baz & quux" })).to eq(
|
9
|
+
%{<script>foo < bar > baz & quux</script>})
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should not escape data inside a <style> tag" do
|
13
|
+
expect(render(widget_class_with_content { style "foo < bar > baz & quux" })).to eq(
|
14
|
+
%{<style>foo < bar > baz & quux</style>})
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
describe "Fortitude void tags", :type => :system do
|
2
|
+
def void_tag_class
|
3
|
+
widget_class do
|
4
|
+
tag :thevoid, :content_allowed => false
|
5
|
+
|
6
|
+
def content
|
7
|
+
thevoid
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should close void tags by default" do
|
13
|
+
vtc = widget_class(:superclass => Fortitude::Widget) do
|
14
|
+
tag :thevoid, :content_allowed => false
|
15
|
+
|
16
|
+
def content
|
17
|
+
thevoid
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
expect(render(vtc)).to eq("<thevoid/>")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should not close void tags if asked not to" do
|
25
|
+
klass = void_tag_class
|
26
|
+
klass.close_void_tags false
|
27
|
+
|
28
|
+
expect(render(klass)).to eq("<thevoid>")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should close void tags if asked to" do
|
32
|
+
klass = void_tag_class
|
33
|
+
klass.close_void_tags true
|
34
|
+
|
35
|
+
expect(render(klass)).to eq("<thevoid/>")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should not affect non-void tags with no content" do
|
39
|
+
klass = void_tag_class
|
40
|
+
klass.class_eval do
|
41
|
+
def content
|
42
|
+
p
|
43
|
+
div ""
|
44
|
+
span { }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
klass.close_void_tags false
|
48
|
+
|
49
|
+
expect(render(klass)).to eq("<p/><div></div><span></span>")
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
describe "Fortitude widget return values", :type => :system do
|
2
|
+
describe "#widget" do
|
3
|
+
it "should return whatever the widget returns" do
|
4
|
+
inner = widget_class_with_content do
|
5
|
+
text "inner"
|
6
|
+
:this_is_inner_rv
|
7
|
+
end
|
8
|
+
|
9
|
+
outer = widget_class do
|
10
|
+
attr_accessor :inner
|
11
|
+
def content
|
12
|
+
rv = widget inner
|
13
|
+
text "inner rv: #{rv.inspect}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
outer_instance = outer.new
|
18
|
+
inner_instance = inner.new
|
19
|
+
outer_instance.inner = inner_instance
|
20
|
+
|
21
|
+
expect(render(outer_instance)).to eq("innerinner rv: :this_is_inner_rv")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return whatever the widget returns, even if there are around_content methods that return something different" do
|
25
|
+
inner = widget_class do
|
26
|
+
def content
|
27
|
+
text "inner"
|
28
|
+
:this_is_inner_rv
|
29
|
+
end
|
30
|
+
|
31
|
+
def around1
|
32
|
+
yield
|
33
|
+
:around1_rv
|
34
|
+
end
|
35
|
+
|
36
|
+
around_content :around1
|
37
|
+
end
|
38
|
+
|
39
|
+
outer = widget_class do
|
40
|
+
attr_accessor :inner
|
41
|
+
def content
|
42
|
+
rv = widget inner
|
43
|
+
text "inner rv: #{rv.inspect}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
outer_instance = outer.new
|
48
|
+
inner_instance = inner.new
|
49
|
+
outer_instance.inner = inner_instance
|
50
|
+
|
51
|
+
expect(render(outer_instance)).to eq("innerinner rv: :this_is_inner_rv")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#to_html" do
|
56
|
+
it "should return whatever #content returns" do
|
57
|
+
wc = widget_class_with_content do
|
58
|
+
text "foo"
|
59
|
+
:widget_rv
|
60
|
+
end
|
61
|
+
|
62
|
+
widget = wc.new
|
63
|
+
rendering_context = rc
|
64
|
+
actual_rv = widget.to_html(rendering_context)
|
65
|
+
expect(actual_rv).to eq(:widget_rv)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should return whatever #content returns, even if there's an around_content that returns something different" do
|
69
|
+
wc = widget_class do
|
70
|
+
def content
|
71
|
+
text "foo"
|
72
|
+
:widget_rv
|
73
|
+
end
|
74
|
+
|
75
|
+
def around1
|
76
|
+
yield
|
77
|
+
:around1_rv
|
78
|
+
end
|
79
|
+
|
80
|
+
around_content :around1
|
81
|
+
end
|
82
|
+
|
83
|
+
widget = wc.new
|
84
|
+
rendering_context = rc
|
85
|
+
actual_rv = widget.to_html(rendering_context)
|
86
|
+
expect(actual_rv).to eq(:widget_rv)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|