rango 0.0.3
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.
- data/CHANGELOG +8 -0
- data/LICENSE +20 -0
- data/README.textile +18 -0
- data/bin/rango +30 -0
- data/doc/head/Array.html +114 -0
- data/doc/head/AttributeMixin.html +613 -0
- data/doc/head/Class.html +102 -0
- data/doc/head/ColoredString.html +476 -0
- data/doc/head/Hash.html +643 -0
- data/doc/head/Kernel.html +641 -0
- data/doc/head/Object.html +140 -0
- data/doc/head/ObjectSpace.html +103 -0
- data/doc/head/Path.html +2499 -0
- data/doc/head/Range.html +109 -0
- data/doc/head/Rango.html +397 -0
- data/doc/head/Rango/ApplicationMixin.html +396 -0
- data/doc/head/Rango/Bundling.html +23 -0
- data/doc/head/Rango/Bundling/RequireStrategy.html +283 -0
- data/doc/head/Rango/Bundling/Strategy.html +703 -0
- data/doc/head/Rango/CallableStrategy.html +300 -0
- data/doc/head/Rango/Chainable.html +181 -0
- data/doc/head/Rango/Configurable.html +199 -0
- data/doc/head/Rango/Controller.html +962 -0
- data/doc/head/Rango/ControllerMixin.html +860 -0
- data/doc/head/Rango/ControllerStrategy.html +264 -0
- data/doc/head/Rango/DependencyStrategy.html +116 -0
- data/doc/head/Rango/Dispatcher.html +305 -0
- data/doc/head/Rango/Form.html +162 -0
- data/doc/head/Rango/GemDependencyStrategy.html +210 -0
- data/doc/head/Rango/Generator.html +93 -0
- data/doc/head/Rango/GenericViews.html +128 -0
- data/doc/head/Rango/GitDependencyStrategy.html +224 -0
- data/doc/head/Rango/GithubDependencyStrategy.html +118 -0
- data/doc/head/Rango/Handler.html +474 -0
- data/doc/head/Rango/Helpers.html +1271 -0
- data/doc/head/Rango/Hookable.html +202 -0
- data/doc/head/Rango/ImportMixin.html +755 -0
- data/doc/head/Rango/Logger.html +920 -0
- data/doc/head/Rango/ModelForm.html +42 -0
- data/doc/head/Rango/Project.html +516 -0
- data/doc/head/Rango/RenderMixin.html +23 -0
- data/doc/head/Rango/Request.html +1177 -0
- data/doc/head/Rango/Route.html +751 -0
- data/doc/head/Rango/Router.html +42 -0
- data/doc/head/Rango/Router/Dispatcher.html +311 -0
- data/doc/head/Rango/RouterStrategy.html +258 -0
- data/doc/head/Rango/Session.html +23 -0
- data/doc/head/Rango/Settings.html +23 -0
- data/doc/head/Rango/Settings/Erubis.html +23 -0
- data/doc/head/Rango/Settings/Framework.html +198 -0
- data/doc/head/Rango/Settings/Haml.html +23 -0
- data/doc/head/Rango/SimpleTemplate.html +187 -0
- data/doc/head/Rango/StrategyMixin.html +261 -0
- data/doc/head/Rango/Tasks.html +251 -0
- data/doc/head/Rango/Template.html +95 -0
- data/doc/head/Rango/Template/Adapter.html +90 -0
- data/doc/head/Rango/Templates.html +116 -0
- data/doc/head/Rango/Templates/Adapter.html +128 -0
- data/doc/head/Rango/Templates/Template.html +636 -0
- data/doc/head/Rango/Templates/TemplateHelpers.html +328 -0
- data/doc/head/RangoThor.html +205 -0
- data/doc/head/String.html +163 -0
- data/doc/head/TimeDSL.html +612 -0
- data/doc/head/all-methods.html +2012 -0
- data/doc/head/all-namespaces.html +114 -0
- data/doc/head/app.js +18 -0
- data/doc/head/index.html +18 -0
- data/doc/head/jquery.js +11 -0
- data/doc/head/readme.html +34 -0
- data/doc/head/style.css +68 -0
- data/doc/head/syntax_highlight.css +21 -0
- data/doc/versions/0.0.1/Rango.html +1025 -0
- data/doc/versions/0.0.1/Rango/CallableStrategy.html +166 -0
- data/doc/versions/0.0.1/Rango/ControllerStrategy.html +180 -0
- data/doc/versions/0.0.1/Rango/Route.html +340 -0
- data/doc/versions/0.0.1/Rango/Router.html +502 -0
- data/doc/versions/0.0.1/Rango/RouterStrategy.html +94 -0
- data/doc/versions/0.0.1/Rango/Template.html +28 -0
- data/doc/versions/0.0.1/Rango/Template/Adapter.html +90 -0
- data/doc/versions/0.0.1/all-methods.html +228 -0
- data/doc/versions/0.0.1/all-namespaces.html +36 -0
- data/doc/versions/0.0.1/app.js +18 -0
- data/doc/versions/0.0.1/index.html +18 -0
- data/doc/versions/0.0.1/jquery.js +11 -0
- data/doc/versions/0.0.1/readme.html +137 -0
- data/doc/versions/0.0.1/style.css +68 -0
- data/doc/versions/0.0.1/syntax_highlight.css +21 -0
- data/lib/rango.rb +25 -0
- data/lib/rango/boot.rb +54 -0
- data/lib/rango/bundling/dependency.rb +65 -0
- data/lib/rango/bundling/strategies/copy.rb +36 -0
- data/lib/rango/bundling/strategies/gem.rb +55 -0
- data/lib/rango/bundling/strategies/git.rb +71 -0
- data/lib/rango/bundling/strategies/hg.rb +9 -0
- data/lib/rango/bundling/strategy.rb +85 -0
- data/lib/rango/cli/generator.rb +15 -0
- data/lib/rango/cli/project.rb +87 -0
- data/lib/rango/cli/simple_template.rb +47 -0
- data/lib/rango/contrib/pagination.rb +15 -0
- data/lib/rango/contrib/pagination/README.textile +21 -0
- data/lib/rango/contrib/pagination/TODO +3 -0
- data/lib/rango/contrib/pagination/_pagination.html.haml +39 -0
- data/lib/rango/contrib/pagination/adapters/datamapper.rb +22 -0
- data/lib/rango/contrib/pagination/helpers.rb +12 -0
- data/lib/rango/contrib/pagination/page.rb +107 -0
- data/lib/rango/contrib/pagination/strategies.rb +49 -0
- data/lib/rango/contrib/syndication.rb +1 -0
- data/lib/rango/exceptions.rb +269 -0
- data/lib/rango/ext.rb +14 -0
- data/lib/rango/ext/attribute.rb +140 -0
- data/lib/rango/ext/class.rb +99 -0
- data/lib/rango/ext/colored_string.rb +105 -0
- data/lib/rango/ext/core_ext.rb +52 -0
- data/lib/rango/ext/hash.rb +21 -0
- data/lib/rango/ext/kernel.rb +74 -0
- data/lib/rango/ext/object_space.rb +11 -0
- data/lib/rango/ext/path.rb +222 -0
- data/lib/rango/ext/random.rb +22 -0
- data/lib/rango/ext/string.rb +16 -0
- data/lib/rango/ext/thor.rb +32 -0
- data/lib/rango/ext/time_dsl.rb +63 -0
- data/lib/rango/ext/try.rb +30 -0
- data/lib/rango/forms/form.rb +29 -0
- data/lib/rango/generic_views/static.rb +7 -0
- data/lib/rango/helpers.rb +24 -0
- data/lib/rango/helpers/README +179 -0
- data/lib/rango/helpers/assets.rb +29 -0
- data/lib/rango/helpers/general.rb +41 -0
- data/lib/rango/helpers/merb-helpers.rb +40 -0
- data/lib/rango/helpers/merb-helpers/core_ext.rb +58 -0
- data/lib/rango/helpers/merb-helpers/core_ext/numeric.rb +388 -0
- data/lib/rango/helpers/merb-helpers/date_time_formatting.rb +158 -0
- data/lib/rango/helpers/merb-helpers/date_time_helpers.rb +191 -0
- data/lib/rango/helpers/merb-helpers/form/builder.rb +447 -0
- data/lib/rango/helpers/merb-helpers/form/helpers.rb +451 -0
- data/lib/rango/helpers/merb-helpers/form_helpers.rb +19 -0
- data/lib/rango/helpers/merb-helpers/tag_helpers.rb +63 -0
- data/lib/rango/helpers/merb-helpers/text_helpers.rb +63 -0
- data/lib/rango/helpers/merb-helpers/time_dsl.rb +61 -0
- data/lib/rango/helpers/spec/core_ext_spec.rb +21 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/application.rb +4 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_check_box.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_file_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_hidden_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_option_tag.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_password_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_radio_button.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_radio_group.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_select.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_text_area.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_text_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/button.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/check_box.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/custom_builder.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/delete_button.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/exceptions.rb +25 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/field_set.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/fields_for.rb +3 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/file_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/foo.rb +23 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/form.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/form_for.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/hacker.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/hidden_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/label.rb +3 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/numeric_ext.rb +3 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/option_tag.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/password_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/radio_button.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/radio_group.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/relative_date.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/relative_date_span.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/select.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/specs_controller.rb +11 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/submit.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/tag_helper.rb +21 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/text_area.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/text_field.rb +3 -0
- data/lib/rango/helpers/spec/fixture/app/helpers/global_helpers.rb +8 -0
- data/lib/rango/helpers/spec/fixture/app/models/fake_dm_model.rb +25 -0
- data/lib/rango/helpers/spec/fixture/app/models/first_generic_fake_model.rb +57 -0
- data/lib/rango/helpers/spec/fixture/app/models/hacker_generic_model.rb +5 -0
- data/lib/rango/helpers/spec/fixture/app/models/second_generic_fake_model.rb +18 -0
- data/lib/rango/helpers/spec/fixture/app/models/third_generic_fake_model.rb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/basic.html.erb +4 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/basic_unchecked.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/checked.html.erb +4 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/errors.html.erb +4 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/label.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/on_and_off.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/raise_value_error.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_file_field_specs/additional_attributes.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_file_field_specs/takes_string.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_file_field_specs/with_label.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_hidden_field_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_hidden_field_specs/errors.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_hidden_field_specs/hidden_error.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_hidden_field_specs/label.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_option_tag_specs/grouped.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_option_tag_specs/nested.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_option_tag_specs/text_and_value.html.erb +4 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_password_field_specs/attributes.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_password_field_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_password_field_specs/label.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_radio_button_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_radio_group_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_radio_group_specs/hashes.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_radio_group_specs/mixed.html.erb +4 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_radio_group_specs/override_id.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/blank.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/label.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/multiple.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/prompt.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/with_options.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/with_options_with_blank.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_text_area_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_text_area_specs/label.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_text_field_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/button_specs/button_with_label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/button_specs/button_with_values.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/button_specs/disabled_button.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/boolean.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/on_off_is_boolean.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/raise_unless_both_on_and_off.html.erb +2 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/raises_error_if_not_boolean.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/raises_error_if_on_off_and_boolean_false.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/simple.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/to_string.html.erb +8 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/unchecked.html.erb +2 -0
- data/lib/rango/helpers/spec/fixture/app/views/custom_builder_specs/everything.html.erb +10 -0
- data/lib/rango/helpers/spec/fixture/app/views/delete_button_specs/delete_with_explicit_url.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/delete_button_specs/delete_with_extra_params.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/delete_button_specs/delete_with_label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/delete_button_specs/simple_delete.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/exeptions/client_error.html.erb +37 -0
- data/lib/rango/helpers/spec/fixture/app/views/exeptions/internal_server_error.html.erb +216 -0
- data/lib/rango/helpers/spec/fixture/app/views/exeptions/not_acceptable.html.erb +38 -0
- data/lib/rango/helpers/spec/fixture/app/views/exeptions/not_found.html.erb +40 -0
- data/lib/rango/helpers/spec/fixture/app/views/fields_for_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/fields_for_specs/midstream.html.erb +7 -0
- data/lib/rango/helpers/spec/fixture/app/views/fields_for_specs/nil.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/fieldset_specs/legend.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/file_field_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/file_field_specs/makes_multipart.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/file_field_specs/with_label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/file_field_specs/with_values.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/foo/bar.html.erb +0 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_for_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/create_a_form.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/create_a_multipart_form.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/fake_delete_if_set.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/fake_put_if_set.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/get_if_set.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/post_by_default.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/resourceful_form.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/file_field.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/hidden_field.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/option_tag.html.erb +4 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/password_field.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/radio_button.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/radio_group.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/text_area.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/text_field.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hidden_field_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/hidden_field_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/hidden_field_specs/label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/label_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/label_specs/basic_with_attributes.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/label_specs/basic_with_class.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/layout/application.html.erb +11 -0
- data/lib/rango/helpers/spec/fixture/app/views/numeric_ext_specs/minutes_to_hours.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/numeric_ext_specs/to_concurrency_default.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/numeric_ext_specs/two_digits.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/array.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/clean.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/collection.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/multiple_selects.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/no_extra_attributes.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/optgroups.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/selected.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/with_blank.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/with_prompt.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/password_field_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/password_field_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/checked.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/unchecked.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/attributes.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/checked.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/hash.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/specific_attributes.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_span_specs/date_span_on_same_day.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_span_specs/date_span_on_same_day_on_different_year.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_date_with_year.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_date_without_year.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_today.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_tomorrow.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_yesterday.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/select_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/select_specs/blank.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/select_specs/multiple.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/select_specs/selected.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/submit_specs/disabled_submit.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/submit_specs/submit_with_label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/submit_specs/submit_with_values.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/tag_helper/nested_tags.html.erb +5 -0
- data/lib/rango/helpers/spec/fixture/app/views/tag_helper/tag_with_attributes.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/tag_helper/tag_with_content.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/tag_helper/tag_with_content_in_the_block.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_area_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_area_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_area_specs/label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_area_specs/nil.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/class.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/symbolized_name.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/config/environments/development.rb +6 -0
- data/lib/rango/helpers/spec/fixture/config/environments/production.rb +5 -0
- data/lib/rango/helpers/spec/fixture/config/environments/test.rb +6 -0
- data/lib/rango/helpers/spec/fixture/config/init.rb +46 -0
- data/lib/rango/helpers/spec/fixture/config/rack.rb +11 -0
- data/lib/rango/helpers/spec/fixture/config/router.rb +38 -0
- data/lib/rango/helpers/spec/fixture/public/images/merb.jpg +0 -0
- data/lib/rango/helpers/spec/fixture/public/merb.fcgi +4 -0
- data/lib/rango/helpers/spec/fixture/public/stylesheets/master.css +119 -0
- data/lib/rango/helpers/spec/merb_helpers_config_spec.rb +84 -0
- data/lib/rango/helpers/spec/merb_helpers_date_time_spec.rb +270 -0
- data/lib/rango/helpers/spec/merb_helpers_form_spec.rb +1371 -0
- data/lib/rango/helpers/spec/merb_helpers_tag_helper_spec.rb +42 -0
- data/lib/rango/helpers/spec/merb_helpers_text_spec.rb +69 -0
- data/lib/rango/helpers/spec/numeric_extlib_spec.rb +137 -0
- data/lib/rango/helpers/spec/ordinalize_spec.rb +53 -0
- data/lib/rango/helpers/spec/spec_helper.rb +160 -0
- data/lib/rango/helpers/spec/time_dsl_spec.rb +45 -0
- data/lib/rango/helpers/syntax.rb +28 -0
- data/lib/rango/loggers/fireruby.rb +1 -0
- data/lib/rango/loggers/logger.rb +100 -0
- data/lib/rango/mixins/application.rb +25 -0
- data/lib/rango/mixins/configurable.rb +20 -0
- data/lib/rango/mixins/controller.rb +113 -0
- data/lib/rango/mixins/import.rb +89 -0
- data/lib/rango/mixins/strategy.rb +28 -0
- data/lib/rango/mvc/controller.rb +139 -0
- data/lib/rango/mvc/strategies.rb +6 -0
- data/lib/rango/orm/adapters/datamapper/fields.rb +3 -0
- data/lib/rango/orm/adapters/datamapper/setup.rb +16 -0
- data/lib/rango/orm/adapters/datamapper/support.rb +15 -0
- data/lib/rango/orm/adapters/datamapper/tasks.thor +41 -0
- data/lib/rango/orm/adapters/datamapper/types/unicode_string.rb +15 -0
- data/lib/rango/project.rb +28 -0
- data/lib/rango/rack/dispatcher.rb +61 -0
- data/lib/rango/rack/middlewares/emails.rb +7 -0
- data/lib/rango/rack/middlewares/encoding.rb +25 -0
- data/lib/rango/rack/middlewares/static.rb +49 -0
- data/lib/rango/rack/request.rb +166 -0
- data/lib/rango/rango.rb +75 -0
- data/lib/rango/router/adapters/basic.rb +21 -0
- data/lib/rango/router/adapters/rack-router.rb +18 -0
- data/lib/rango/router/dispatcher.rb +29 -0
- data/lib/rango/router/specification.txt +16 -0
- data/lib/rango/settings.rb +87 -0
- data/lib/rango/settings/erubis.rb +13 -0
- data/lib/rango/settings/framework.rb +85 -0
- data/lib/rango/settings/haml.rb +35 -0
- data/lib/rango/support/cucumber/steps/given_steps.rb +5 -0
- data/lib/rango/support/cucumber/steps/then_steps.rb +41 -0
- data/lib/rango/support/cucumber/steps/when_steps.rb +54 -0
- data/lib/rango/tasks/bundle.thor +28 -0
- data/lib/rango/tasks/stats.thor +0 -0
- data/lib/rango/templates/adapter.rb +19 -0
- data/lib/rango/templates/adapters/erb.rb +45 -0
- data/lib/rango/templates/adapters/erubis.rb +60 -0
- data/lib/rango/templates/adapters/haml.rb +17 -0
- data/lib/rango/templates/template.rb +123 -0
- data/rango.gemspec +35 -0
- data/spec/factories.rb +21 -0
- data/spec/rango/auth/core/authenticated_helper_spec.rb +0 -0
- data/spec/rango/auth/core/authentication_spec.rb +0 -0
- data/spec/rango/auth/core/callbacks_spec.rb +0 -0
- data/spec/rango/auth/core/errors_spec.rb +0 -0
- data/spec/rango/auth/core/responses_spec.rb +0 -0
- data/spec/rango/auth/core/session_mixin_spec.rb +0 -0
- data/spec/rango/auth/core/spec/helpers/authentication_helper_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/activation_fixture_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/authentication_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/callbacks_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/customizations_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/errors_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/failed_login_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/merb-auth-core_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/router_helper_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/strategy_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/spec_helper_spec.rb +0 -0
- data/spec/rango/auth/core/strategy_spec.rb +0 -0
- data/spec/rango/auth/core_spec.rb +0 -0
- data/spec/rango/auth/more/mixins/redirect_back_spec.rb +0 -0
- data/spec/rango/auth/more/mixins/salted_user/ar_salted_user_spec.rb +0 -0
- data/spec/rango/auth/more/mixins/salted_user/dm_salted_user_spec.rb +0 -0
- data/spec/rango/auth/more/mixins/salted_user/relaxdb_salted_user_spec.rb +0 -0
- data/spec/rango/auth/more/mixins/salted_user/sq_salted_user_spec.rb +0 -0
- data/spec/rango/auth/more/mixins/salted_user_spec.rb +0 -0
- data/spec/rango/auth/more/spec/merb-auth-more_spec_spec.rb +0 -0
- data/spec/rango/auth/more/spec/mixins/redirect_back_spec_spec.rb +0 -0
- data/spec/rango/auth/more/spec/mixins/salted_user_spec_spec.rb +0 -0
- data/spec/rango/auth/more/spec/spec_helper_spec.rb +0 -0
- data/spec/rango/auth/more/strategies/abstract_password_spec.rb +0 -0
- data/spec/rango/auth/more/strategies/basic/basic_auth_spec.rb +0 -0
- data/spec/rango/auth/more/strategies/basic/openid_spec.rb +0 -0
- data/spec/rango/auth/more/strategies/basic/password_form_spec.rb +0 -0
- data/spec/rango/auth/more_spec.rb +0 -0
- data/spec/rango/auth/slice/exceptions_spec.rb +0 -0
- data/spec/rango/auth/slice/merb-auth-slice-password_spec.rb +0 -0
- data/spec/rango/auth/slice/sessions_spec.rb +0 -0
- data/spec/rango/auth/slice/spec_helper_spec.rb +0 -0
- data/spec/rango/auth/slice/xsessions_spec.rb +0 -0
- data/spec/rango/boot_spec.rb +19 -0
- data/spec/rango/bundling/dependency_spec.rb +0 -0
- data/spec/rango/bundling/strategies_spec.rb +0 -0
- data/spec/rango/cli/project_spec.rb +0 -0
- data/spec/rango/contrib/pagination/adapters/dm_spec.rb +0 -0
- data/spec/rango/contrib/pagination/helpers_spec.rb +0 -0
- data/spec/rango/contrib/pagination/page_spec.rb +94 -0
- data/spec/rango/contrib/pagination/strategies_spec.rb +0 -0
- data/spec/rango/contrib/pagination_spec.rb +0 -0
- data/spec/rango/contrib/syndication_spec.rb +0 -0
- data/spec/rango/exceptions_spec.rb +0 -0
- data/spec/rango/ext/attribute_spec.rb +0 -0
- data/spec/rango/ext/colored_string_spec.rb +0 -0
- data/spec/rango/ext/core_ext_spec.rb +0 -0
- data/spec/rango/ext/kernel_spec.rb +0 -0
- data/spec/rango/ext/path_spec.rb +0 -0
- data/spec/rango/ext/string_spec.rb +0 -0
- data/spec/rango/ext/thor_spec.rb +0 -0
- data/spec/rango/ext/time_dsl_spec.rb +0 -0
- data/spec/rango/ext_spec.rb +0 -0
- data/spec/rango/forms/form_spec.rb +0 -0
- data/spec/rango/generators_spec.rb +0 -0
- data/spec/rango/generic_views/static_spec.rb +0 -0
- data/spec/rango/helpers/assets_spec.rb +0 -0
- data/spec/rango/helpers/general_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/core_ext/numeric_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/core_ext_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/date_time_formatting_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/date_time_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/form/builder_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/form/helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/form_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/tag_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/text_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/time_dsl_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers_spec.rb +0 -0
- data/spec/rango/helpers/spec/core_ext_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/application_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_check_box_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_file_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_hidden_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_option_tag_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_password_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_radio_button_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_radio_group_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_select_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_text_area_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_text_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/button_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/check_box_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/custom_builder_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/delete_button_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/exceptions_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/field_set_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/fields_for_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/file_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/foo_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/form_for_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/form_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/hacker_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/hidden_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/label_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/numeric_ext_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/option_tag_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/password_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/radio_button_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/radio_group_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/relative_date_span_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/relative_date_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/select_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/specs_controller_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/submit_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/tag_helper_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/text_area_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/text_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/helpers/global_helpers_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/models/fake_dm_model_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/models/first_generic_fake_model_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/models/hacker_generic_model_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/models/second_generic_fake_model_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/models/third_generic_fake_model_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/config/environments/development_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/config/environments/production_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/config/environments/test_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/config/init_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/config/rack_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/config/router_spec.rb +0 -0
- data/spec/rango/helpers/spec/merb_helpers_config_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/merb_helpers_date_time_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/merb_helpers_form_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/merb_helpers_tag_helper_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/merb_helpers_text_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/numeric_extlib_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/ordinalize_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/spec_helper_spec.rb +0 -0
- data/spec/rango/helpers/spec/time_dsl_spec_spec.rb +0 -0
- data/spec/rango/helpers/syntax_spec.rb +0 -0
- data/spec/rango/helpers_spec.rb +0 -0
- data/spec/rango/loggers/fireruby_spec.rb +0 -0
- data/spec/rango/loggers/logger_spec.rb +0 -0
- data/spec/rango/mixins/application_spec.rb +0 -0
- data/spec/rango/mixins/controller_spec.rb +0 -0
- data/spec/rango/mixins/import_spec.rb +0 -0
- data/spec/rango/mvc/controller_spec.rb +24 -0
- data/spec/rango/mvc/strategies_spec.rb +0 -0
- data/spec/rango/orm/adapters/dm/fields_spec.rb +0 -0
- data/spec/rango/orm/adapters/dm/setup_spec.rb +0 -0
- data/spec/rango/project_spec.rb +46 -0
- data/spec/rango/rack/dispatcher_spec.rb +0 -0
- data/spec/rango/rack/middlewares/emails_spec.rb +0 -0
- data/spec/rango/rack/middlewares/static_spec.rb +0 -0
- data/spec/rango/rack/request_spec.rb +18 -0
- data/spec/rango/rango_spec.rb +0 -0
- data/spec/rango/router/route_spec.rb +0 -0
- data/spec/rango/router/router_spec.rb +0 -0
- data/spec/rango/router/strategies_spec.rb +0 -0
- data/spec/rango/settings_spec.rb +26 -0
- data/spec/rango/spec/cucumber_spec.rb +0 -0
- data/spec/rango/spec/rspec_spec.rb +0 -0
- data/spec/rango/templates/adapter_spec.rb +0 -0
- data/spec/rango/templates/adapters/erb_spec.rb +0 -0
- data/spec/rango/templates/adapters/erubis_spec.rb +0 -0
- data/spec/rango/templates/adapters/haml_spec.rb +0 -0
- data/spec/rango/templates/template_spec.rb +0 -0
- data/spec/rango_spec.rb +37 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/stubs/flat.rb +0 -0
- data/stubs/app/content/init.rb.rbt +6 -0
- data/stubs/app/content/models.rb.rbt +9 -0
- data/stubs/app/content/views.rb.rbt +10 -0
- data/stubs/app/preprocess.rb +13 -0
- data/stubs/bigapp/content/init.rb +0 -0
- data/stubs/bigapp/content/views/application.rb +0 -0
- data/stubs/bigapp/preprocess.rb +5 -0
- data/stubs/features/content/env.rb +36 -0
- data/stubs/flat/content/flat.ru.rbt +19 -0
- data/stubs/flat/preprocess.rb +5 -0
- data/stubs/project/content/TODO +0 -0
- data/stubs/project/content/Thorfile +12 -0
- data/stubs/project/content/config.ru +34 -0
- data/stubs/project/content/init.rb +14 -0
- data/stubs/project/content/settings.rb.rbt +10 -0
- data/stubs/project/content/settings_local.rb.rbt +6 -0
- data/stubs/project/content/templates/base.html.haml.rbt +29 -0
- data/stubs/project/preprocess.rb +5 -0
- data/stubs/pupu/preprocess.rb +5 -0
- data/stubs/stub/content/metadata.yml +2 -0
- data/stubs/stub/content/postprocess.rb +7 -0
- data/stubs/stub/content/preprocess.rb +5 -0
- data/stubs/stub/preprocess.rb +5 -0
- data/support/Rango.tmbundle/Commands/Documentation for current word.tmCommand +22 -0
- data/support/Rango.tmbundle/Commands/Got to import.tmCommand +23 -0
- data/support/Rango.tmbundle/Commands/Rango console.tmCommand +22 -0
- data/support/Rango.tmbundle/Commands/Rango server.tmCommand +22 -0
- data/support/Rango.tmbundle/Commands/Read documentation.tmCommand +22 -0
- data/support/Rango.tmbundle/Snippets/Method with yardoc.tmSnippet +20 -0
- data/support/Rango.tmbundle/Snippets/Project_configure.tmSnippet +18 -0
- data/support/Rango.tmbundle/Snippets/Project_import.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Project_logger_debug.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Project_logger_error.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Project_logger_fatal.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Project_logger_inspect.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Project_logger_warn.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_dependency.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_import.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_logger_debug.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_logger_error.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_logger_fatal.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_logger_inspect.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_logger_warn.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/controller.tmSnippet +28 -0
- data/support/Rango.tmbundle/Snippets/doc.tmSnippet +20 -0
- data/support/Rango.tmbundle/Snippets/match.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/thor task.tmSnippet +19 -0
- data/support/Rango.tmbundle/info.plist +37 -0
- data/support/hooks/commit-msg +13 -0
- data/support/hooks/post-commit +4 -0
- data/support/hooks/pre-commit +4 -0
- data/support/hooks/pre-rebase +169 -0
- data/support/hooks/prepare-commit-msg +36 -0
- data/tasks/hooks.thor +26 -0
- data/tasks/package.thor +49 -0
- data/tasks/release.thor +72 -0
- data/tasks/repair.thor +75 -0
- data/tasks/spec.thor +39 -0
- data/tasks/stats.thor +66 -0
- data/tasks/yardoc.thor +16 -0
- data/templates/errors/404.html.erb +52 -0
- data/templates/errors/406.html.erb +1 -0
- data/templates/errors/500.html.erb +48 -0
- metadata +866 -0
|
@@ -0,0 +1,1371 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
4
|
+
|
|
5
|
+
# Quick rundown of how these specs work
|
|
6
|
+
# please read before hacking on this plugin
|
|
7
|
+
#
|
|
8
|
+
# helpers must be tested through then entire stack
|
|
9
|
+
# what that means is that each spec must
|
|
10
|
+
# send a request to a controller and render a template
|
|
11
|
+
#
|
|
12
|
+
# Start by creating a spec controller subclassing SpecController
|
|
13
|
+
# which itself is a subclass of Rango::Controller
|
|
14
|
+
# specs_controller.rb (available at spec/fixture/app/controllers/specs_controller.rb)
|
|
15
|
+
# defines SpecController.
|
|
16
|
+
# Create a new controller in the spec/fixture/app/controllers/ if you are adding a new helper
|
|
17
|
+
#
|
|
18
|
+
# To test your helper, start by initializing a controller
|
|
19
|
+
#
|
|
20
|
+
# @controller = CustomHelperSpecs.new(Rango::Request.new({}))
|
|
21
|
+
#
|
|
22
|
+
# Note that we are sending a real request to the controller, feel free to use the request as needed
|
|
23
|
+
#
|
|
24
|
+
# You might need to access real objects in your views
|
|
25
|
+
# you can do that by setting them up in the controller
|
|
26
|
+
#
|
|
27
|
+
# @obj = FakeModel.new # FaKeModel is defined in spec/fixture/models/first_generic_fake_model.rb check it out!
|
|
28
|
+
# @controller.instance_variable_set(:@obj, @obj)
|
|
29
|
+
#
|
|
30
|
+
# To test a helper, you need to render a view:
|
|
31
|
+
#
|
|
32
|
+
# result = @controller.render :view_name
|
|
33
|
+
#
|
|
34
|
+
# Of course, you need to create a view:
|
|
35
|
+
# spec/fixture/app/views/custom_helper_specs/view_name.html.erb
|
|
36
|
+
# in the view, call the helper you want to test
|
|
37
|
+
#
|
|
38
|
+
# You can now test the helper in the view:
|
|
39
|
+
# result.should match_tag(:form, :method => "post")
|
|
40
|
+
#
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Rango::Plugins.config[:helpers] = {
|
|
44
|
+
:default_builder => Rango::Helpers::Form::Builder::FormWithErrors
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
describe "error_messages_for" do
|
|
48
|
+
|
|
49
|
+
before :each do
|
|
50
|
+
@c = Application.new({})
|
|
51
|
+
@dm_obj = Object.new
|
|
52
|
+
@sq_obj = Object.new
|
|
53
|
+
@dm_errors = [["foo", "bar"],["baz","bat"]]
|
|
54
|
+
@sq_errors = Object.new
|
|
55
|
+
@sq_errors.stub!(:full_messages).and_return(["foo", "baz"])
|
|
56
|
+
@dm_obj.stub!(:errors).and_return(@dm_errors)
|
|
57
|
+
@dm_obj.stub!(:new_record?).and_return(false)
|
|
58
|
+
@sq_obj.stub!(:errors).and_return(@sq_errors)
|
|
59
|
+
@sq_obj.stub!(:new_record?).and_return(false)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should build default error messages for AR-like models" do
|
|
63
|
+
errs = @c.error_messages_for(@dm_obj)
|
|
64
|
+
errs.should include("<h2>Form submission failed because of 2 problems</h2>")
|
|
65
|
+
errs.should include("<li>foo bar</li>")
|
|
66
|
+
errs.should include("<li>baz bat</li>")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "should build default error messages for Sequel-like models" do
|
|
70
|
+
errs = @c.error_messages_for(@sq_obj)
|
|
71
|
+
errs.should include("<h2>Form submission failed because of 2 problems</h2>")
|
|
72
|
+
errs.should include("<li>foo</li>")
|
|
73
|
+
errs.should include("<li>baz</li>")
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# it "should build default error messages for symbol" do
|
|
77
|
+
# errs = error_messages_for(:obj)
|
|
78
|
+
# errs.should include("<h2>Form submittal failed because of 2 problems</h2>")
|
|
79
|
+
# errs.should include("<li>foo bar</li>")
|
|
80
|
+
# errs.should include("<li>baz bat</li>")
|
|
81
|
+
# end
|
|
82
|
+
|
|
83
|
+
it "should accept a custom HTML class" do
|
|
84
|
+
errs = @c.error_messages_for(@dm_obj, :error_class => "foo")
|
|
85
|
+
errs.should include("<div class='foo'>")
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "should accept a custom header block" do
|
|
89
|
+
errs = @c.error_messages_for(@dm_obj, :header => "<h3>Failure: %s issue%s</h3>")
|
|
90
|
+
errs.should include("<h3>Failure: 2 issues</h3>")
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# it "should put the error messages inside a form if :before is false" do
|
|
94
|
+
# ret = @c.form_for @dm_obj do
|
|
95
|
+
# _buffer << error_messages
|
|
96
|
+
# end
|
|
97
|
+
# ret.should =~ /\A\s*<form.*<div class='error'>/
|
|
98
|
+
# end
|
|
99
|
+
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe "form" do
|
|
103
|
+
|
|
104
|
+
before :each do
|
|
105
|
+
@c = FormSpecs.new(Rango::Request.new({}))
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
describe "when _default_builder is Rango::Helpers::Form::Builder::ResourcefulFormWithErrors" do
|
|
109
|
+
|
|
110
|
+
before(:each) do
|
|
111
|
+
@obj = FakeModel2.new
|
|
112
|
+
@c.instance_variable_set(:@obj, @obj)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "should not explode when #form is called" do
|
|
116
|
+
r = @c.render :resourceful_form
|
|
117
|
+
pending
|
|
118
|
+
#r.should =~ /action="fake_model2\/#{@obj.id}"/
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
it "should use the post method by default" do
|
|
124
|
+
ret = @c.render(:post_by_default)
|
|
125
|
+
ret.should have_selector("form[method=post]")
|
|
126
|
+
ret.should include("CONTENT")
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "should use the get method if set" do
|
|
130
|
+
ret = @c.render(:get_if_set)
|
|
131
|
+
ret.should have_selector("form[method=get]")
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "should fake out the put method if set" do
|
|
135
|
+
ret = @c.render(:fake_put_if_set)
|
|
136
|
+
ret.should have_selector("form[method=post]")
|
|
137
|
+
ret.should have_selector("input[type=hidden][name=_method][value=put]")
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "should fake out the delete method if set" do
|
|
141
|
+
ret = @c.render(:fake_delete_if_set)
|
|
142
|
+
ret.should have_selector("form[method=post]")
|
|
143
|
+
ret.should have_selector("input[type=hidden][name=_method][value=delete]")
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# TODO: Why is this required?
|
|
147
|
+
# ---------------------------
|
|
148
|
+
#
|
|
149
|
+
# it "should silently set method to post if an unsupported method is used" do
|
|
150
|
+
# form_tag :method => :dodgy do
|
|
151
|
+
# _buffer << "CONTENT"
|
|
152
|
+
# end
|
|
153
|
+
# _buffer.should match_tag(:form, :method => "post")
|
|
154
|
+
# _buffer.should_not match_tag(:input, :type => "hidden", :name => "_method", :value => "dodgy")
|
|
155
|
+
# end
|
|
156
|
+
|
|
157
|
+
it "should take create a form" do
|
|
158
|
+
ret = @c.render(:create_a_form)
|
|
159
|
+
ret.should have_selector("form[action=foo][method=post]")
|
|
160
|
+
ret.should include("Hello")
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it "should set a form to be multipart" do
|
|
164
|
+
ret = @c.render(:create_a_multipart_form)
|
|
165
|
+
ret.should have_selector("form[action=foo][method=post][enctype='multipart/form-data']")
|
|
166
|
+
ret.should include("CONTENT")
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
describe "form_for" do
|
|
172
|
+
|
|
173
|
+
before :each do
|
|
174
|
+
@c = FormForSpecs.new(Rango::Request.new({}))
|
|
175
|
+
@c.instance_variable_set(:@obj, FakeModel.new)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it "should wrap the contents in a form tag" do
|
|
179
|
+
form = @c.render :basic
|
|
180
|
+
form.should have_selector("form[method=post]")
|
|
181
|
+
form.should have_selector("input[type=hidden][value=put][name=_method]")
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it "should set the method to post be default" do
|
|
185
|
+
new_fake_model = FakeModel2.new
|
|
186
|
+
@c.instance_variable_set(:@obj, new_fake_model)
|
|
187
|
+
form = @c.render :basic
|
|
188
|
+
form.should have_selector("form[method=post]")
|
|
189
|
+
form.should_not have_selector("input[type=hidden][name=_method]")
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
it "should support PUT if the object passed in is not a new_record? via a hidden field" do
|
|
193
|
+
form = @c.render :basic
|
|
194
|
+
form.should have_selector("form[method=post]")
|
|
195
|
+
form.should have_selector("input[type=hidden][value=put][name=_method]")
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
describe "fields_for" do
|
|
202
|
+
|
|
203
|
+
before :each do
|
|
204
|
+
@c = FieldsForSpecs.new(Rango::Request.new({}))
|
|
205
|
+
@c.instance_variable_set(:@obj, FakeModel.new)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
it "should dump the contents in the context of the object" do
|
|
210
|
+
r = @c.render :basic
|
|
211
|
+
r.should have_selector("input[type=text][value=foowee]")
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
it "should be able to modify the context midstream" do
|
|
215
|
+
@c.instance_variable_set(:@obj2, FakeModel2.new)
|
|
216
|
+
r = @c.render :midstream
|
|
217
|
+
r.should have_selector("input[type=text][value=foowee]")
|
|
218
|
+
r.should have_selector("input[name='fake_model2[foo]'][type=text][value=foowee2]")
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
it "should handle an explicit nil attribute" do
|
|
222
|
+
r = @c.render :nil
|
|
223
|
+
r.should have_selector("input[name='fake_model[foo]'][value=foowee][type=text]")
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
it "should pass context back to the old object after exiting block" do
|
|
227
|
+
@c.instance_variable_set(:@obj2, FakeModel2.new)
|
|
228
|
+
r = @c.render :midstream
|
|
229
|
+
r.should have_selector("input[id=fake_model_foo][name='fake_model[foo]'][type=text][extra=true]")
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
describe "text_field" do
|
|
234
|
+
|
|
235
|
+
before :each do
|
|
236
|
+
@c = TextFieldSpecs.new(Rango::Request.new({}))
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
it "should return a basic text field based on the values passed in" do
|
|
240
|
+
r = @c.render :basic
|
|
241
|
+
r.should have_selector("input[type=text][id=foo][name=foo][value=bar]")
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
it "should update an existing :class with a new class" do
|
|
245
|
+
r = @c.render :class
|
|
246
|
+
r.should == "<input type=\"text\" class=\"awesome foobar text\"/>"
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
it "should be disabled if :disabled => true is passed in" do
|
|
250
|
+
r = @c.render :disabled
|
|
251
|
+
r.should have_selector("input[type=text][disabled=disabled]")
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
it "should provide an additional label tag if the :label option is passed in as a hash" do
|
|
255
|
+
r = @c.render :label
|
|
256
|
+
r.should have_selector("label[class=cool][for=foo]:contains('LABEL')")
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
it "should allow a symbolized name" do
|
|
260
|
+
r = @c.render :symbolized_name
|
|
261
|
+
r.should have_selector("input[type=text][name=foo][value=bar]")
|
|
262
|
+
r.should have_selector("label[for=foo]:contains('LABEL')")
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
describe "bound_text_field" do
|
|
267
|
+
|
|
268
|
+
before :each do
|
|
269
|
+
@c = BoundTextFieldSpecs.new(Rango::Request.new({}))
|
|
270
|
+
@c.instance_variable_set(:@obj, FakeModel.new)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
it "should take a string object and return a useful text control" do
|
|
274
|
+
r = @c.render :basic
|
|
275
|
+
r.should have_selector("input[type=text][id=fake_model_foo][name='fake_model[foo]'][value=foowee]")
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
it "should take additional attributes and use them" do
|
|
279
|
+
r = @c.render :basic
|
|
280
|
+
r.should have_selector("input[type=text][name='fake_model[foo]'][value=foowee][bar='7']")
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
it "should provide an additional label tag if the :label option is passed in" do
|
|
284
|
+
form = @c.render :basic
|
|
285
|
+
form.should match(/<label.*>LABEL<\/label><input/)
|
|
286
|
+
form.should_not have_selector("input[label=LABEL]")
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
it "should render the label tag with the proper for= atttribute" do
|
|
290
|
+
form = @c.render :basic
|
|
291
|
+
form.should have_selector("label[for=fake_model_foo]:contains('LABEL')")
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
it "should not errorify the field for a new object" do
|
|
295
|
+
r = @c.render :basic
|
|
296
|
+
r.should_not have_selector("input[type=text][name='fake_model[foo]'][class=error]")
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
it "should errorify a field for a model with errors" do
|
|
300
|
+
model = mock("model")
|
|
301
|
+
model.stub!(:new_record?).and_return(true)
|
|
302
|
+
model.stub!(:class).and_return("MyClass")
|
|
303
|
+
model.stub!(:foo).and_return("FOO")
|
|
304
|
+
errors = mock("errors")
|
|
305
|
+
errors.should_receive(:on).with(:foo).and_return(true)
|
|
306
|
+
|
|
307
|
+
model.stub!(:errors).and_return(errors)
|
|
308
|
+
@c.instance_variable_set(:@obj, model)
|
|
309
|
+
r = @c.render :basic
|
|
310
|
+
r.should have_selector("input[class='error text']")
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
describe "bound_radio_button" do
|
|
315
|
+
|
|
316
|
+
before :each do
|
|
317
|
+
@c = BoundRadioButtonSpecs.new(Rango::Request.new({}))
|
|
318
|
+
@c.instance_variable_set(:@obj, FakeModel.new)
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
it "should take a string object and return a useful text control" do
|
|
322
|
+
r = @c.render :basic
|
|
323
|
+
r.should have_selector("input[type=radio][id=fake_model_foo][name='fake_model[foo]'][value=foowee]")
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
it "should take additional attributes and use them" do
|
|
327
|
+
r = @c.render :basic
|
|
328
|
+
r.should have_selector("input[type=radio][name='fake_model[foo]'][value=foowee][bar='7']")
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
it "should provide an additional label tag if the :label option is passed in" do
|
|
332
|
+
form = @c.render :basic
|
|
333
|
+
form.should have_selector("input + label:contains('LABEL')")
|
|
334
|
+
form.should_not have_selector("input[label]")
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
it "should render the label tag with the proper for= atttribute" do
|
|
338
|
+
form = @c.render :basic
|
|
339
|
+
form.should have_selector("label[for=fake_model_foo]:contains('LABEL')")
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
it "should not errorify the field for a new object" do
|
|
343
|
+
r = @c.render :basic
|
|
344
|
+
r.should_not have_selector("input[type=radio][name='fake_model[foo]'][class=error]")
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
it "should errorify a field for a model with errors" do
|
|
348
|
+
model = mock("model")
|
|
349
|
+
model.stub!(:new_record?).and_return(true)
|
|
350
|
+
model.stub!(:class).and_return("MyClass")
|
|
351
|
+
model.stub!(:foo).and_return("FOO")
|
|
352
|
+
errors = mock("errors")
|
|
353
|
+
errors.should_receive(:on).with(:foo).and_return(true)
|
|
354
|
+
|
|
355
|
+
model.stub!(:errors).and_return(errors)
|
|
356
|
+
@c.instance_variable_set(:@obj, model)
|
|
357
|
+
r = @c.render :basic
|
|
358
|
+
r.should have_selector("input[class='error radio']")
|
|
359
|
+
end
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
describe "password_field" do
|
|
363
|
+
|
|
364
|
+
before :each do
|
|
365
|
+
@c = PasswordFieldSpecs.new(Rango::Request.new({}))
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
it "should return a basic password field, but omit the value" do
|
|
369
|
+
r = @c.render :basic
|
|
370
|
+
r.should have_selector("input[type=password][id=foo][name=foo]")
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
it "should provide an additional label tag if the :label option is passed in" do
|
|
374
|
+
r = @c.render :basic
|
|
375
|
+
r.should have_selector("label[for=foo]:contains('LABEL')")
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
it "should be disabled if :disabled => true is passed in" do
|
|
379
|
+
r = @c.render :disabled
|
|
380
|
+
r.should match_tag(:input, :type => "password", :disabled => "disabled")
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
describe "bound_password_field" do
|
|
385
|
+
|
|
386
|
+
before :each do
|
|
387
|
+
@c = BoundPasswordFieldSpecs.new(Rango::Request.new({}))
|
|
388
|
+
@obj = FakeModel.new
|
|
389
|
+
@c.instance_variable_set(:@obj, @obj)
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
it "should take a string object and return a useful password control, but omit the value" do
|
|
393
|
+
r = @c.render :basic
|
|
394
|
+
r.should match_tag(:input, :type => "password", :id => "fake_model_foo", :name => "fake_model[foo]")
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
it "should take additional attributes and use them" do
|
|
398
|
+
r = @c.render :basic
|
|
399
|
+
r.should match_tag(:input, :type => "password", :name => "fake_model[foo]", :bar => "7", :value => @obj.foo)
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
it "should provide an additional label tag if the :label option is passed in" do
|
|
403
|
+
r = @c.render :basic
|
|
404
|
+
r.should match(/<label.*>LABEL<\/label><input/)
|
|
405
|
+
r.should_not match_tag(:input, :label => "LABEL")
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
it "should render the label tag with the proper for= atttribute" do
|
|
409
|
+
form = @c.render :basic
|
|
410
|
+
form.should have_selector("label[for=fake_model_foo]:contains('LABEL')")
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
it "should not errorify the field for a new object" do
|
|
414
|
+
r = @c.render :basic
|
|
415
|
+
r.should_not match_tag(:input, :class => "error")
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
it "should errorify a field for a model with errors" do
|
|
419
|
+
model = mock("model")
|
|
420
|
+
model.stub!(:new_record?).and_return(true)
|
|
421
|
+
model.stub!(:class).and_return("MyClass")
|
|
422
|
+
model.stub!(:foo).and_return("FOO")
|
|
423
|
+
errors = mock("errors")
|
|
424
|
+
errors.should_receive(:on).with(:foo).and_return(true)
|
|
425
|
+
|
|
426
|
+
model.stub!(:errors).and_return(errors)
|
|
427
|
+
|
|
428
|
+
@c.instance_variable_set(:@obj, model)
|
|
429
|
+
r = @c.render :basic
|
|
430
|
+
r.should match_tag(:input, :class => "error password")
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
describe "check_box" do
|
|
436
|
+
|
|
437
|
+
before :each do
|
|
438
|
+
@c = CheckBoxSpecs.new(Rango::Request.new({}))
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
it "should return a basic checkbox based on the values passed in" do
|
|
442
|
+
r = @c.render :basic
|
|
443
|
+
r.should match_tag(:input, :class => "checkbox", :id => "foo", :name => "foo", :checked => "checked")
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
it "should provide an additional label tag if the :label option is passed in" do
|
|
447
|
+
result = @c.render :label
|
|
448
|
+
result.should have_selector("label[for=foo]:contains('LABEL')")
|
|
449
|
+
|
|
450
|
+
result.should match(/<input.*><label/)
|
|
451
|
+
res = result.scan(/<[^>]*>/)
|
|
452
|
+
res[0].should_not match_tag(:input, :label => "LABEL")
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
it 'should remove the checked="checked" attribute if :checked is false or nil' do
|
|
456
|
+
r = @c.render :unchecked
|
|
457
|
+
r.should_not include('checked="')
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
it 'should have the checked="checked" attribute if :checked => true is passed in' do
|
|
461
|
+
r = @c.render :basic
|
|
462
|
+
r.should include('checked="checked"')
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
it "should not be boolean by default" do
|
|
466
|
+
r = @c.render :basic
|
|
467
|
+
r.should match_tag(:input, :type => "checkbox", :name => "foo")
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
it "should add a hidden input if boolean" do
|
|
471
|
+
r = @c.render :boolean
|
|
472
|
+
r.should have_tag(:input, :type => "checkbox", :value => "1")
|
|
473
|
+
r.should have_tag(:input, :type => "hidden", :value => "0")
|
|
474
|
+
r.should match(/<input.*?type="hidden"[^>]*>[^<]*<input.*?type="checkbox"[^>]*>/)
|
|
475
|
+
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
it "should not allow a :value param if boolean" do
|
|
479
|
+
lambda { @c.render :raises_error_if_not_boolean }.
|
|
480
|
+
should raise_error(ArgumentError, /can't be used with a boolean checkbox/)
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
it "should not allow :boolean => false if :on and :off are specified" do
|
|
484
|
+
lambda { @c.render :raises_error_if_on_off_and_boolean_false }.
|
|
485
|
+
should raise_error(ArgumentError, /cannot be used/)
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
it "should be boolean if :on and :off are specified" do
|
|
489
|
+
html = @c.render :on_off_is_boolean
|
|
490
|
+
html.should have_tag(:input, :type => "checkbox", :value => "YES", :name => "foo")
|
|
491
|
+
html.should have_tag(:input, :type => "hidden", :value => "NO", :name => "foo")
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
it "should have both :on and :off specified or neither" do
|
|
495
|
+
lambda { @c.render :raise_unless_both_on_and_off }.should raise_error(ArgumentError, /must be specified/)
|
|
496
|
+
lambda { @c.render :raise_unless_both_on_and_off }.should raise_error(ArgumentError, /must be specified/)
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
it "should convert :value to a string on a non-boolean checkbox" do
|
|
500
|
+
r = @c.render :to_string
|
|
501
|
+
r.should match_tag(:input, :value => "")
|
|
502
|
+
r.should match_tag(:input, :value => "false")
|
|
503
|
+
r.should match_tag(:input, :value => "0")
|
|
504
|
+
r.should match_tag(:input, :value => "0")
|
|
505
|
+
r.should match_tag(:input, :value => "1")
|
|
506
|
+
r.should match_tag(:input, :value => "1")
|
|
507
|
+
r.should match_tag(:input, :value => "true")
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
it "should be disabled if :disabled => true is passed in" do
|
|
511
|
+
r = @c.render :disabled
|
|
512
|
+
r.should match_tag(:input, :type => "checkbox", :disabled => "disabled")
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
it "should be possible to call with just check_box" do
|
|
516
|
+
r = @c.render :simple
|
|
517
|
+
r.should match_tag(:input, :type => "checkbox", :class => "checkbox")
|
|
518
|
+
end
|
|
519
|
+
end
|
|
520
|
+
|
|
521
|
+
describe "bound_check_box" do
|
|
522
|
+
|
|
523
|
+
before :each do
|
|
524
|
+
@c = BoundCheckBoxSpecs.new(Rango::Request.new({}))
|
|
525
|
+
@c.instance_variable_set(:@obj, FakeModel.new)
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
it "should take a string and return a useful checkbox control" do
|
|
529
|
+
r = @c.render :basic
|
|
530
|
+
r.should match_tag(:input, :type =>"checkbox", :id => "fake_model_baz", :name => "fake_model[baz]", :class => "checkbox", :value => "1", :checked => "checked", :id => "fake_model_baz")
|
|
531
|
+
r.should match_tag(:input, :type =>"hidden", :name => "fake_model[baz]", :value => "0")
|
|
532
|
+
end
|
|
533
|
+
|
|
534
|
+
it "should raise an error if you try to use :value" do
|
|
535
|
+
lambda { @c.render(:raise_value_error) }.should raise_error(ArgumentError, /:value can't be used with a bound_check_box/)
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
it "should support models from datamapper" do
|
|
539
|
+
@c.instance_variable_set(:@obj, FakeDMModel.new)
|
|
540
|
+
r = @c.render :basic
|
|
541
|
+
r.should match_tag(:input,
|
|
542
|
+
:type =>"checkbox",
|
|
543
|
+
:name => "fake_dm_model[baz]",
|
|
544
|
+
:class => "checkbox",
|
|
545
|
+
:value => "1",
|
|
546
|
+
:checked => "checked",
|
|
547
|
+
:id => "fake_dm_model_baz")
|
|
548
|
+
|
|
549
|
+
r.should match_tag(:input, :type =>"hidden", :name => "fake_dm_model[bat]", :value => "0")
|
|
550
|
+
r.should match_tag(:input, :type =>"checkbox", :name => "fake_dm_model[bat]", :class => "checkbox", :value => "1")
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
it "should allow a user to set the :off value" do
|
|
554
|
+
r = @c.render :on_and_off
|
|
555
|
+
r.should match_tag(:input, :type =>"hidden", :name => "fake_model[bat]", :value => "off")
|
|
556
|
+
r.should match_tag(:input, :type =>"checkbox", :name => "fake_model[bat]", :class => "checkbox", :value => "on")
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
it "should render controls with errors if their attribute contains an error" do
|
|
560
|
+
r = @c.render :errors
|
|
561
|
+
r.should match_tag(:input, :type =>"checkbox", :name => "fake_model[bazbad]", :class => "error checkbox", :value => "1", :checked => "checked")
|
|
562
|
+
r.should match_tag(:input, :type =>"hidden", :name => "fake_model[batbad]", :value => "0")
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
it "should provide an additional label tag if the :label option is passed in" do
|
|
566
|
+
form = @c.render :label
|
|
567
|
+
form.should match( /<input.*><label.*>LABEL<\/label>/ )
|
|
568
|
+
form.should_not match_tag(:input, :label => "LABEL")
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
it "should render the label tag with the proper for= atttribute" do
|
|
572
|
+
form = @c.render :label
|
|
573
|
+
form.should have_selector("label[for=fake_model_foo]:contains('LABEL')")
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
it "should not errorify the field for a new object" do
|
|
577
|
+
r = @c.render :basic
|
|
578
|
+
r.should_not match_tag(:input, :type => "checkbox", :class => "error checkbox")
|
|
579
|
+
end
|
|
580
|
+
|
|
581
|
+
it "should errorify a field for a model with errors" do
|
|
582
|
+
model = mock("model")
|
|
583
|
+
model.stub!(:new_record?).and_return(true)
|
|
584
|
+
model.stub!(:class).and_return("MyClass")
|
|
585
|
+
model.stub!(:baz).and_return("BAZ")
|
|
586
|
+
model.stub!(:bat).and_return("BAT")
|
|
587
|
+
errors = mock("errors")
|
|
588
|
+
errors.should_receive(:on).with(:baz).and_return(true)
|
|
589
|
+
errors.should_receive(:on).with(:bat).and_return(true)
|
|
590
|
+
|
|
591
|
+
model.stub!(:errors).and_return(errors)
|
|
592
|
+
|
|
593
|
+
@c.instance_variable_set(:@obj, model)
|
|
594
|
+
r = @c.render :basic
|
|
595
|
+
r.should match_tag(:input, :type => "checkbox", :class => "error checkbox")
|
|
596
|
+
end
|
|
597
|
+
|
|
598
|
+
it "should be boolean" do
|
|
599
|
+
r = @c.render :basic
|
|
600
|
+
r.should have_tag(:input, :type => "checkbox", :value => "1")
|
|
601
|
+
r.should have_tag(:input, :type => "hidden", :value => "0")
|
|
602
|
+
end
|
|
603
|
+
|
|
604
|
+
it "should be checked if the value of the model's attribute is equal to the value of :on" do
|
|
605
|
+
r = @c.render :checked
|
|
606
|
+
r.should match_tag(:input, :type =>"checkbox", :value => "foowee", :checked => "checked")
|
|
607
|
+
r.should match_tag(:input, :type =>"checkbox", :value => "YES")
|
|
608
|
+
end
|
|
609
|
+
|
|
610
|
+
it "should render false attributes as not checked" do
|
|
611
|
+
@c.instance_variable_set(:@obj, FakeDMModel.new)
|
|
612
|
+
r = @c.render :basic_unchecked
|
|
613
|
+
r.should match_tag(:input, :type =>"checkbox", :name => "fake_dm_model[bat]")
|
|
614
|
+
r.should_not include("checked=")
|
|
615
|
+
end
|
|
616
|
+
end
|
|
617
|
+
|
|
618
|
+
describe "hidden_field" do
|
|
619
|
+
|
|
620
|
+
before :each do
|
|
621
|
+
@c = HiddenFieldSpecs.new(Rango::Request.new({}))
|
|
622
|
+
end
|
|
623
|
+
|
|
624
|
+
it "should return a basic checkbox based on the values passed in" do
|
|
625
|
+
r = @c.render :basic
|
|
626
|
+
r.should match_tag(:input, :type => "hidden", :id => "foo", :name => "foo", :value => "bar")
|
|
627
|
+
end
|
|
628
|
+
|
|
629
|
+
it "should not render a label if the :label option is passed in" do
|
|
630
|
+
res = @c.render :label
|
|
631
|
+
res.should_not match(/<label>LABEL/)
|
|
632
|
+
res.should_not match_tag(:input, :label=> "LABEL")
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
it "should be disabled if :disabled => true is passed in" do
|
|
636
|
+
r = @c.render :disabled
|
|
637
|
+
r.should match_tag(:input, :type => "hidden", :disabled => "disabled")
|
|
638
|
+
end
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
describe "bound_hidden_field" do
|
|
642
|
+
|
|
643
|
+
before :each do
|
|
644
|
+
@c = BoundHiddenFieldSpecs.new(Rango::Request.new({}))
|
|
645
|
+
@c.instance_variable_set(:@obj, FakeModel.new)
|
|
646
|
+
end
|
|
647
|
+
|
|
648
|
+
it "should take a string and return a hidden field control" do
|
|
649
|
+
r = @c.render :basic
|
|
650
|
+
r.should match_tag(:input, :type =>"hidden", :id => "fake_model_foo", :name => "fake_model[foo]", :value => "foowee")
|
|
651
|
+
end
|
|
652
|
+
|
|
653
|
+
it "should render controls with errors if their attribute contains an error" do
|
|
654
|
+
r = @c.render :errors
|
|
655
|
+
r.should match_tag(:input, :type =>"hidden", :name => "fake_model[foobad]", :value => "foowee", :class => "error hidden")
|
|
656
|
+
end
|
|
657
|
+
|
|
658
|
+
it "should not render a label if the :label option is passed in" do
|
|
659
|
+
r = @c.render :label
|
|
660
|
+
r.should_not match(/<label>LABEL/)
|
|
661
|
+
r.should_not match_tag(:input, :label=> "LABEL")
|
|
662
|
+
end
|
|
663
|
+
|
|
664
|
+
it "should not errorify the field for a new object" do
|
|
665
|
+
r = @c.render :basic
|
|
666
|
+
r.should_not match_tag(:input, :type => "hidden", :class => "error")
|
|
667
|
+
end
|
|
668
|
+
|
|
669
|
+
it "should not errorify a field for a model with errors" do
|
|
670
|
+
model = mock("model")
|
|
671
|
+
model.stub!(:new_record?).and_return(true)
|
|
672
|
+
model.stub!(:class).and_return("MyClass")
|
|
673
|
+
model.stub!(:foo).and_return("FOO")
|
|
674
|
+
errors = mock("errors")
|
|
675
|
+
errors.should_receive(:on).with(:foo).and_return(true)
|
|
676
|
+
|
|
677
|
+
model.stub!(:errors).and_return(errors)
|
|
678
|
+
|
|
679
|
+
@c.instance_variable_set(:@model, model)
|
|
680
|
+
r = @c.render :hidden_error
|
|
681
|
+
r.should match_tag(:input, :type => "hidden", :name => "my_class[foo]", :class => "error hidden")
|
|
682
|
+
end
|
|
683
|
+
|
|
684
|
+
end
|
|
685
|
+
|
|
686
|
+
describe "radio_button" do
|
|
687
|
+
|
|
688
|
+
before :each do
|
|
689
|
+
@c = RadioButtonSpecs.new(Rango::Request.new({}))
|
|
690
|
+
end
|
|
691
|
+
|
|
692
|
+
it "should should return a basic radio button based on the values passed in" do
|
|
693
|
+
r = @c.render :basic
|
|
694
|
+
r.should match_tag(:input, :type => "radio", :name => "foo", :value => "bar", :id => "baz")
|
|
695
|
+
end
|
|
696
|
+
|
|
697
|
+
it "should provide an additional label tag if the :label option is passed in" do
|
|
698
|
+
result = @c.render :label
|
|
699
|
+
result.should match(/<input.*><label.*>LABEL<\/label>/)
|
|
700
|
+
res = result.scan(/<[^>]*>/)
|
|
701
|
+
res[0].should_not match_tag(:input, :label => "LABEL")
|
|
702
|
+
end
|
|
703
|
+
|
|
704
|
+
it "should render the label tag with the proper for= atttribute" do
|
|
705
|
+
form = @c.render :label
|
|
706
|
+
form.should have_selector("label[for='foo']:contains('LABEL')")
|
|
707
|
+
end
|
|
708
|
+
|
|
709
|
+
it "should be disabled if :disabled => true is passed in" do
|
|
710
|
+
r = @c.render :disabled
|
|
711
|
+
r.should match_tag(:input, :type => "radio", :disabled => "disabled")
|
|
712
|
+
end
|
|
713
|
+
|
|
714
|
+
it "should be checked if :checked => true is passed in" do
|
|
715
|
+
r = @c.render :checked
|
|
716
|
+
r.should match_tag(:input, :type => "radio", :checked => "checked")
|
|
717
|
+
end
|
|
718
|
+
|
|
719
|
+
it "should be unchecked if :checked => false is passed in" do
|
|
720
|
+
r = @c.render :unchecked
|
|
721
|
+
r.should_not include("checked=")
|
|
722
|
+
end
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
describe "radio_group" do
|
|
726
|
+
|
|
727
|
+
before :each do
|
|
728
|
+
@c = RadioGroupSpecs.new(Rango::Request.new({}))
|
|
729
|
+
end
|
|
730
|
+
|
|
731
|
+
it "should return a group of radio buttons" do
|
|
732
|
+
radio = @c.render :basic
|
|
733
|
+
radio_tags = radio.scan(/<[^>]*>/)
|
|
734
|
+
radio_tags[0].should match_tag(:input, :type => "radio", :value => "foowee")
|
|
735
|
+
radio_tags[3].should match_tag(:input, :type => "radio", :value => "baree")
|
|
736
|
+
end
|
|
737
|
+
|
|
738
|
+
it "should provide an additional label tag for each option in array-based options" do
|
|
739
|
+
radio = @c.render :basic
|
|
740
|
+
radio.scan( /<input.*?><label.*?>(foowee|baree)<\/label>/ ).size.should == 2
|
|
741
|
+
radio = radio.scan(/<[^>]*>/)
|
|
742
|
+
radio[0].should_not match_tag(:input, :label => "LABEL")
|
|
743
|
+
radio[3].should_not match_tag(:input, :label => "LABEL")
|
|
744
|
+
end
|
|
745
|
+
|
|
746
|
+
it "should accept array of hashes as options" do
|
|
747
|
+
radio = @c.render :hash
|
|
748
|
+
radio.scan( /<input.*?><label.*?>(Five|Bar)<\/label>/ ).size.should == 2
|
|
749
|
+
radio.scan(/<[^>]*>/).size.should == 6
|
|
750
|
+
radio.should match_tag(:input, :value => 5)
|
|
751
|
+
radio.should match_tag(:label)
|
|
752
|
+
radio.should match_tag(:input, :value => 'bar', :id => 'bar_id')
|
|
753
|
+
radio.should match_tag(:label, :for => 'bar_id')
|
|
754
|
+
end
|
|
755
|
+
|
|
756
|
+
it "should render the label tags on each radio button with the proper for= atttribute" do
|
|
757
|
+
form = @c.render :hash
|
|
758
|
+
form.should have_selector("label[for='bar_id']:contains('Bar')")
|
|
759
|
+
end
|
|
760
|
+
|
|
761
|
+
it "should apply attributes to each element" do
|
|
762
|
+
radio = @c.render :attributes
|
|
763
|
+
radio = radio.scan(/<[^>]*>/)
|
|
764
|
+
radio[0].should match_tag(:input, :type => "radio", :value => "foowee", :class => "CLASS radio")
|
|
765
|
+
radio[3].should match_tag(:input, :type => "radio", :value => "baree", :class => "CLASS radio")
|
|
766
|
+
end
|
|
767
|
+
|
|
768
|
+
it "should override universal attributes with specific ones" do
|
|
769
|
+
radio = @c.render :specific_attributes
|
|
770
|
+
radio = radio.scan(/<[^>]*>/)
|
|
771
|
+
radio[0].should match_tag(:input, :type => "radio", :value => "foowee", :class => "CLASS radio")
|
|
772
|
+
radio[3].should match_tag(:input, :type => "radio", :value => "baree", :class => "BAREE radio")
|
|
773
|
+
end
|
|
774
|
+
|
|
775
|
+
it "should allow specifying a checked radio button" do
|
|
776
|
+
r = @c.render :checked
|
|
777
|
+
r.should match_tag(:input, :value => "bar", :checked => "checked")
|
|
778
|
+
end
|
|
779
|
+
end
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
describe "bound_radio_group" do
|
|
783
|
+
|
|
784
|
+
before do
|
|
785
|
+
@c = BoundRadioGroupSpecs.new(Rango::Request.new({}))
|
|
786
|
+
@c.instance_variable_set(:@obj, FakeModel.new)
|
|
787
|
+
end
|
|
788
|
+
|
|
789
|
+
it "should return a group of radio buttons" do
|
|
790
|
+
r = @c.render :basic
|
|
791
|
+
r.should match_tag(:input, :type => "radio", :id => "fake_model_foo_foowee", :name => "fake_model[foo]", :value => "foowee", :checked => "checked")
|
|
792
|
+
r.should match_tag(:input, :type => "radio", :id => "fake_model_foo_baree", :name => "fake_model[foo]", :value => "baree")
|
|
793
|
+
r.should_not match_tag(:checked => "checked")
|
|
794
|
+
end
|
|
795
|
+
|
|
796
|
+
it "should provide an additional label tag for each option in array-based options" do
|
|
797
|
+
r = @c.render :basic
|
|
798
|
+
r.scan( /<input.*?><label.*?>(foowee|baree)<\/label>/ ).size.should == 2
|
|
799
|
+
radio = r.scan(/<[^>]*>/)[2..-2]
|
|
800
|
+
radio[0].should_not match_tag(:input, :label => "LABEL")
|
|
801
|
+
radio[3].should_not match_tag(:input, :label => "LABEL")
|
|
802
|
+
end
|
|
803
|
+
|
|
804
|
+
it "should render the label tags on each radio option with the proper for= atttribute" do
|
|
805
|
+
form = @c.render :basic
|
|
806
|
+
form.should have_selector("label[for=fake_model_foo_foowee]:contains('foowee')")
|
|
807
|
+
form.should have_selector("label[for=fake_model_foo_baree]:contains('baree')")
|
|
808
|
+
end
|
|
809
|
+
|
|
810
|
+
it "should accept array of hashes as options" do
|
|
811
|
+
r = @c.render :hashes
|
|
812
|
+
r.scan( /<input.*?><label.*?>(Five|Bar)<\/label>/ ).size.should == 2
|
|
813
|
+
r.scan(/<[^>]*>/)[2..-2].size.should == 6
|
|
814
|
+
r.should match_tag(:input, :value => 5)
|
|
815
|
+
r.should match_tag(:label)
|
|
816
|
+
r.should match_tag(:input, :value => 'bar', :id => 'bar_id')
|
|
817
|
+
r.should match_tag(:label, :for => 'bar_id')
|
|
818
|
+
end
|
|
819
|
+
|
|
820
|
+
it "should provide autogenerated id for inputs" do
|
|
821
|
+
r = @c.render :mixed
|
|
822
|
+
r.should match_tag(:input, :id => 'fake_model_foo_bar')
|
|
823
|
+
r.should match_tag(:label, :for => 'fake_model_foo_bar')
|
|
824
|
+
r.should match_tag(:input, :id => 'fake_model_foo_bar')
|
|
825
|
+
r.should match_tag(:label, :for => 'fake_model_foo_bar')
|
|
826
|
+
end
|
|
827
|
+
|
|
828
|
+
it "should override autogenerated id for inputs with hash-given id" do
|
|
829
|
+
r = @c.render :override_id
|
|
830
|
+
r.should match_tag(:input, :id => 'bar_id')
|
|
831
|
+
r.should match_tag(:label, :for => 'bar_id')
|
|
832
|
+
end
|
|
833
|
+
|
|
834
|
+
it "should only have one element with the checked property" do
|
|
835
|
+
r = @c.render :basic
|
|
836
|
+
r.should match_tag(:input, :checked => "checked")
|
|
837
|
+
r.should_not match_tag(:input, :checked => "false")
|
|
838
|
+
end
|
|
839
|
+
end
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
describe "text_area" do
|
|
843
|
+
|
|
844
|
+
before do
|
|
845
|
+
@c = TextAreaSpecs.new(Rango::Request.new({}))
|
|
846
|
+
end
|
|
847
|
+
|
|
848
|
+
it "should should return a basic text area based on the values passed in" do
|
|
849
|
+
r = @c.render :basic
|
|
850
|
+
r.should match_tag(:textarea, :name => "foo", :id => "foo")
|
|
851
|
+
end
|
|
852
|
+
|
|
853
|
+
it "should handle a nil content" do
|
|
854
|
+
r = @c.render :nil
|
|
855
|
+
r.should == "<textarea name=\"foo\" id=\"foo\"></textarea>"
|
|
856
|
+
end
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
# TODO: Why is this required?
|
|
860
|
+
# ---------------------------
|
|
861
|
+
#
|
|
862
|
+
# it "should handle a nil attributes hash" do
|
|
863
|
+
# text_area("CONTENT", nil).should == "<textarea>CONTENT</textarea>"
|
|
864
|
+
# end
|
|
865
|
+
|
|
866
|
+
it "should render a label when the :label option is passed in" do
|
|
867
|
+
result = @c.render :label
|
|
868
|
+
result.should match(/<label.*>LABEL<\/label><textarea/)
|
|
869
|
+
result.should_not match_tag(:textarea, :label => "LABEL")
|
|
870
|
+
|
|
871
|
+
result.should have_selector("label[for=foo]:contains('LABEL')")
|
|
872
|
+
end
|
|
873
|
+
|
|
874
|
+
it "should be disabled if :disabled => true is passed in" do
|
|
875
|
+
r = @c.render :disabled
|
|
876
|
+
r.should match_tag(:textarea, :disabled => "disabled")
|
|
877
|
+
end
|
|
878
|
+
end
|
|
879
|
+
|
|
880
|
+
describe "bound_text_area" do
|
|
881
|
+
|
|
882
|
+
before do
|
|
883
|
+
@c = BoundTextAreaSpecs.new(Rango::Request.new({}))
|
|
884
|
+
@obj = FakeModel.new
|
|
885
|
+
@c.instance_variable_set(:@obj, @obj)
|
|
886
|
+
end
|
|
887
|
+
|
|
888
|
+
it "should provide :id attribute" do
|
|
889
|
+
r = @c.render :basic
|
|
890
|
+
r.should match_tag(:textarea, :id => 'fake_model_foo', :name => "fake_model[foo]")
|
|
891
|
+
r.should =~ />\s*#{@obj.foo}\s*</
|
|
892
|
+
end
|
|
893
|
+
|
|
894
|
+
it "should render the label tag with the proper for= atttribute" do
|
|
895
|
+
form = @c.render :label
|
|
896
|
+
form.should have_selector("label[for='fake_model_foo']:contains('LABEL')")
|
|
897
|
+
end
|
|
898
|
+
end
|
|
899
|
+
|
|
900
|
+
describe "select" do
|
|
901
|
+
|
|
902
|
+
before do
|
|
903
|
+
@c = SelectSpecs.new(Rango::Request.new({}))
|
|
904
|
+
end
|
|
905
|
+
|
|
906
|
+
it "should provide a blank option if you :include_blank" do
|
|
907
|
+
r = @c.render :blank
|
|
908
|
+
r.should =~ /<option.*>\s*<\/option>/
|
|
909
|
+
end
|
|
910
|
+
|
|
911
|
+
it "should render the select tag proper attributes" do
|
|
912
|
+
r = @c.render :basic
|
|
913
|
+
r.should match_tag( :select, :name => "foo", :id => "foo")
|
|
914
|
+
r.should have_selector("select[name=foo] option:contains('one')")
|
|
915
|
+
r.should have_selector("select[name=foo] option:contains('two')")
|
|
916
|
+
r.should have_selector("select[name=foo] option:contains('three')")
|
|
917
|
+
end
|
|
918
|
+
|
|
919
|
+
it "should allow selecting an option by passing in :selected => 'three'" do
|
|
920
|
+
r = @c.render :selected
|
|
921
|
+
r.should_not have_selector("select[name=foo] option[selected]:contains('one')")
|
|
922
|
+
r.should_not have_selector("select[name=foo] option[selected]:contains('two')")
|
|
923
|
+
r.should have_selector("select[name=foo] option[selected]:contains('three')")
|
|
924
|
+
end
|
|
925
|
+
|
|
926
|
+
it "should render the select tag with suffix '[]' to name when :multiple => true" do
|
|
927
|
+
r = @c.render :multiple
|
|
928
|
+
r.should match_tag( :select, :name => "foo[]")
|
|
929
|
+
end
|
|
930
|
+
|
|
931
|
+
it "should render a label when the :label option is passed in" do
|
|
932
|
+
result = @c.render :label
|
|
933
|
+
result.should have_selector("label[for=foo]:contains('LABEL')")
|
|
934
|
+
end
|
|
935
|
+
end
|
|
936
|
+
|
|
937
|
+
describe "bound_select" do
|
|
938
|
+
|
|
939
|
+
before do
|
|
940
|
+
@c = BoundSelectSpecs.new(Rango::Request.new({}))
|
|
941
|
+
@c.instance_variable_set(:@obj, FakeModel.new)
|
|
942
|
+
end
|
|
943
|
+
|
|
944
|
+
it "should render the select tag with the correct id and name" do
|
|
945
|
+
r = @c.render :basic
|
|
946
|
+
r.should match_tag( :select, :id => "fake_model_foo", :name => "fake_model[foo]" )
|
|
947
|
+
end
|
|
948
|
+
|
|
949
|
+
it "should render the select tag with suffix '[]' to name when :multiple => true" do
|
|
950
|
+
r = @c.render :multiple
|
|
951
|
+
r.should match_tag( :select, :id => "fake_model_foo", :name => "fake_model[foo][]" )
|
|
952
|
+
end
|
|
953
|
+
|
|
954
|
+
it "should include a blank option" do
|
|
955
|
+
r = @c.render :blank
|
|
956
|
+
r.should match_tag(:option, :value => '')
|
|
957
|
+
r.should =~ /<option.*>\s*<\/option>/
|
|
958
|
+
end
|
|
959
|
+
|
|
960
|
+
it "should render a prompt option without a value" do
|
|
961
|
+
r = @c.render :prompt
|
|
962
|
+
r.should match_tag(:option, :value => '')
|
|
963
|
+
r.should =~ /<option.*>Choose<\/option>/
|
|
964
|
+
end
|
|
965
|
+
|
|
966
|
+
it "should render a select tag with options" do
|
|
967
|
+
r = @c.render :with_options
|
|
968
|
+
r.should match_tag( :select, :class => "class1 class2", :title=> "This is the title" )
|
|
969
|
+
r.should =~ /<select.*>\s*<\/select>/
|
|
970
|
+
end
|
|
971
|
+
|
|
972
|
+
it "should render a select tag with options and a blank option" do
|
|
973
|
+
r = @c.render :with_options_with_blank
|
|
974
|
+
r.should match_tag( :select, :title => "TITLE" )
|
|
975
|
+
r.should match_tag( :option, :value => '' )
|
|
976
|
+
r.should =~ /<option.*>\s*<\/option>/
|
|
977
|
+
end
|
|
978
|
+
|
|
979
|
+
it "should render the label tag with the proper for= atttribute" do
|
|
980
|
+
form = @c.render :label
|
|
981
|
+
form.should have_selector("label[for=fake_model_foo]:contains('LABEL')")
|
|
982
|
+
end
|
|
983
|
+
|
|
984
|
+
# Not sure how this makes any sense
|
|
985
|
+
# ---------------------------------
|
|
986
|
+
#
|
|
987
|
+
# it "should render the text as the value if no text_method is specified" do
|
|
988
|
+
# form_for @obj do
|
|
989
|
+
# content = select( :foo, :collection => [FakeModel] )
|
|
990
|
+
# content.should match_tag( :option, :value => "FakeModel" )
|
|
991
|
+
# end
|
|
992
|
+
# end
|
|
993
|
+
|
|
994
|
+
end
|
|
995
|
+
|
|
996
|
+
describe "bound option tags" do
|
|
997
|
+
|
|
998
|
+
before do
|
|
999
|
+
@c = BoundOptionTagSpecs.new(Rango::Request.new({}))
|
|
1000
|
+
@c.instance_variable_set(:@obj, FakeModel.new)
|
|
1001
|
+
end
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
it "should use text_method and value_method for tag generation" do
|
|
1005
|
+
r = @c.render :text_and_value
|
|
1006
|
+
r.should match_tag( :option, :content => "foowee", :value => "7" )
|
|
1007
|
+
r.should match_tag( :option, :content => "foowee2", :value => "barbar" )
|
|
1008
|
+
|
|
1009
|
+
# content = options_from_collection_for_select( [FakeModel.new, FakeModel2.new], :text_method => 'foo', :value_method => 'bar' )
|
|
1010
|
+
# content.should match_tag( :option, :content => "foowee", :value => "7" )
|
|
1011
|
+
# content.should match_tag( :option, :content => "foowee2", :value => "barbar" )
|
|
1012
|
+
end
|
|
1013
|
+
|
|
1014
|
+
it "should render a hash of arrays as a grouped select box" do
|
|
1015
|
+
model1 = FakeModel.new ; model1.make = "Ford" ; model1.model = "Mustang" ; model1.vin = '1'
|
|
1016
|
+
model2 = FakeModel.new ; model2.make = "Ford" ; model2.model = "Falcon" ; model2.vin = '2'
|
|
1017
|
+
model3 = FakeModel.new ; model3.make = "Holden" ; model3.model = "Commodore" ; model3.vin = '3'
|
|
1018
|
+
@c.instance_variable_set(:@model1, model1)
|
|
1019
|
+
@c.instance_variable_set(:@model2, model2)
|
|
1020
|
+
@c.instance_variable_set(:@model3, model3)
|
|
1021
|
+
@c.instance_variable_set(:@collection, [model1, model2, model3].inject({}) {|s,e| (s[e.make] ||= []) << e; s })
|
|
1022
|
+
r = @c.render :grouped
|
|
1023
|
+
# Blank actually defaults to ""
|
|
1024
|
+
r.should =~ /<optgroup label=\"Ford\"><option/
|
|
1025
|
+
r.should match_tag( :optgroup, :label => "Ford" )
|
|
1026
|
+
r.should match_tag( :option, :selected => "selected", :value => "1", :content => "Mustang" )
|
|
1027
|
+
r.should match_tag( :option, :value => "2", :content => "Falcon" )
|
|
1028
|
+
r.should match_tag( :optgroup, :label => "Holden" )
|
|
1029
|
+
r.should match_tag( :option, :value => "3", :content => "Commodore" )
|
|
1030
|
+
|
|
1031
|
+
# collection = [@model1, @model2, @model3].inject({}) {|s,e| (s[e.make] ||= []) << e; s }
|
|
1032
|
+
# content = options_from_collection_for_select(collection, :text_method => 'model', :value_method => 'vin', :selected => '1')
|
|
1033
|
+
end
|
|
1034
|
+
|
|
1035
|
+
it "should render a collection of nested value/content arrays" do
|
|
1036
|
+
r = @c.render :nested
|
|
1037
|
+
r.should match_tag(:select, :id => "fake_model_foo", :name => "fake_model[foo]")
|
|
1038
|
+
r.should match_tag(:option, :value => "small", :content => "Small")
|
|
1039
|
+
r.should match_tag(:option, :value => "medium", :content => "Medium")
|
|
1040
|
+
r.should match_tag(:option, :value => "large", :content => "Large")
|
|
1041
|
+
end
|
|
1042
|
+
|
|
1043
|
+
# Is this really worth the extra speed hit? I'm thinking not
|
|
1044
|
+
# ----------------------------------------------------------
|
|
1045
|
+
#
|
|
1046
|
+
# it "should humanize and titlize keys in the label for the option group" do
|
|
1047
|
+
# collection = { :some_snake_case_key => [FakeModel.new] }
|
|
1048
|
+
# form_for @obj do
|
|
1049
|
+
# content = select( :foo, :collection => collection )
|
|
1050
|
+
# content.should match_tag( :optgroup, :label => "Some Snake Case Key" )
|
|
1051
|
+
# end
|
|
1052
|
+
# end
|
|
1053
|
+
|
|
1054
|
+
end
|
|
1055
|
+
|
|
1056
|
+
require "hpricot"
|
|
1057
|
+
|
|
1058
|
+
describe "option tags" do
|
|
1059
|
+
|
|
1060
|
+
before do
|
|
1061
|
+
@c = OptionTagSpecs.new(Rango::Request.new({}))
|
|
1062
|
+
@c.instance_variable_set(:@collection, [['rabbit','Rabbit'],['horse','Horse'],['bird','Bird']])
|
|
1063
|
+
end
|
|
1064
|
+
|
|
1065
|
+
it "should provide an option tag for each item in the collection" do
|
|
1066
|
+
r = @c.render :collection
|
|
1067
|
+
doc = Hpricot( r )
|
|
1068
|
+
(doc/"option").size.should == 3
|
|
1069
|
+
end
|
|
1070
|
+
|
|
1071
|
+
it "should provide a blank option" do
|
|
1072
|
+
r = @c.render :with_blank
|
|
1073
|
+
r.should match_tag( :option, :value => '' )
|
|
1074
|
+
end
|
|
1075
|
+
|
|
1076
|
+
it "should render the prompt option at the top" do
|
|
1077
|
+
r = @c.render :with_prompt
|
|
1078
|
+
#ontent = select( :collection => [["foo", "Foo"]], :prompt => 'Choose' )
|
|
1079
|
+
r.should match(/<option[^>]*>Choose<\/option>[^<]*<option[^>]*>Foo<\/option>/)
|
|
1080
|
+
end
|
|
1081
|
+
|
|
1082
|
+
it "should provide selected options by value" do
|
|
1083
|
+
r = @c.render :selected
|
|
1084
|
+
r.should match_tag( :option, :value => 'rabbit', :selected => 'selected', :content => 'Rabbit' )
|
|
1085
|
+
r.should_not match_tag( :option, :value => 'chicken', :selected => nil, :content => 'Chicken' )
|
|
1086
|
+
end
|
|
1087
|
+
|
|
1088
|
+
it "should handle arrays for selected when :multiple is true" do
|
|
1089
|
+
r = @c.render :multiple_selects
|
|
1090
|
+
r.should match_tag( :option, :value => 'minutes', :selected => 'selected', :content => 'Time' )
|
|
1091
|
+
r.should match_tag( :option, :value => 'dollars', :selected => 'selected', :content => 'Money' )
|
|
1092
|
+
end
|
|
1093
|
+
|
|
1094
|
+
it "should render a hash of options as optgroup" do
|
|
1095
|
+
r = @c.render :optgroups
|
|
1096
|
+
r.should match_tag( :optgroup, :label => 'Fruit' )
|
|
1097
|
+
r.should match_tag( :optgroup, :label => 'Vegetables' )
|
|
1098
|
+
r.should match_tag( :option, :value => 'banana', :selected => 'selected', :content => 'Banana' )
|
|
1099
|
+
end
|
|
1100
|
+
|
|
1101
|
+
it "should accept an array of strings in :collection as the content/value of each option" do
|
|
1102
|
+
r = @c.render :array
|
|
1103
|
+
r.should match_tag(:option, :content => "one", :value => "one")
|
|
1104
|
+
r.should match_tag(:option, :content => "two", :value => "two")
|
|
1105
|
+
end
|
|
1106
|
+
|
|
1107
|
+
it "should only pass :selected and :value attrs to <option> tags" do
|
|
1108
|
+
r = @c.render :no_extra_attributes
|
|
1109
|
+
r = r.slice(/<option[^>]*>[^<]*<\/option>/)
|
|
1110
|
+
r.should match_tag(:option, :value => "rabbit", :content => "Rabbit")
|
|
1111
|
+
r.should_not match_tag(:option, :id => "my_id", :name => "my_name", :class => "classy")
|
|
1112
|
+
end
|
|
1113
|
+
|
|
1114
|
+
it "should not pollute the <select> attributes with <option> attributes" do
|
|
1115
|
+
r = @c.render :clean
|
|
1116
|
+
r.should_not match_tag(:select, :value => "banana", :selected => "selected")
|
|
1117
|
+
end
|
|
1118
|
+
end
|
|
1119
|
+
|
|
1120
|
+
describe "fieldset" do
|
|
1121
|
+
|
|
1122
|
+
before :each do
|
|
1123
|
+
@c = FieldsetSpecs.new(Rango::Request.new({}))
|
|
1124
|
+
end
|
|
1125
|
+
|
|
1126
|
+
it "should provide legend option" do
|
|
1127
|
+
r = @c.render :legend
|
|
1128
|
+
r.should have_selector("fieldset legend:contains('TEST')")
|
|
1129
|
+
end
|
|
1130
|
+
|
|
1131
|
+
end
|
|
1132
|
+
|
|
1133
|
+
describe "label" do
|
|
1134
|
+
|
|
1135
|
+
before :each do
|
|
1136
|
+
@c = LabelSpecs.new(Rango::Request.new({}))
|
|
1137
|
+
end
|
|
1138
|
+
|
|
1139
|
+
it "should render a label tag" do
|
|
1140
|
+
r = @c.render :basic
|
|
1141
|
+
r.should have_selector("label[for=user_first_name]:contains('First Name')")
|
|
1142
|
+
end
|
|
1143
|
+
|
|
1144
|
+
it "should render a label tag with a :class attribute set" do
|
|
1145
|
+
r = @c.render :basic_with_class
|
|
1146
|
+
r.should have_selector("label[class=name_class]")
|
|
1147
|
+
end
|
|
1148
|
+
|
|
1149
|
+
it "should render a label tag with both rel and style attributes set" do
|
|
1150
|
+
r = @c.render :basic_with_attributes
|
|
1151
|
+
r.should have_selector("label[rel=tooltip][style='display:none']")
|
|
1152
|
+
end
|
|
1153
|
+
|
|
1154
|
+
end
|
|
1155
|
+
|
|
1156
|
+
describe "file_field" do
|
|
1157
|
+
|
|
1158
|
+
before :each do
|
|
1159
|
+
@c = FileFieldSpecs.new(Rango::Request.new({}))
|
|
1160
|
+
end
|
|
1161
|
+
|
|
1162
|
+
it "should return a basic file field based on the values passed in" do
|
|
1163
|
+
r = @c.render :with_values
|
|
1164
|
+
r.should have_selector("input[type=file][id=foo][name=foo][value=bar]")
|
|
1165
|
+
end
|
|
1166
|
+
|
|
1167
|
+
it "should wrap the field in a label if the :label option is passed to the file" do
|
|
1168
|
+
r = @c.render :with_label
|
|
1169
|
+
r.should have_selector("label[for=foo]:contains('LABEL') + input.file[type=file]")
|
|
1170
|
+
end
|
|
1171
|
+
|
|
1172
|
+
it "should be disabled if :disabled => true is passed in" do
|
|
1173
|
+
r = @c.render :disabled
|
|
1174
|
+
r.should have_selector("input[type=file][disabled=disabled]")
|
|
1175
|
+
end
|
|
1176
|
+
|
|
1177
|
+
it "should make the surrounding form multipart" do
|
|
1178
|
+
r = @c.render :makes_multipart
|
|
1179
|
+
r.should have_selector("form[enctype='multipart/form-data']")
|
|
1180
|
+
end
|
|
1181
|
+
end
|
|
1182
|
+
|
|
1183
|
+
describe "bound_file_field" do
|
|
1184
|
+
|
|
1185
|
+
before :each do
|
|
1186
|
+
@c = BoundFileFieldSpecs.new(Rango::Request.new({}))
|
|
1187
|
+
@c.instance_variable_set(:@obj, FakeModel.new)
|
|
1188
|
+
end
|
|
1189
|
+
|
|
1190
|
+
it "should take a string object and return a useful file control" do
|
|
1191
|
+
r = @c.render :takes_string
|
|
1192
|
+
r.should have_selector("input[type=file][id=fake_model_foo][name='fake_model[foo]'][value=foowee]")
|
|
1193
|
+
end
|
|
1194
|
+
|
|
1195
|
+
it "should take additional attributes and use them" do
|
|
1196
|
+
r = @c.render :additional_attributes
|
|
1197
|
+
r.should have_selector("input[type=file][name='fake_model[foo]'][value=foowee][bar='7']")
|
|
1198
|
+
end
|
|
1199
|
+
|
|
1200
|
+
it "should wrap the file_field in a label if the :label option is passed in" do
|
|
1201
|
+
r = @c.render :with_label
|
|
1202
|
+
r.should have_selector("label[for=fake_model_foo]:contains('LABEL')")
|
|
1203
|
+
r.should_not have_selector("input[label=LABEL]")
|
|
1204
|
+
end
|
|
1205
|
+
end
|
|
1206
|
+
|
|
1207
|
+
describe "submit" do
|
|
1208
|
+
|
|
1209
|
+
before :each do
|
|
1210
|
+
@c = SubmitSpecs.new(Rango::Request.new({}))
|
|
1211
|
+
end
|
|
1212
|
+
|
|
1213
|
+
it "should return a basic submit input based on the values passed in" do
|
|
1214
|
+
r = @c.render :submit_with_values
|
|
1215
|
+
r.should have_selector("input[type=submit][name=foo][value=Done]")
|
|
1216
|
+
end
|
|
1217
|
+
|
|
1218
|
+
it "should provide an additional label tag if the :label option is passed in" do
|
|
1219
|
+
r = @c.render :submit_with_label
|
|
1220
|
+
r.should have_selector("input[type=submit][name=submit][value=Done]")
|
|
1221
|
+
r.should have_selector("label:contains('LABEL')")
|
|
1222
|
+
end
|
|
1223
|
+
|
|
1224
|
+
it "should be disabled if :disabled => true is passed in" do
|
|
1225
|
+
r = @c.render :disabled_submit
|
|
1226
|
+
r.should have_selector("input[type=submit][value=Done][disabled=disabled]")
|
|
1227
|
+
end
|
|
1228
|
+
end
|
|
1229
|
+
|
|
1230
|
+
describe "button" do
|
|
1231
|
+
|
|
1232
|
+
before :each do
|
|
1233
|
+
@c = ButtonSpecs.new(Rango::Request.new({}))
|
|
1234
|
+
end
|
|
1235
|
+
|
|
1236
|
+
it "should return a button based on the values passed in" do
|
|
1237
|
+
r = @c.render :button_with_values
|
|
1238
|
+
r.should have_selector("button[type=button][name=foo][value=bar]:contains('Click Me')")
|
|
1239
|
+
end
|
|
1240
|
+
|
|
1241
|
+
it "should provide an additional label tag if the :label option is passed in" do
|
|
1242
|
+
r = @c.render :button_with_label
|
|
1243
|
+
r.should have_selector("button[value=foo]")
|
|
1244
|
+
r.should have_selector("label:contains('LABEL')")
|
|
1245
|
+
end
|
|
1246
|
+
|
|
1247
|
+
it "should be disabled if :disabled => true is passed in" do
|
|
1248
|
+
r = @c.render :disabled_button
|
|
1249
|
+
r.should have_selector("button[disabled=true]")
|
|
1250
|
+
end
|
|
1251
|
+
end
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
class MyBuilder < Rango::Helpers::Form::Builder::Base
|
|
1255
|
+
|
|
1256
|
+
def update_bound_controls(method, attrs, type)
|
|
1257
|
+
super
|
|
1258
|
+
attrs[:bound] = type
|
|
1259
|
+
end
|
|
1260
|
+
|
|
1261
|
+
def update_unbound_controls(attrs, type)
|
|
1262
|
+
super
|
|
1263
|
+
attrs[:unbound] = type
|
|
1264
|
+
end
|
|
1265
|
+
|
|
1266
|
+
end
|
|
1267
|
+
|
|
1268
|
+
describe "custom builder" do
|
|
1269
|
+
|
|
1270
|
+
before :each do
|
|
1271
|
+
@c = CustomBuilderSpecs.new(Rango::Request.new({}))
|
|
1272
|
+
@c.instance_variable_set(:@obj, FakeModel.new)
|
|
1273
|
+
end
|
|
1274
|
+
|
|
1275
|
+
it "should let you override update_bound_controls" do
|
|
1276
|
+
r = @c.render :everything
|
|
1277
|
+
r.should =~ / bound="file"/
|
|
1278
|
+
r.should =~ / bound="text"/
|
|
1279
|
+
r.should =~ / bound="hidden"/
|
|
1280
|
+
r.should =~ / bound="password"/
|
|
1281
|
+
r.should =~ / bound="radio"/
|
|
1282
|
+
r.should =~ / bound="text_area"/
|
|
1283
|
+
end
|
|
1284
|
+
|
|
1285
|
+
it "should let you override update_unbound_controls" do
|
|
1286
|
+
r = @c.render :everything
|
|
1287
|
+
r.should have_selector("button[unbound=button]")
|
|
1288
|
+
r.should have_selector("input[unbound=submit]")
|
|
1289
|
+
r.should have_selector("textarea[unbound=text_area]")
|
|
1290
|
+
end
|
|
1291
|
+
end
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
describe 'delete_button' do
|
|
1295
|
+
|
|
1296
|
+
before :each do
|
|
1297
|
+
@controller = DeleteButtonSpecs.new(Rango::Request.new({}))
|
|
1298
|
+
@controller.instance_variable_set(:@obj, FakeModel.new)
|
|
1299
|
+
end
|
|
1300
|
+
|
|
1301
|
+
it "should have a default submit button text" do
|
|
1302
|
+
result = @controller.render :simple_delete # <%= delete_button @obj %>
|
|
1303
|
+
result.should have_selector("input[type=submit][value=Delete]")
|
|
1304
|
+
end
|
|
1305
|
+
|
|
1306
|
+
it 'should return a button inside of a form for the object' do
|
|
1307
|
+
result = @controller.render :simple_delete # <%= delete_button @obj %>
|
|
1308
|
+
result.should have_selector("form[action='/fake_models/fake_model'][method=post]")
|
|
1309
|
+
result.should have_selector("input[type=hidden][value=DELETE][name=_method]")
|
|
1310
|
+
end
|
|
1311
|
+
|
|
1312
|
+
it 'should allow you to modify the label' do
|
|
1313
|
+
result = @controller.render :delete_with_label # <%= delete_button(@obj, "Delete moi!") %>
|
|
1314
|
+
result.should have_selector("input[type=submit][value='Delete moi!']")
|
|
1315
|
+
end
|
|
1316
|
+
|
|
1317
|
+
it "should allow you to pass some extra params like a class" do
|
|
1318
|
+
result = @controller.render :delete_with_extra_params
|
|
1319
|
+
result.should have_selector("input.custom-class[type=submit][value=Delete]")
|
|
1320
|
+
end
|
|
1321
|
+
|
|
1322
|
+
it "should allow to pass an explicit url as a string" do
|
|
1323
|
+
result = @controller.render :delete_with_explicit_url # <%= delete_button('/test/custom_url') %>
|
|
1324
|
+
result.should have_selector("form[action='/test/custom_url'][method=post]")
|
|
1325
|
+
end
|
|
1326
|
+
|
|
1327
|
+
end
|
|
1328
|
+
|
|
1329
|
+
describe "escaping values" do
|
|
1330
|
+
|
|
1331
|
+
before :each do
|
|
1332
|
+
@c = Hacker.new(Rango::Request.new({}))
|
|
1333
|
+
@c.instance_variable_set(:@obj, HackerModel.new)
|
|
1334
|
+
end
|
|
1335
|
+
|
|
1336
|
+
it "should escape bound text field values" do
|
|
1337
|
+
r = @c.render :text_field
|
|
1338
|
+
r.should =~ /&"<>/
|
|
1339
|
+
end
|
|
1340
|
+
|
|
1341
|
+
it "should escape bound hidden field values" do
|
|
1342
|
+
r = @c.render :hidden_field
|
|
1343
|
+
r.should =~ /&"<>/
|
|
1344
|
+
end
|
|
1345
|
+
|
|
1346
|
+
it "should escape bound password field values" do
|
|
1347
|
+
r = @c.render :password_field
|
|
1348
|
+
r.should =~ /&"<>/
|
|
1349
|
+
end
|
|
1350
|
+
|
|
1351
|
+
it "should escape bound text area values" do
|
|
1352
|
+
r = @c.render :text_area
|
|
1353
|
+
r.should =~ /&"<>/
|
|
1354
|
+
end
|
|
1355
|
+
|
|
1356
|
+
it "should escape bound file field values" do
|
|
1357
|
+
r = @c.render :file_field
|
|
1358
|
+
r.should =~ /&"<>/
|
|
1359
|
+
end
|
|
1360
|
+
|
|
1361
|
+
it "should escape bound option tag values" do
|
|
1362
|
+
r = @c.render :option_tag
|
|
1363
|
+
r.should =~ /&"<>/
|
|
1364
|
+
end
|
|
1365
|
+
|
|
1366
|
+
it "should escape bound radio button values" do
|
|
1367
|
+
r = @c.render :radio_button
|
|
1368
|
+
r.should =~ /&"<>/
|
|
1369
|
+
end
|
|
1370
|
+
|
|
1371
|
+
end
|