fortitude 0.0.4-java
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.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec-local +4 -0
- data/.travis.yml +50 -0
- data/CHANGES.md +62 -0
- data/CONTRIBUTORS.md +6 -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 +42 -0
- data/lib/fortitude.rb +7 -0
- data/lib/fortitude/doctypes.rb +48 -0
- data/lib/fortitude/doctypes/base.rb +42 -0
- data/lib/fortitude/doctypes/html4.rb +21 -0
- data/lib/fortitude/doctypes/html4_frameset.rb +20 -0
- data/lib/fortitude/doctypes/html4_strict.rb +18 -0
- data/lib/fortitude/doctypes/html4_tags_frameset.rb +53 -0
- data/lib/fortitude/doctypes/html4_tags_strict.rb +274 -0
- data/lib/fortitude/doctypes/html4_tags_transitional.rb +115 -0
- data/lib/fortitude/doctypes/html4_transitional.rb +19 -0
- data/lib/fortitude/doctypes/html5.rb +373 -0
- data/lib/fortitude/doctypes/unknown_doctype.rb +20 -0
- data/lib/fortitude/doctypes/xhtml10.rb +20 -0
- data/lib/fortitude/doctypes/xhtml10_frameset.rb +18 -0
- data/lib/fortitude/doctypes/xhtml10_strict.rb +18 -0
- data/lib/fortitude/doctypes/xhtml10_transitional.rb +18 -0
- data/lib/fortitude/doctypes/xhtml11.rb +30 -0
- data/lib/fortitude/errors.rb +153 -0
- data/lib/fortitude/extensions/fortitude_ruby_ext.rb +76 -0
- data/lib/fortitude/extensions/native_extensions.rb +33 -0
- data/lib/fortitude/method_templates/assign_locals_from_template.rb.smpl +22 -0
- data/lib/fortitude/method_templates/need_assignment_template.rb.smpl +16 -0
- data/lib/fortitude/method_templates/need_method_template.rb.smpl +4 -0
- data/lib/fortitude/method_templates/simple_template.rb +50 -0
- data/lib/fortitude/method_templates/tag_method_template.rb.smpl +68 -0
- data/lib/fortitude/method_templates/text_method_template.rb.smpl +17 -0
- data/lib/fortitude/rails.rb +26 -0
- data/lib/fortitude/rails/helpers.rb +153 -0
- data/lib/fortitude/rails/railtie.rb +256 -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 +13 -0
- data/lib/fortitude/rails/yielded_object_outputter.rb +31 -0
- data/lib/fortitude/rendering_context.rb +205 -0
- data/lib/fortitude/support/assigns_proxy.rb +77 -0
- data/lib/fortitude/support/class_inheritable_attributes.rb +98 -0
- data/lib/fortitude/support/instance_variable_set.rb +76 -0
- data/lib/fortitude/support/staticized_method.rb +87 -0
- data/lib/fortitude/tags/partial_tag_placeholder.rb +19 -0
- data/lib/fortitude/tags/tag.rb +189 -0
- data/lib/fortitude/tags/tag_return_value.rb +13 -0
- data/lib/fortitude/tags/tag_store.rb +53 -0
- data/lib/fortitude/tags/tag_support.rb +51 -0
- data/lib/fortitude/tags/tags_module.rb +16 -0
- data/lib/fortitude/tilt.rb +17 -0
- data/lib/fortitude/tilt/fortitude_template.rb +169 -0
- data/lib/fortitude/version.rb +3 -0
- data/lib/fortitude/widget.rb +54 -0
- data/lib/fortitude/widget/around_content.rb +53 -0
- data/lib/fortitude/widget/capturing.rb +37 -0
- data/lib/fortitude/widget/content.rb +61 -0
- data/lib/fortitude/widget/doctypes.rb +53 -0
- data/lib/fortitude/widget/helpers.rb +62 -0
- data/lib/fortitude/widget/integration.rb +76 -0
- data/lib/fortitude/widget/localization.rb +63 -0
- data/lib/fortitude/widget/modules_and_subclasses.rb +58 -0
- data/lib/fortitude/widget/needs.rb +164 -0
- data/lib/fortitude/widget/non_rails_widget_methods.rb +13 -0
- data/lib/fortitude/widget/rendering.rb +98 -0
- data/lib/fortitude/widget/start_and_end_comments.rb +69 -0
- data/lib/fortitude/widget/staticization.rb +50 -0
- data/lib/fortitude/widget/tag_like_methods.rb +102 -0
- data/lib/fortitude/widget/tags.rb +55 -0
- data/lib/fortitude/widget/temporary_overrides.rb +28 -0
- data/lib/fortitude/widget/widget_class_inheritable_attributes.rb +35 -0
- data/lib/fortitude/widgets.rb +12 -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_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 +228 -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/inline_system_spec.rb +58 -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 +381 -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 +260 -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 +382 -0
- data/spec/system/unparsed_data_system_spec.rb +16 -0
- data/spec/system/void_tags_system_spec.rb +90 -0
- data/spec/system/widget_return_values_system_spec.rb +107 -0
- metadata +759 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
describe "Fortitude tag return values", :type => :system do
|
2
|
+
context "should blow up when calling a method on" do
|
3
|
+
def expect_nrv(name, &block)
|
4
|
+
e = capture_exception(Fortitude::Errors::NoReturnValueFromTag) { render(widget_class_with_content(&block)) }
|
5
|
+
expect(e).to be
|
6
|
+
expect(e.method_name).to eq(name)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "a simple tag" do
|
10
|
+
expect_nrv(:foo) { p.foo }
|
11
|
+
end
|
12
|
+
|
13
|
+
it "a tag with attributes" do
|
14
|
+
expect_nrv(:foo) { p(:foo => :bar).foo }
|
15
|
+
end
|
16
|
+
|
17
|
+
it "a tag with direct content" do
|
18
|
+
expect_nrv(:foo) { p("whatever").foo }
|
19
|
+
end
|
20
|
+
|
21
|
+
it "a tag with a block" do
|
22
|
+
expect_nrv(:foo) { p { text "whatever" }.foo }
|
23
|
+
end
|
24
|
+
|
25
|
+
it "a tag with a block and direct content" do
|
26
|
+
expect_nrv(:foo) { p("foo") { text "whatever" }.foo }
|
27
|
+
end
|
28
|
+
|
29
|
+
it "a tag with direct content and attributes" do
|
30
|
+
expect_nrv(:foo) { p("foo", :foo => :bar).foo }
|
31
|
+
end
|
32
|
+
|
33
|
+
it "a tag with a block and attributes" do
|
34
|
+
expect_nrv(:foo) { p(:foo => :bar) { text "whatever" }.foo }
|
35
|
+
end
|
36
|
+
|
37
|
+
it "a tag with a block, direct content, and attributes" do
|
38
|
+
expect_nrv(:foo) { p("foo", :foo => :bar) { text "whatever" }.foo }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
describe "Fortitude tag rules enforcement", :type => :system do
|
2
|
+
def widget_class(options = { }, &block)
|
3
|
+
out = super(options, &block)
|
4
|
+
out.class_eval { enforce_element_nesting_rules true } unless options[:no_enforcement]
|
5
|
+
out
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should not allow a <div> inside a <p>" do
|
9
|
+
expect { render(widget_class_with_content { p { div } })}.to raise_error(Fortitude::Errors::InvalidElementNesting)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should quote HTML specifications at you when you screw up" do
|
13
|
+
expect { render(widget_class_with_content { p { div } })}.to raise_error(Fortitude::Errors::InvalidElementNesting, /THE_SPEC_FOR_P/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should allow a <b> inside a <p>" do
|
17
|
+
expect(render(widget_class_with_content { p { b } })).to eq('<p><b></b></p>')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should not allow text where it's, well, not allowed, when specified directly" do
|
21
|
+
expect { render(widget_class_with_content { div "hi" }) }.to raise_error(Fortitude::Errors::InvalidElementNesting)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should not allow text where it's, well, not allowed, when specified directly and with a hash" do
|
25
|
+
expect { render(widget_class_with_content { div "hi", :class => "something" }) }.to raise_error(Fortitude::Errors::InvalidElementNesting)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not allow text where it's, well, not allowed, when specified indirectly" do
|
29
|
+
expect { render(widget_class_with_content { div { text "hi" } }) }.to raise_error(Fortitude::Errors::InvalidElementNesting)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should always allow rawtext" do
|
33
|
+
expect(render(widget_class_with_content { div { rawtext "yo" }})).to eq("<div>yo</div>")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should always allow html_safe text, when specified indirectly" do
|
37
|
+
expect(render(widget_class_with_content { div { text "yo".html_safe } })).to eq("<div>yo</div>")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should always allow html_safe text, when specified directly" do
|
41
|
+
expect(render(widget_class_with_content { div "yo".html_safe })).to eq("<div>yo</div>")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not enforce rules inside a widget with the setting off, even if surrounding widgets have it on" do
|
45
|
+
outer = widget_class do
|
46
|
+
attr_accessor :inner
|
47
|
+
def content
|
48
|
+
p do
|
49
|
+
widget inner
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
middle = widget_class(:no_enforcement => true) do
|
55
|
+
attr_accessor :inner
|
56
|
+
def content
|
57
|
+
div do
|
58
|
+
p do
|
59
|
+
widget inner
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
inner = widget_class_with_content do
|
66
|
+
text "yo"
|
67
|
+
end
|
68
|
+
|
69
|
+
outer_instance = outer.new
|
70
|
+
middle_instance = middle.new
|
71
|
+
inner_instance = inner.new
|
72
|
+
|
73
|
+
outer_instance.inner = middle_instance
|
74
|
+
middle_instance.inner = inner_instance
|
75
|
+
|
76
|
+
expect(render(outer_instance)).to eq("<p><div><p>yo</p></div></p>")
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should still enforce rules from one widget to the next" do
|
80
|
+
outer = widget_class do
|
81
|
+
attr_accessor :inner
|
82
|
+
def content
|
83
|
+
p do
|
84
|
+
widget inner
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
middle = widget_class do
|
90
|
+
def content
|
91
|
+
div do
|
92
|
+
text "hi"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
outer_instance = outer.new
|
98
|
+
middle_instance = middle.new
|
99
|
+
|
100
|
+
outer_instance.inner = middle_instance
|
101
|
+
|
102
|
+
expect { render(outer_instance) }.to raise_error(Fortitude::Errors::InvalidElementNesting)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should allow you to disable enforcement with a block" do
|
106
|
+
wc = widget_class_with_content do
|
107
|
+
p do
|
108
|
+
with_element_nesting_rules(false) do
|
109
|
+
div do
|
110
|
+
text "hi"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
expect(render(wc)).to eq("<p><div>hi</div></p>")
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should allow you to disable enforcement with a block, even across widget boundaries" do
|
120
|
+
outer = widget_class do
|
121
|
+
attr_accessor :inner
|
122
|
+
def content
|
123
|
+
p do
|
124
|
+
with_element_nesting_rules(false) do
|
125
|
+
widget inner
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
inner = widget_class_with_content { div { text "hi" } }
|
132
|
+
|
133
|
+
outer_instance = outer.new
|
134
|
+
inner_instance = inner.new
|
135
|
+
outer_instance.inner = inner_instance
|
136
|
+
|
137
|
+
expect(render(outer_instance)).to eq("<p><div>hi</div></p>")
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should allow you to re-enable enforcement with a block" do
|
141
|
+
wc = widget_class_with_content do
|
142
|
+
with_element_nesting_rules(false) do
|
143
|
+
p do
|
144
|
+
with_element_nesting_rules(true) do
|
145
|
+
div do
|
146
|
+
text "hi"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
expect { render(wc) }.to raise_error(Fortitude::Errors::InvalidElementNesting)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should let you re-enable enforcement with a block, even across widget boundaries" do
|
157
|
+
outer = widget_class do
|
158
|
+
attr_accessor :inner
|
159
|
+
def content
|
160
|
+
with_element_nesting_rules(false) do
|
161
|
+
p do
|
162
|
+
widget inner
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
inner = widget_class_with_content { with_element_nesting_rules(true) { div { text "hi" } } }
|
169
|
+
|
170
|
+
outer_instance = outer.new
|
171
|
+
inner_instance = inner.new
|
172
|
+
outer_instance.inner = inner_instance
|
173
|
+
|
174
|
+
expect { render(outer_instance) }.to raise_error(Fortitude::Errors::InvalidElementNesting)
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should raise an error if you try to enable enforcement with a block in a widget that isn't enforcing in the first place" do
|
178
|
+
wc = widget_class_with_content(:no_enforcement => true) do
|
179
|
+
with_element_nesting_rules(true) do
|
180
|
+
text "hi"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
expect { render(wc) }.to raise_error(ArgumentError)
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should not raise an error if you try to DISable enforcement with a block in a widget that isn't enforcing in the first place" do
|
188
|
+
wc = widget_class_with_content(:no_enforcement => true) do
|
189
|
+
with_element_nesting_rules(false) do
|
190
|
+
text "hi"
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
expect(render(wc)).to eq("hi")
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
describe "Fortitude tag updating", :type => :system do
|
2
|
+
before :each do
|
3
|
+
@base_class = widget_class do
|
4
|
+
enforce_attribute_rules true
|
5
|
+
enforce_element_nesting_rules true
|
6
|
+
|
7
|
+
tag :foo, :valid_attributes => %w{bar baz}
|
8
|
+
end
|
9
|
+
|
10
|
+
@derived_class = widget_class(:superclass => @base_class)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be enforcing rules" do
|
14
|
+
@base_class.class_eval do
|
15
|
+
def content
|
16
|
+
foo :something => 'whatever'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
expect { render(@base_class) }.to raise_error(Fortitude::Errors::InvalidElementAttributes)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should allow replacing a tag completely" do
|
24
|
+
@derived_class.tag :foo, :can_enclose => %w{p}
|
25
|
+
@derived_class.class_eval do
|
26
|
+
def content
|
27
|
+
foo :something => 'whatever' do
|
28
|
+
p "hi"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
expect(render(@derived_class)).to eq("<foo something=\"whatever\"><p>hi</p></foo>")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should not change the parent class's tag when replacing a tag completely" do
|
37
|
+
@derived_class.tag :foo, :can_enclose => %w{p}
|
38
|
+
@derived_class.class_eval do
|
39
|
+
def content
|
40
|
+
foo :something => 'whatever' do
|
41
|
+
p "hi"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
expect(render(@derived_class)).to eq("<foo something=\"whatever\"><p>hi</p></foo>")
|
47
|
+
|
48
|
+
@base_class.class_eval do
|
49
|
+
def content
|
50
|
+
foo :something => 'something_else'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
expect { render(@base_class) }.to raise_error(Fortitude::Errors::InvalidElementAttributes)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should not change the parent class's tag when modifying a tag" do
|
58
|
+
@derived_class.modify_tag(:foo) { |t| t.valid_attributes += %w{quux} }
|
59
|
+
@derived_class.class_eval do
|
60
|
+
def content
|
61
|
+
foo :quux => 'baz'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
expect(render(@derived_class)).to eq("<foo quux=\"baz\"></foo>")
|
66
|
+
|
67
|
+
@base_class.class_eval do
|
68
|
+
def content
|
69
|
+
foo :quux => 'baz'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
expect { render(@base_class) }.to raise_error(Fortitude::Errors::InvalidElementAttributes)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should allow modifying a tag's :valid_attributes" do
|
77
|
+
@derived_class.modify_tag(:foo) { |t| t.valid_attributes += %w{quux} }
|
78
|
+
@derived_class.class_eval do
|
79
|
+
def content
|
80
|
+
foo :quux => 'baz'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
expect(render(@derived_class)).to eq("<foo quux=\"baz\"></foo>")
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should allow modifying a tag's :can_enclose" do
|
88
|
+
@derived_class.modify_tag(:div) { |t| t.can_enclose += %w{_text} }
|
89
|
+
@derived_class.modify_tag(:p) { |t| t.can_enclose += %w{div} }
|
90
|
+
@derived_class.class_eval do
|
91
|
+
def content
|
92
|
+
p do
|
93
|
+
div "whatever"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
expect(render(@derived_class)).to eq("<p><div>whatever</div></p>")
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should allow modifying a tag's :newline_before" do
|
102
|
+
@derived_class.modify_tag(:a) { |t| t.newline_before = true }
|
103
|
+
@derived_class.class_eval do
|
104
|
+
format_output true
|
105
|
+
|
106
|
+
def content
|
107
|
+
p do
|
108
|
+
text "hello"
|
109
|
+
a "there"
|
110
|
+
text "goodbye"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
expect(render(@derived_class)).to eq("<p>\n hello\n <a>there</a>\n goodbye\n</p>")
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should allow modifying a tag's :content_allowed" do
|
119
|
+
@derived_class.modify_tag(:br) { |t| t.content_allowed = true }
|
120
|
+
@derived_class.class_eval do
|
121
|
+
def content
|
122
|
+
br "hello"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
expect(render(@derived_class)).to eq("<br>hello</br>")
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should allow modifying a tag's :allow_data_attributes" do
|
130
|
+
@derived_class.modify_tag(:p) { |t| t.allow_data_attributes = false }
|
131
|
+
@derived_class.class_eval do
|
132
|
+
def content
|
133
|
+
p :'data-foo' => 'bar'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
expect { render(@derived_class) }.to raise_error(Fortitude::Errors::InvalidElementAttributes)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should allow modifying a tag's :allow_aria_attributes" do
|
141
|
+
@derived_class.modify_tag(:p) { |t| t.allow_aria_attributes = false }
|
142
|
+
@derived_class.class_eval do
|
143
|
+
def content
|
144
|
+
p :'aria-foo' => 'bar'
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
expect { render(@derived_class) }.to raise_error(Fortitude::Errors::InvalidElementAttributes)
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should allow overriding a doctype's tags, but shouldn't modify the doctype itself" do
|
152
|
+
@base_class.modify_tag(:p) { |t| t.valid_attributes += %w{bonk} }
|
153
|
+
@base_class.class_eval do
|
154
|
+
def content
|
155
|
+
p :bonk => "whatever"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
expect(render(@base_class)).to eq("<p bonk=\"whatever\"></p>")
|
160
|
+
|
161
|
+
other_widget = widget_class do
|
162
|
+
enforce_attribute_rules true
|
163
|
+
|
164
|
+
def content
|
165
|
+
p :bonk => :whatever
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
expect { render(other_widget) }.to raise_error(Fortitude::Errors::InvalidElementAttributes)
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,382 @@
|
|
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
|
+
it "should allow the Tilt template to be created with an empty string, since earlier versions of Tilt do that" do
|
46
|
+
expect { Fortitude::Tilt::FortitudeTemplate.new { "" } }.not_to raise_error
|
47
|
+
end
|
48
|
+
|
49
|
+
SIMPLE_TEMPLATE_WITH_VARIABLES = <<-EOS
|
50
|
+
class SimpleTemplateWithVariables < Fortitude::Widgets::Html5
|
51
|
+
needs :foo, :bar => 'whatever'
|
52
|
+
|
53
|
+
def content
|
54
|
+
text "foo: \#{foo}, bar: \#{bar}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
EOS
|
58
|
+
|
59
|
+
SIMPLE_TEMPLATE_WITH_VARIABLES_NO_EXTRA_ASSIGNS = <<-EOS
|
60
|
+
class SimpleTemplateWithVariablesNoExtraAssigns < Fortitude::Widgets::Html5
|
61
|
+
extra_assigns :error
|
62
|
+
needs :foo, :bar => 'whatever'
|
63
|
+
|
64
|
+
def content
|
65
|
+
text "foo: \#{foo}, bar: \#{bar}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
EOS
|
69
|
+
|
70
|
+
SIMPLE_TEMPLATE_WITH_VARIABLES_WANTS_EXTRA_ASSIGNS = <<-EOS
|
71
|
+
class SimpleTemplateWithVariablesWantsExtraAssigns < Fortitude::Widgets::Html5
|
72
|
+
extra_assigns :use
|
73
|
+
needs :foo, :bar => 'whatever'
|
74
|
+
|
75
|
+
def content
|
76
|
+
text "foo: \#{foo}, bar: \#{bar}, baz: \#{assigns[:baz] || 'nil'}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
EOS
|
80
|
+
|
81
|
+
it "should pass explicit locals to the template" do
|
82
|
+
result = render_text_with_tilt("simple_template_with_variables.rb", SIMPLE_TEMPLATE_WITH_VARIABLES, context_object, { :foo => 'the_foo', :bar => 'the_bar' })
|
83
|
+
expect(result).to eq("foo: the_foo, bar: the_bar")
|
84
|
+
end
|
85
|
+
|
86
|
+
def context_object(variable_mappings = { }, klass = Object.class, &block)
|
87
|
+
out = klass.new
|
88
|
+
variable_mappings.each do |name, value|
|
89
|
+
out.instance_variable_set("@#{name}", value)
|
90
|
+
end
|
91
|
+
out.instance_eval(&block) if block
|
92
|
+
out
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should make variables defined on the context object available to the template as needs" do
|
96
|
+
co = context_object(:foo => 'the_foo', :bar => 'the_bar')
|
97
|
+
|
98
|
+
result = render_text_with_tilt("simple_template_with_variables.rb", SIMPLE_TEMPLATE_WITH_VARIABLES, co, { })
|
99
|
+
expect(result).to eq("foo: the_foo, bar: the_bar")
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should allow passing locals as strings, and overriding context-object variables" do
|
103
|
+
co = context_object(:foo => 'co_foo', :bar => 'co_bar')
|
104
|
+
result = render_text_with_tilt("simple_template_with_variables.rb", SIMPLE_TEMPLATE_WITH_VARIABLES, co, { 'bar' => 'local_bar' })
|
105
|
+
expect(result).to eq("foo: co_foo, bar: local_bar")
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should allow passing locals as symbols, and overriding context-object variables" do
|
109
|
+
co = context_object(:foo => 'co_foo', :bar => 'co_bar')
|
110
|
+
result = render_text_with_tilt("simple_template_with_variables.rb", SIMPLE_TEMPLATE_WITH_VARIABLES, co, { :bar => 'local_bar' })
|
111
|
+
expect(result).to eq("foo: co_foo, bar: local_bar")
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should ignore passed locals that the template doesn't actually need" do
|
115
|
+
result = render_text_with_tilt("simple_template_with_variables_no_extra_assigns.rb", SIMPLE_TEMPLATE_WITH_VARIABLES_NO_EXTRA_ASSIGNS,
|
116
|
+
context_object, { :foo => 'the_foo', :baz => 'baz!'})
|
117
|
+
expect(result).to eq("foo: the_foo, bar: whatever")
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should pass extra locals if the template wants extra assigns" do
|
121
|
+
result = render_text_with_tilt("simple_template_with_variables_wants_extra_assigns.rb", SIMPLE_TEMPLATE_WITH_VARIABLES_WANTS_EXTRA_ASSIGNS,
|
122
|
+
context_object, { :foo => 'the_foo', :baz => 'baz!'})
|
123
|
+
expect(result).to eq("foo: the_foo, bar: whatever, baz: baz!")
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should ignore context-object instance variables that the template doesn't actually need" do
|
127
|
+
result = render_text_with_tilt("simple_template_with_variables_no_extra_assigns.rb", SIMPLE_TEMPLATE_WITH_VARIABLES_NO_EXTRA_ASSIGNS,
|
128
|
+
context_object(:foo => 'the_foo', :baz => 'baz!'), { })
|
129
|
+
expect(result).to eq("foo: the_foo, bar: whatever")
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should pass extra context-object instance variables if the template wants extra assigns" do
|
133
|
+
result = render_text_with_tilt("simple_template_with_variables_wants_extra_assigns.rb", SIMPLE_TEMPLATE_WITH_VARIABLES_WANTS_EXTRA_ASSIGNS,
|
134
|
+
context_object(:foo => 'the_foo', :baz => 'baz!'), { })
|
135
|
+
expect(result).to eq("foo: the_foo, bar: whatever, baz: baz!")
|
136
|
+
end
|
137
|
+
|
138
|
+
SHARED_VARIABLE_ACCESS = <<-EOS
|
139
|
+
class SharedVariableAccess < Fortitude::Widgets::Html5
|
140
|
+
def content
|
141
|
+
data = shared_variables[:foo]
|
142
|
+
text "foo is: \#{data}"
|
143
|
+
shared_variables[:foo] = 'new_foo'
|
144
|
+
end
|
145
|
+
end
|
146
|
+
EOS
|
147
|
+
|
148
|
+
it "should allow instance variables on the context object to be accessed via #shared_variables" do
|
149
|
+
co = context_object(:foo => 'the_foo')
|
150
|
+
result = render_text_with_tilt("shared_variable_access.rb", SHARED_VARIABLE_ACCESS, co, { })
|
151
|
+
expect(result).to eq("foo is: the_foo")
|
152
|
+
expect(co.instance_variable_get("@foo")).to eq("new_foo")
|
153
|
+
end
|
154
|
+
|
155
|
+
IMPLICIT_SHARED_VARIABLE_ACCESS = <<-EOS
|
156
|
+
class ImplicitSharedVariableAccess < Fortitude::Widgets::Html5
|
157
|
+
implicit_shared_variable_access true
|
158
|
+
def content
|
159
|
+
text "foo is: \#{@foo}"
|
160
|
+
@foo = "new_foo"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
EOS
|
164
|
+
|
165
|
+
it "should allow instance variables on the context object to be read and written implicitly if implicit_shared_variable_access is set" do
|
166
|
+
co = context_object(:foo => 'the_foo')
|
167
|
+
result = render_text_with_tilt("implicit_shared_variable_access.rb", IMPLICIT_SHARED_VARIABLE_ACCESS, co, { })
|
168
|
+
expect(result).to eq("foo is: the_foo")
|
169
|
+
expect(co.instance_variable_get("@foo")).to eq("new_foo")
|
170
|
+
end
|
171
|
+
|
172
|
+
WIDGET_WITH_BLOCK = <<-EOS
|
173
|
+
class WidgetWithBlock < Fortitude::Widgets::Html5
|
174
|
+
def content
|
175
|
+
data = yield("foo")
|
176
|
+
text "data is: \#{data}"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
EOS
|
180
|
+
|
181
|
+
it "should forward the passed block to the widget" do
|
182
|
+
result = render_text_with_tilt("widget_with_block.rb", WIDGET_WITH_BLOCK,
|
183
|
+
context_object, { }) { |a| "xx#{a}yy" }
|
184
|
+
expect(result).to eq("data is: xxfooyy")
|
185
|
+
end
|
186
|
+
|
187
|
+
WIDGET_CALLING_FOO = <<-EOS
|
188
|
+
class WidgetCallingFoo < Fortitude::Widgets::Html5
|
189
|
+
def content
|
190
|
+
val = foo("xxx")
|
191
|
+
text "val is: \#{val}"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
EOS
|
195
|
+
|
196
|
+
it "should allow helpers defined on the context object to be invoked via automatic helper support" do
|
197
|
+
co = context_object do
|
198
|
+
def foo(x)
|
199
|
+
"foo#{x}foo"
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
result = render_text_with_tilt("widget_calling_foo.rb", WIDGET_CALLING_FOO, co, { })
|
204
|
+
expect(result).to eq("val is: fooxxxfoo")
|
205
|
+
end
|
206
|
+
|
207
|
+
WIDGET_CALLING_FOO_AHA_OFF = <<-EOS
|
208
|
+
class WidgetCallingFooAhaOff < Fortitude::Widgets::Html5
|
209
|
+
automatic_helper_access false
|
210
|
+
|
211
|
+
def content
|
212
|
+
val = invoke_helper(:foo, "yyy")
|
213
|
+
text "val is: \#{val}"
|
214
|
+
end
|
215
|
+
end
|
216
|
+
EOS
|
217
|
+
|
218
|
+
it "should allow helpers defined on the context object to be invoked via explicit helper support" do
|
219
|
+
co = context_object do
|
220
|
+
def foo(x)
|
221
|
+
"foo#{x}foo"
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
result = render_text_with_tilt("widget_calling_foo_aha_off.rb", WIDGET_CALLING_FOO_AHA_OFF, co, { })
|
226
|
+
expect(result).to eq("val is: fooyyyfoo")
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should not require the class name to match the filename of the widget at all" do
|
230
|
+
result = render_text_with_tilt("foo_bar.rb", SIMPLE_TEMPLATE_WITH_VARIABLES, context_object, { :foo => 'the_foo', :bar => 'the_bar' })
|
231
|
+
expect(result).to eq("foo: the_foo, bar: the_bar")
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should still render a widget that's directly in a module (class Foo::Bar::Baz < Fortitude::Widget)" do
|
235
|
+
eval("module Spec1; module Bar; end; end")
|
236
|
+
|
237
|
+
text = <<-EOS
|
238
|
+
class Spec1::Bar::Baz < Fortitude::Widgets::Html5
|
239
|
+
def content
|
240
|
+
text "hello from spec1"
|
241
|
+
end
|
242
|
+
end
|
243
|
+
EOS
|
244
|
+
|
245
|
+
expect(render_text_with_tilt("random_#{rand(1_000_000)}.rb", text, context_object, { })).to eq("hello from spec1")
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should still render a widget that's directly in a module, of a subclass of Widget (class Foo::Bar::Baz < MyWidget)" do
|
249
|
+
eval("module Spec2; module Bar; end; end")
|
250
|
+
eval("class Spec2::Spec2Superclass < Fortitude::Widgets::Html5; end")
|
251
|
+
|
252
|
+
text = <<-EOS
|
253
|
+
class Spec2::Bar::Baz < Spec2::Spec2Superclass
|
254
|
+
def content
|
255
|
+
text "hello from spec2"
|
256
|
+
end
|
257
|
+
end
|
258
|
+
EOS
|
259
|
+
|
260
|
+
expect(render_text_with_tilt("random_#{rand(1_000_000)}.rb", text, context_object, { })).to eq("hello from spec2")
|
261
|
+
end
|
262
|
+
|
263
|
+
it "should still render a widget that's in a module via namespace nesting (module Foo; module Bar; Baz < Fortitude::Widget)" do
|
264
|
+
text = <<-EOS
|
265
|
+
module Spec3
|
266
|
+
module Bar
|
267
|
+
class Baz < Fortitude::Widgets::Html5
|
268
|
+
def content
|
269
|
+
text "hello from spec3"
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
EOS
|
275
|
+
|
276
|
+
expect(render_text_with_tilt("random_#{rand(1_000_000)}.rb", text, context_object, { })).to eq("hello from spec3")
|
277
|
+
end
|
278
|
+
|
279
|
+
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
|
280
|
+
eval("module Spec4; class Spec4Superclass < Fortitude::Widgets::Html5; end; end")
|
281
|
+
|
282
|
+
text = <<-EOS
|
283
|
+
module Spec4
|
284
|
+
module Bar
|
285
|
+
class Baz < Fortitude::Widgets::Html5
|
286
|
+
def content
|
287
|
+
text "hello from spec4"
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
EOS
|
293
|
+
|
294
|
+
expect(render_text_with_tilt("random_#{rand(1_000_000)}.rb", text, context_object, { })).to eq("hello from spec4")
|
295
|
+
end
|
296
|
+
|
297
|
+
def impossible_to_find_class_name_text(num, insert="")
|
298
|
+
text = <<-EOS
|
299
|
+
klass_name = "Spec#{num}" + "TheClass"
|
300
|
+
c = Class.new(Fortitude::Widgets::Html5) do
|
301
|
+
#{insert}
|
302
|
+
def content
|
303
|
+
text "hello from spec#{num}"
|
304
|
+
end
|
305
|
+
end
|
306
|
+
::Object.const_set(klass_name, c)
|
307
|
+
EOS
|
308
|
+
end
|
309
|
+
|
310
|
+
it "should fail with a nice message if it can't figure out which class to render" do
|
311
|
+
e = capture_exception(Fortitude::Tilt::CannotDetermineTemplateClassError) do
|
312
|
+
render_text_with_tilt("random_#{rand(1_000_000)}.rb", impossible_to_find_class_name_text(5), context_object, { })
|
313
|
+
end
|
314
|
+
|
315
|
+
expect(e).to be
|
316
|
+
expect(e.tried_class_names).to eq([ ])
|
317
|
+
expect(e.message).to match(/\#\!fortitude_tilt_class/)
|
318
|
+
expect(e.message).to match(/:fortitude_class/)
|
319
|
+
end
|
320
|
+
|
321
|
+
it "should allow overriding the class that's defined in the module explicitly with an option" do
|
322
|
+
result = render_text_with_tilt("random_#{rand(1_000_000)}.rb", impossible_to_find_class_name_text(6), context_object, { },
|
323
|
+
{ :fortitude_class => "Spec6TheClass" })
|
324
|
+
expect(result).to eq("hello from spec6")
|
325
|
+
end
|
326
|
+
|
327
|
+
it "should fail with a nice message if you tell it to use something that doesn't exist, using an option" do
|
328
|
+
e = capture_exception(Fortitude::Tilt::NotATemplateClassError) do
|
329
|
+
render_text_with_tilt("random_#{rand(1_000_000)}.rb", impossible_to_find_class_name_text(7), context_object, { },
|
330
|
+
{ :fortitude_class => "NonExistent" })
|
331
|
+
end
|
332
|
+
expect(e.class_name).to eq("NonExistent")
|
333
|
+
expect(e.actual_object).to be_nil
|
334
|
+
expect(e.message).to match(/NonExistent/)
|
335
|
+
end
|
336
|
+
|
337
|
+
it "should fail with a nice message if you tell it to use something that isn't a class, using an option" do
|
338
|
+
e = capture_exception(Fortitude::Tilt::NotATemplateClassError) do
|
339
|
+
render_text_with_tilt("random_#{rand(1_000_000)}.rb", impossible_to_find_class_name_text(8), context_object, { },
|
340
|
+
{ :fortitude_class => 12345 })
|
341
|
+
end
|
342
|
+
expect(e.class_name).to eq(12345)
|
343
|
+
expect(e.actual_object).to eq(12345)
|
344
|
+
expect(e.message).to match(/12345/)
|
345
|
+
end
|
346
|
+
|
347
|
+
it "should fail with a nice message if you tell it to use something that isn't a widget class, using an option" do
|
348
|
+
e = capture_exception(Fortitude::Tilt::NotATemplateClassError) do
|
349
|
+
render_text_with_tilt("random_#{rand(1_000_000)}.rb", impossible_to_find_class_name_text(9), context_object, { },
|
350
|
+
{ :fortitude_class => "String" })
|
351
|
+
end
|
352
|
+
expect(e.class_name).to eq("String")
|
353
|
+
expect(e.actual_object).to eq(String)
|
354
|
+
expect(e.message).to match(/String/)
|
355
|
+
end
|
356
|
+
|
357
|
+
it "should allow overriding the class that's defined in the module explicitly with a comment in the template" do
|
358
|
+
result = render_text_with_tilt("random_#{rand(1_000_000)}.rb",
|
359
|
+
impossible_to_find_class_name_text(10, "#!fortitude_tilt_class: Spec10TheClass"), context_object, { })
|
360
|
+
expect(result).to eq("hello from spec10")
|
361
|
+
end
|
362
|
+
|
363
|
+
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
|
364
|
+
e = capture_exception(Fortitude::Tilt::NotATemplateClassError) do
|
365
|
+
render_text_with_tilt("random_#{rand(1_000_000)}.rb",
|
366
|
+
impossible_to_find_class_name_text(11, "#!fortitude_tilt_class: 12345"), context_object, { })
|
367
|
+
end
|
368
|
+
expect(e.class_name).to eq("12345")
|
369
|
+
expect(e.actual_object).to be_nil
|
370
|
+
expect(e.message).to match(/12345/)
|
371
|
+
end
|
372
|
+
|
373
|
+
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
|
374
|
+
e = capture_exception(Fortitude::Tilt::NotATemplateClassError) do
|
375
|
+
render_text_with_tilt("random_#{rand(1_000_000)}.rb",
|
376
|
+
impossible_to_find_class_name_text(12, "#!fortitude_tilt_class: String"), context_object, { })
|
377
|
+
end
|
378
|
+
expect(e.class_name).to eq("String")
|
379
|
+
expect(e.actual_object).to eq(String)
|
380
|
+
expect(e.message).to match(/String/)
|
381
|
+
end
|
382
|
+
end
|