middleman-core 3.0.0.beta.2 → 3.0.0.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- data/features/cli_extension.feature +13 -0
- data/features/{cli.feature → cli_init.feature} +1 -10
- data/features/directory_index.feature +29 -1
- data/features/dynamic_pages.feature +1 -0
- data/features/extensionless_text_files.feature +0 -2
- data/features/front-matter.feature +17 -1
- data/features/frontmatter_page_settings.feature +16 -1
- data/features/helpers_relative_link_to.feature +68 -0
- data/features/unicode_filenames.feature +14 -0
- data/fixtures/csspie/config.rb +0 -0
- data/fixtures/csspie/source/stylesheets/PIE.htc +96 -0
- data/fixtures/dynamic-pages-app/config.rb +3 -0
- data/fixtures/frontmatter-app/source/front-matter-auto.erb +6 -0
- data/fixtures/frontmatter-app/source/front-matter.html.erb +2 -0
- data/fixtures/frontmatter-app/source/json-front-matter-2.php.erb +7 -0
- data/fixtures/frontmatter-app/source/json-front-matter-auto.erb +6 -0
- data/fixtures/frontmatter-app/source/json-front-matter.html.erb +6 -0
- data/fixtures/unicode-filenames-app/config.rb +1 -0
- data/fixtures/unicode-filenames-app/source/snowmen-rule-/342/230/203.html +4 -0
- data/lib/middleman-core/application.rb +43 -335
- data/lib/middleman-core/cli/build.rb +11 -4
- data/lib/middleman-core/cli/bundler.rb +40 -0
- data/lib/middleman-core/cli/extension.rb +36 -0
- data/lib/middleman-core/cli/server.rb +2 -2
- data/lib/middleman-core/cli.rb +2 -6
- data/lib/middleman-core/core_extensions/assets.rb +35 -31
- data/lib/middleman-core/core_extensions/builder.rb +14 -9
- data/lib/middleman-core/core_extensions/data.rb +150 -145
- data/lib/middleman-core/core_extensions/default_helpers.rb +159 -97
- data/lib/middleman-core/core_extensions/extensions.rb +103 -97
- data/lib/middleman-core/core_extensions/external_helpers.rb +27 -23
- data/lib/middleman-core/core_extensions/file_watcher.rb +140 -110
- data/lib/middleman-core/core_extensions/front_matter.rb +155 -175
- data/lib/middleman-core/core_extensions/i18n.rb +111 -102
- data/lib/middleman-core/core_extensions/rendering.rb +293 -295
- data/lib/middleman-core/core_extensions/request.rb +338 -0
- data/lib/middleman-core/core_extensions/routing.rb +72 -68
- data/lib/middleman-core/core_extensions/show_exceptions.rb +23 -18
- data/lib/middleman-core/core_extensions.rb +39 -0
- data/lib/middleman-core/extensions/directory_indexes.rb +1 -4
- data/lib/middleman-core/extensions/lorem.rb +10 -3
- data/lib/middleman-core/extensions.rb +2 -64
- data/lib/middleman-core/preview_server.rb +157 -0
- data/lib/middleman-core/sitemap/extensions/ignores.rb +73 -68
- data/lib/middleman-core/sitemap/extensions/on_disk.rb +65 -58
- data/lib/middleman-core/sitemap/extensions/proxies.rb +86 -75
- data/lib/middleman-core/sitemap/extensions/traversal.rb +68 -61
- data/lib/middleman-core/sitemap/resource.rb +123 -102
- data/lib/middleman-core/sitemap/store.rb +170 -149
- data/lib/middleman-core/sitemap.rb +57 -57
- data/lib/middleman-core/step_definitions/server_steps.rb +13 -3
- data/lib/middleman-core/templates/extension/Gemfile +4 -0
- data/lib/middleman-core/templates/extension/Rakefile +12 -0
- data/lib/middleman-core/templates/extension/features/support/env.rb +4 -0
- data/lib/middleman-core/templates/extension/gemspec +24 -0
- data/lib/middleman-core/templates/extension/lib/lib.rb +49 -0
- data/lib/middleman-core/templates/extension/lib/middleman_extension.rb +1 -0
- data/lib/middleman-core/templates/shared/gitignore +14 -0
- data/lib/middleman-core/templates.rb +14 -8
- data/lib/middleman-core/util.rb +31 -9
- data/lib/middleman-core/version.rb +1 -1
- data/lib/middleman-core.rb +6 -4
- data/middleman-core.gemspec +4 -6
- metadata +62 -203
- data/lib/middleman-core/vendor/padrino-core-0.10.6/.document +0 -5
- data/lib/middleman-core/vendor/padrino-core-0.10.6/.gitignore +0 -22
- data/lib/middleman-core/vendor/padrino-core-0.10.6/.yardopts +0 -1
- data/lib/middleman-core/vendor/padrino-core-0.10.6/LICENSE.txt +0 -20
- data/lib/middleman-core/vendor/padrino-core-0.10.6/README.rdoc +0 -294
- data/lib/middleman-core/vendor/padrino-core-0.10.6/Rakefile +0 -5
- data/lib/middleman-core/vendor/padrino-core-0.10.6/bin/padrino +0 -9
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/application/rendering.rb +0 -292
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/application/routing.rb +0 -943
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/application/showexceptions.rb +0 -20
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/application.rb +0 -269
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/caller.rb +0 -53
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/cli/adapter.rb +0 -24
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/cli/base.rb +0 -150
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/cli/console.rb +0 -20
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/cli/rake.rb +0 -24
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/cli/rake_tasks.rb +0 -59
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/command.rb +0 -38
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/images/404.png +0 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/images/500.png +0 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/loader.rb +0 -211
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/cs.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/da.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/de.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/en.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/es.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/fr.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/hu.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/it.yml +0 -40
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/ja.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/lv.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/nl.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/no.yml +0 -35
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/pl.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/pt_br.yml +0 -40
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/ru.yml +0 -35
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/tr.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/uk.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/zh_cn.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/zh_tw.yml +0 -34
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/logger.rb +0 -428
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/mounter.rb +0 -224
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/reloader.rb +0 -254
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/router.rb +0 -98
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/server.rb +0 -79
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/support_lite.rb +0 -199
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/tasks.rb +0 -21
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/version.rb +0 -20
- data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core.rb +0 -152
- data/lib/middleman-core/vendor/padrino-core-0.10.6/padrino-core.gemspec +0 -38
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/apps/.components +0 -6
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/apps/.gitignore +0 -7
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/apps/complex.rb +0 -32
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/apps/simple.rb +0 -33
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/a.rb +0 -9
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/b.rb +0 -4
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/c.rb +0 -1
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/circular/e.rb +0 -13
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/circular/f.rb +0 -2
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/circular/g.rb +0 -2
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/d.rb +0 -4
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/helper.rb +0 -83
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/mini_shoulda.rb +0 -45
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_application.rb +0 -108
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_core.rb +0 -77
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_dependencies.rb +0 -44
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_filters.rb +0 -278
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_locale.rb +0 -21
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_logger.rb +0 -154
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_mounter.rb +0 -177
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_reloader_complex.rb +0 -75
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_reloader_simple.rb +0 -98
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_rendering.rb +0 -461
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_restful_routing.rb +0 -33
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_router.rb +0 -146
- data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_routing.rb +0 -1680
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/.document +0 -5
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/.gitignore +0 -21
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/.yardopts +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/LICENSE.txt +0 -20
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/README.rdoc +0 -239
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/Rakefile +0 -5
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/asset_tag_helpers.rb +0 -417
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/form_builder/abstract_form_builder.rb +0 -251
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/form_builder/standard_form_builder.rb +0 -43
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/form_helpers.rb +0 -787
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/format_helpers.rb +0 -381
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/cs.yml +0 -103
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/da.yml +0 -91
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/de.yml +0 -81
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/en.yml +0 -103
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/es.yml +0 -103
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/fr.yml +0 -80
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/hu.yml +0 -103
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/it.yml +0 -89
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/ja.yml +0 -103
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/lv.yml +0 -103
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/nl.yml +0 -82
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/no.yml +0 -91
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/pl.yml +0 -95
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/pt_br.yml +0 -103
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/ru.yml +0 -103
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/tr.yml +0 -103
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/uk.yml +0 -103
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/zh_cn.yml +0 -104
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/zh_tw.yml +0 -103
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/number_helpers.rb +0 -288
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/output_helpers/abstract_handler.rb +0 -98
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/output_helpers/erb_handler.rb +0 -79
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/output_helpers/haml_handler.rb +0 -63
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/output_helpers/slim_handler.rb +0 -81
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/output_helpers.rb +0 -175
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/render_helpers.rb +0 -60
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/tag_helpers.rb +0 -260
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/translation_helpers.rb +0 -38
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers.rb +0 -59
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/padrino-helpers.gemspec +0 -27
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/app.rb +0 -73
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/capture_concat.erb +0 -14
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/capture_concat.haml +0 -12
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/capture_concat.slim +0 -13
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/content_for.erb +0 -14
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/content_for.haml +0 -12
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/content_for.slim +0 -12
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/content_tag.erb +0 -11
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/content_tag.haml +0 -9
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/content_tag.slim +0 -9
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/current_engine.erb +0 -5
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/current_engine.haml +0 -5
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/current_engine.slim +0 -5
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/fields_for.erb +0 -20
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/fields_for.haml +0 -15
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/fields_for.slim +0 -15
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/form_for.erb +0 -72
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/form_for.haml +0 -59
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/form_for.slim +0 -59
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/form_tag.erb +0 -86
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/form_tag.haml +0 -70
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/form_tag.slim +0 -70
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/link_to.erb +0 -5
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/link_to.haml +0 -4
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/link_to.slim +0 -4
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/mail_to.erb +0 -3
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/mail_to.haml +0 -3
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/mail_to.slim +0 -3
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/meta_tag.erb +0 -3
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/meta_tag.haml +0 -3
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/meta_tag.slim +0 -3
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/partials/_erb.erb +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/partials/_haml.haml +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/partials/_slim.slim +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/simple_partial.erb +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/simple_partial.haml +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/simple_partial.slim +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/app.rb +0 -50
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/current_engine.haml +0 -5
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/current_engines/_erb.erb +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/current_engines/_haml.haml +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/current_engines/_slim.slim +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/erb/test.erb +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/explicit_engine.haml +0 -5
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/haml/test.haml +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/template/_user.haml +0 -7
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/template/haml_template.haml +0 -1
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/template/some_template.haml +0 -2
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/helper.rb +0 -66
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_asset_tag_helpers.rb +0 -328
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_form_builder.rb +0 -1106
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_form_helpers.rb +0 -770
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_format_helpers.rb +0 -227
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_locale.rb +0 -20
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_number_helpers.rb +0 -139
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_output_helpers.rb +0 -153
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_render_helpers.rb +0 -76
- data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_tag_helpers.rb +0 -106
- data/lib/middleman-core/watcher.rb +0 -196
@@ -1,1106 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/fixtures/markup_app/app')
|
3
|
-
|
4
|
-
describe "FormBuilder" do
|
5
|
-
include Padrino::Helpers::FormHelpers
|
6
|
-
|
7
|
-
# Dummy form builder for testing
|
8
|
-
module Padrino::Helpers::FormBuilder
|
9
|
-
class FakeFormBuilder < AbstractFormBuilder
|
10
|
-
def foo_field; @template.content_tag(:span, "bar"); end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def app
|
15
|
-
MarkupDemo.tap { |app| app.set :environment, :test }
|
16
|
-
end
|
17
|
-
|
18
|
-
def setup
|
19
|
-
role_types = [mock_model('Role', :name => "Admin", :id => 1),
|
20
|
-
mock_model('Role', :name => 'Moderate', :id => 2), mock_model('Role', :name => 'Limited', :id => 3)]
|
21
|
-
@user = mock_model("User", :first_name => "Joe", :email => '', :session_id => 54)
|
22
|
-
@user.stubs(:errors => {:a => "must be present", :b => "must be valid", :email => "Must be valid", :first_name => []})
|
23
|
-
@user.stubs(:role_types => role_types, :role => "1")
|
24
|
-
@user_none = mock_model("User")
|
25
|
-
end
|
26
|
-
|
27
|
-
def standard_builder(object=@user)
|
28
|
-
Padrino::Helpers::FormBuilder::StandardFormBuilder.new(self, object)
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'for #form_for method' do
|
32
|
-
should "display correct form html" do
|
33
|
-
actual_html = form_for(@user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { "Demo" }
|
34
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post', :content => "Demo") { actual_html }
|
35
|
-
assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
|
36
|
-
end
|
37
|
-
|
38
|
-
should "display correct form html with fake object" do
|
39
|
-
actual_html = form_for(:markup_user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.text_field :username }
|
40
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post') { actual_html }
|
41
|
-
assert_has_tag('form input', :type => 'text', :name => 'markup_user[username]') { actual_html }
|
42
|
-
assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
|
43
|
-
end
|
44
|
-
|
45
|
-
should "display correct form html for namespaced object" do
|
46
|
-
actual_html = form_for(Outer::UserAccount.new, '/register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.text_field :username }
|
47
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post') { actual_html }
|
48
|
-
assert_has_tag('form input', :type => 'text', :name => 'outer_user_account[username]') { actual_html }
|
49
|
-
end
|
50
|
-
|
51
|
-
should "display form specifying default builder setting" do
|
52
|
-
self.expects(:settings).returns(stub(:default_builder => 'FakeFormBuilder')).once
|
53
|
-
actual_html = ""
|
54
|
-
actual_html = form_for(@user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.foo_field }
|
55
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post') { actual_html }
|
56
|
-
assert_has_tag('span', :content => "bar") { actual_html }
|
57
|
-
end
|
58
|
-
|
59
|
-
should "display correct form html with remote option" do
|
60
|
-
actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :remote => true) { "Demo" }
|
61
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post', "data-remote" => 'true') { actual_html }
|
62
|
-
end
|
63
|
-
|
64
|
-
should "display correct form html with remote option and method put" do
|
65
|
-
actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :remote => true, :method => 'put') { "Demo" }
|
66
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :method => 'post', "data-remote" => 'true') { actual_html }
|
67
|
-
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
|
68
|
-
end
|
69
|
-
|
70
|
-
should "display correct form html with method :put" do
|
71
|
-
actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :method => 'put') { "Demo" }
|
72
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post') { actual_html }
|
73
|
-
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
|
74
|
-
end
|
75
|
-
|
76
|
-
should "display correct form html with method :delete" do
|
77
|
-
actual_html = form_for(@user, '/destroy', :"accept-charset" => "UTF-8", :method => 'delete') { "Demo" }
|
78
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/destroy', :method => 'post') { actual_html }
|
79
|
-
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'delete') { actual_html }
|
80
|
-
end
|
81
|
-
|
82
|
-
should "display correct form html with multipart" do
|
83
|
-
actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8", :multipart => true) { "Demo" }
|
84
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
|
85
|
-
end
|
86
|
-
|
87
|
-
should "support changing form builder type" do
|
88
|
-
form_html = proc { form_for(@user, '/register', :"accept-charset" => "UTF-8", :builder => "AbstractFormBuilder") { |f| f.text_field_block(:name) } }
|
89
|
-
assert_raises(NoMethodError) { form_html.call }
|
90
|
-
end
|
91
|
-
|
92
|
-
should "support using default standard builder" do
|
93
|
-
actual_html = form_for(@user, '/register') { |f| f.text_field_block(:name) }
|
94
|
-
assert_has_tag('form p input[type=text]') { actual_html }
|
95
|
-
end
|
96
|
-
|
97
|
-
should "display fail for form with nil object" do
|
98
|
-
assert_raises(RuntimeError) { form_for(@not_real, '/register', :id => 'register', :method => 'post') { "Demo" } }
|
99
|
-
end
|
100
|
-
|
101
|
-
should "display correct form in haml" do
|
102
|
-
visit '/haml/form_for'
|
103
|
-
assert_have_selector :form, :action => '/demo', :id => 'demo'
|
104
|
-
assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
|
105
|
-
assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
|
106
|
-
end
|
107
|
-
|
108
|
-
should "display correct form in erb" do
|
109
|
-
visit '/erb/form_for'
|
110
|
-
assert_have_selector :form, :action => '/demo', :id => 'demo'
|
111
|
-
assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
|
112
|
-
assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
|
113
|
-
end
|
114
|
-
|
115
|
-
should "display correct form in slim" do
|
116
|
-
visit '/slim/form_for'
|
117
|
-
assert_have_selector :form, :action => '/demo', :id => 'demo'
|
118
|
-
assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
|
119
|
-
assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
|
120
|
-
end
|
121
|
-
|
122
|
-
should "have a class of 'invalid' for fields with errors" do
|
123
|
-
actual_html = form_for(@user, '/register') {|f| f.text_field(:email) }
|
124
|
-
assert_has_tag(:input, :type => 'text', :name => 'user[email]', :id => 'user_email', :class => 'invalid') {actual_html }
|
125
|
-
end
|
126
|
-
|
127
|
-
should "not have a class of 'invalid' for fields with no errors" do
|
128
|
-
actual_html = form_for(@user, '/register') {|f| f.text_field(:first_name) }
|
129
|
-
assert_has_no_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name', :class => 'invalid') {actual_html }
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context 'for #fields_for method' do
|
134
|
-
should 'display correct fields html' do
|
135
|
-
actual_html = fields_for(@user) { |f| f.text_field(:first_name) }
|
136
|
-
assert_has_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name') { actual_html }
|
137
|
-
end
|
138
|
-
|
139
|
-
should 'display correct fields html with symbol object' do
|
140
|
-
actual_html = fields_for(:markup_user) { |f| f.text_field(:first_name) }
|
141
|
-
assert_has_tag(:input, :type => 'text', :name => 'markup_user[first_name]', :id => 'markup_user_first_name') { actual_html }
|
142
|
-
end
|
143
|
-
|
144
|
-
should "display fail for nil object" do
|
145
|
-
assert_raises(RuntimeError) { fields_for(@not_real) { |f| "Demo" } }
|
146
|
-
end
|
147
|
-
|
148
|
-
should 'display correct simple fields in haml' do
|
149
|
-
visit '/haml/fields_for'
|
150
|
-
assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
|
151
|
-
assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
152
|
-
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
|
153
|
-
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
154
|
-
end
|
155
|
-
|
156
|
-
should "display correct simple fields in erb" do
|
157
|
-
visit '/erb/fields_for'
|
158
|
-
assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
|
159
|
-
assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
160
|
-
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
|
161
|
-
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
162
|
-
end
|
163
|
-
|
164
|
-
should "display correct simple fields in slim" do
|
165
|
-
visit '/slim/fields_for'
|
166
|
-
assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
|
167
|
-
assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
168
|
-
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
|
169
|
-
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
# ===========================
|
174
|
-
# AbstractFormBuilder
|
175
|
-
# ===========================
|
176
|
-
|
177
|
-
context 'for #error_messages method' do
|
178
|
-
should "display correct form html with no record" do
|
179
|
-
actual_html = standard_builder(@user_none).error_messages(:header_message => "Demo form cannot be saved")
|
180
|
-
assert actual_html.blank?
|
181
|
-
end
|
182
|
-
|
183
|
-
should "display correct form html with valid record" do
|
184
|
-
actual_html = standard_builder.error_messages(:header_message => "Demo form cannot be saved", :style => "foo:bar", :class => "mine")
|
185
|
-
assert_has_tag('#field-errors h2', :content => "Demo form cannot be saved") { actual_html }
|
186
|
-
assert_has_tag('#field-errors ul li', :content => "B must be valid") { actual_html }
|
187
|
-
assert_has_tag('#field-errors ul li', :content => "A must be present") { actual_html }
|
188
|
-
assert_has_tag('#field-errors', :style => "foo:bar") { actual_html }
|
189
|
-
assert_has_tag('#field-errors', :class => "mine") { actual_html }
|
190
|
-
end
|
191
|
-
|
192
|
-
should "display correct form in haml" do
|
193
|
-
visit '/haml/form_for'
|
194
|
-
assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
195
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
|
196
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Second must be present"
|
197
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Third must be a number"
|
198
|
-
assert_have_selector '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
199
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
|
200
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
|
201
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
|
202
|
-
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
203
|
-
end
|
204
|
-
|
205
|
-
should "display correct form in erb" do
|
206
|
-
visit '/erb/form_for'
|
207
|
-
assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
208
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
|
209
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Second must be present"
|
210
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Third must be a number"
|
211
|
-
assert_have_selector '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
212
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
|
213
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
|
214
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
|
215
|
-
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
216
|
-
end
|
217
|
-
|
218
|
-
should "display correct form in slim" do
|
219
|
-
visit '/slim/form_for'
|
220
|
-
assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
221
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
|
222
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Second must be present"
|
223
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Third must be a number"
|
224
|
-
assert_have_selector '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
225
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
|
226
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
|
227
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
|
228
|
-
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
context 'for #error_message_on method' do
|
233
|
-
should "display correct form html with no record" do
|
234
|
-
actual_html = standard_builder(@user_none).error_message_on(:name)
|
235
|
-
assert actual_html.blank?
|
236
|
-
end
|
237
|
-
|
238
|
-
should "display error for specified invalid object" do
|
239
|
-
actual_html = standard_builder(@user).error_message_on(:a, :prepend => "foo", :append => "bar")
|
240
|
-
assert_has_tag('span.error', :content => "foo must be present bar") { actual_html }
|
241
|
-
end
|
242
|
-
|
243
|
-
should "display error for specified invalid object not matching class name" do
|
244
|
-
@bob = mock_model("User", :first_name => "Frank", :errors => { :foo => "must be bob" })
|
245
|
-
actual_html = standard_builder(@bob).error_message_on(:foo, :prepend => "foo", :append => "bar")
|
246
|
-
assert_has_tag('span.error', :content => "foo must be bob bar") { actual_html }
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
context 'for #label method' do
|
251
|
-
should "display correct label html" do
|
252
|
-
actual_html = standard_builder.label(:first_name, :class => 'large', :caption => "F. Name: ")
|
253
|
-
assert_has_tag('label', :class => 'large', :for => 'user_first_name', :content => "F. Name: ") { actual_html }
|
254
|
-
end
|
255
|
-
|
256
|
-
should "display correct label in haml" do
|
257
|
-
visit '/haml/form_for'
|
258
|
-
assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
|
259
|
-
assert_have_selector '#demo label', :content => "About Me: "
|
260
|
-
assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
|
261
|
-
end
|
262
|
-
|
263
|
-
should "display correct label in erb" do
|
264
|
-
visit '/erb/form_for'
|
265
|
-
assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
|
266
|
-
assert_have_selector '#demo label', :content => "About Me: "
|
267
|
-
assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
|
268
|
-
end
|
269
|
-
|
270
|
-
should "display correct label in slim" do
|
271
|
-
visit '/slim/form_for'
|
272
|
-
assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
|
273
|
-
assert_have_selector '#demo label', :content => "About Me: "
|
274
|
-
assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
context 'for #hidden_field method' do
|
279
|
-
should "display correct hidden field html" do
|
280
|
-
actual_html = standard_builder.hidden_field(:session_id, :class => 'hidden')
|
281
|
-
assert_has_tag('input.hidden[type=hidden]', :value => "54", :id => 'user_session_id', :name => 'user[session_id]') { actual_html }
|
282
|
-
end
|
283
|
-
|
284
|
-
should "display correct hidden field in haml" do
|
285
|
-
visit '/haml/form_for'
|
286
|
-
assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
|
287
|
-
assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
|
288
|
-
end
|
289
|
-
|
290
|
-
should "display correct hidden field in erb" do
|
291
|
-
visit '/erb/form_for'
|
292
|
-
assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
|
293
|
-
assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
|
294
|
-
end
|
295
|
-
|
296
|
-
should "display correct hidden field in slim" do
|
297
|
-
visit '/slim/form_for'
|
298
|
-
assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
|
299
|
-
assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
context 'for #text_field method' do
|
304
|
-
should "display correct text field html" do
|
305
|
-
actual_html = standard_builder.text_field(:first_name, :class => 'large')
|
306
|
-
assert_has_tag('input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]') { actual_html }
|
307
|
-
end
|
308
|
-
|
309
|
-
should "display correct text field in haml" do
|
310
|
-
visit '/haml/form_for'
|
311
|
-
assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
|
312
|
-
assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
|
313
|
-
end
|
314
|
-
|
315
|
-
should "display correct text field in erb" do
|
316
|
-
visit '/erb/form_for'
|
317
|
-
assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
|
318
|
-
assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
|
319
|
-
end
|
320
|
-
|
321
|
-
should "display correct text field in slim" do
|
322
|
-
visit '/slim/form_for'
|
323
|
-
assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
|
324
|
-
assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
|
-
context 'for #number_field method' do
|
329
|
-
should "display correct number field html" do
|
330
|
-
actual_html = standard_builder.number_field(:age, :class => 'numeric')
|
331
|
-
assert_has_tag('input.numeric[type=number]', :id => 'user_age', :name => 'user[age]') { actual_html }
|
332
|
-
end
|
333
|
-
|
334
|
-
should "display correct number field in haml" do
|
335
|
-
visit '/haml/form_for'
|
336
|
-
assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
337
|
-
end
|
338
|
-
|
339
|
-
should "display correct number field in erb" do
|
340
|
-
visit '/erb/form_for'
|
341
|
-
assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
342
|
-
end
|
343
|
-
|
344
|
-
should "display correct number field in slim" do
|
345
|
-
visit '/slim/form_for'
|
346
|
-
assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
context 'for #telephone_field method' do
|
351
|
-
should "display correct telephone field html" do
|
352
|
-
actual_html = standard_builder.telephone_field(:telephone, :class => 'numeric')
|
353
|
-
assert_has_tag('input.numeric[type=tel]', :id => 'user_telephone', :name => 'user[telephone]') { actual_html }
|
354
|
-
end
|
355
|
-
|
356
|
-
should "display correct telephone field in haml" do
|
357
|
-
visit '/haml/form_for'
|
358
|
-
assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
359
|
-
end
|
360
|
-
|
361
|
-
should "display correct telephone field in erb" do
|
362
|
-
visit '/erb/form_for'
|
363
|
-
assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
364
|
-
end
|
365
|
-
|
366
|
-
should "display correct telephone field in slim" do
|
367
|
-
visit '/slim/form_for'
|
368
|
-
assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
context 'for #search_field method' do
|
373
|
-
should "display correct search field html" do
|
374
|
-
actual_html = standard_builder.search_field(:search, :class => 'string')
|
375
|
-
assert_has_tag('input.string[type=search]', :id => 'user_search', :name => 'user[search]') { actual_html }
|
376
|
-
end
|
377
|
-
|
378
|
-
should "display correct search field in haml" do
|
379
|
-
visit '/haml/form_for'
|
380
|
-
assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
|
381
|
-
end
|
382
|
-
|
383
|
-
should "display correct search field in erb" do
|
384
|
-
visit '/erb/form_for'
|
385
|
-
assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
|
386
|
-
end
|
387
|
-
|
388
|
-
should "display correct search field in slim" do
|
389
|
-
visit '/slim/form_for'
|
390
|
-
assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
|
-
context 'for #email_field method' do
|
395
|
-
should "display correct email field html" do
|
396
|
-
actual_html = standard_builder.email_field(:email, :class => 'string')
|
397
|
-
assert_has_tag('input.string[type=email]', :id => 'user_email', :name => 'user[email]') { actual_html }
|
398
|
-
end
|
399
|
-
|
400
|
-
should "display correct email field in haml" do
|
401
|
-
visit '/haml/form_for'
|
402
|
-
assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
|
403
|
-
end
|
404
|
-
|
405
|
-
should "display correct email field in erb" do
|
406
|
-
visit '/erb/form_for'
|
407
|
-
assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
|
408
|
-
end
|
409
|
-
|
410
|
-
should "display correct email field in slim" do
|
411
|
-
visit '/slim/form_for'
|
412
|
-
assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
|
413
|
-
end
|
414
|
-
end
|
415
|
-
|
416
|
-
context 'for #url_field method' do
|
417
|
-
should "display correct url field html" do
|
418
|
-
actual_html = standard_builder.url_field(:webpage, :class => 'string')
|
419
|
-
assert_has_tag('input.string[type=url]', :id => 'user_webpage', :name => 'user[webpage]') { actual_html }
|
420
|
-
end
|
421
|
-
|
422
|
-
should "display correct url field in haml" do
|
423
|
-
visit '/haml/form_for'
|
424
|
-
assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
425
|
-
end
|
426
|
-
|
427
|
-
should "display correct url field in erb" do
|
428
|
-
visit '/erb/form_for'
|
429
|
-
assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
430
|
-
end
|
431
|
-
|
432
|
-
should "display correct url field in slim" do
|
433
|
-
visit '/slim/form_for'
|
434
|
-
assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
context 'for #check_box method' do
|
439
|
-
should "display correct checkbox html" do
|
440
|
-
actual_html = standard_builder.check_box(:confirm_destroy, :class => 'large')
|
441
|
-
assert_has_tag('input.large[type=checkbox]', :id => 'user_confirm_destroy', :name => 'user[confirm_destroy]') { actual_html }
|
442
|
-
assert_has_tag('input[type=hidden]', :name => 'user[confirm_destroy]', :value => '0') { actual_html }
|
443
|
-
end
|
444
|
-
|
445
|
-
should "display correct checkbox html when checked" do
|
446
|
-
actual_html = standard_builder.check_box(:confirm_destroy, :checked => true)
|
447
|
-
assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[confirm_destroy]') { actual_html }
|
448
|
-
end
|
449
|
-
|
450
|
-
should "display correct checkbox html as checked when object value matches" do
|
451
|
-
@user.stubs(:show_favorites => 'human')
|
452
|
-
actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
|
453
|
-
assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
|
454
|
-
end
|
455
|
-
|
456
|
-
should "display correct checkbox html as checked when object value is true" do
|
457
|
-
@user.stubs(:show_favorites => true)
|
458
|
-
actual_html = standard_builder.check_box(:show_favorites, :value => '1')
|
459
|
-
assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
|
460
|
-
end
|
461
|
-
|
462
|
-
should "display correct checkbox html as unchecked when object value doesn't match" do
|
463
|
-
@user.stubs(:show_favorites => 'alien')
|
464
|
-
actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
|
465
|
-
assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
|
466
|
-
end
|
467
|
-
|
468
|
-
should "display correct checkbox html as unchecked when object value is false" do
|
469
|
-
@user.stubs(:show_favorites => false)
|
470
|
-
actual_html = standard_builder.check_box(:show_favorites, :value => '1')
|
471
|
-
assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
|
472
|
-
end
|
473
|
-
|
474
|
-
should "display correct unchecked hidden field when specified" do
|
475
|
-
actual_html = standard_builder.check_box(:show_favorites, :value => 'female', :uncheck_value => 'false')
|
476
|
-
assert_has_tag('input[type=hidden]', :name => 'user[show_favorites]', :value => 'false') { actual_html }
|
477
|
-
end
|
478
|
-
|
479
|
-
should "display correct checkbox in haml" do
|
480
|
-
visit '/haml/form_for'
|
481
|
-
assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
|
482
|
-
end
|
483
|
-
|
484
|
-
should "display correct checkbox in erb" do
|
485
|
-
visit '/erb/form_for'
|
486
|
-
assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
|
487
|
-
end
|
488
|
-
|
489
|
-
should "display correct checkbox in slim" do
|
490
|
-
visit '/slim/form_for'
|
491
|
-
assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
|
492
|
-
end
|
493
|
-
end
|
494
|
-
|
495
|
-
context 'for #radio_button method' do
|
496
|
-
should "display correct radio button html" do
|
497
|
-
actual_html = standard_builder.radio_button(:gender, :value => 'male', :class => 'large')
|
498
|
-
assert_has_tag('input.large[type=radio]', :id => 'user_gender_male', :name => 'user[gender]', :value => 'male') { actual_html }
|
499
|
-
end
|
500
|
-
|
501
|
-
should "display correct radio button html when checked" do
|
502
|
-
actual_html = standard_builder.radio_button(:gender, :checked => true)
|
503
|
-
assert_has_tag('input[type=radio]', :checked => 'checked', :name => 'user[gender]') { actual_html }
|
504
|
-
end
|
505
|
-
|
506
|
-
should "display correct radio button html as checked when object value matches" do
|
507
|
-
@user.stubs(:gender => 'male')
|
508
|
-
actual_html = standard_builder.radio_button(:gender, :value => 'male')
|
509
|
-
assert_has_tag('input[type=radio]', :checked => 'checked', :name => 'user[gender]') { actual_html }
|
510
|
-
end
|
511
|
-
|
512
|
-
should "display correct radio button html as unchecked when object value doesn't match" do
|
513
|
-
@user.stubs(:gender => 'male')
|
514
|
-
actual_html = standard_builder.radio_button(:gender, :value => 'female')
|
515
|
-
assert_has_no_tag('input[type=radio]', :checked => 'checked') { actual_html }
|
516
|
-
end
|
517
|
-
|
518
|
-
should "display correct radio button in haml" do
|
519
|
-
visit '/haml/form_for'
|
520
|
-
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
|
521
|
-
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
|
522
|
-
assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
|
523
|
-
end
|
524
|
-
|
525
|
-
should "display correct radio button in erb" do
|
526
|
-
visit '/erb/form_for'
|
527
|
-
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
|
528
|
-
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
|
529
|
-
assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
|
530
|
-
end
|
531
|
-
|
532
|
-
should "display correct radio button in slim" do
|
533
|
-
visit '/slim/form_for'
|
534
|
-
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
|
535
|
-
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
|
536
|
-
assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
|
537
|
-
end
|
538
|
-
end
|
539
|
-
|
540
|
-
context 'for #text_area method' do
|
541
|
-
should "display correct text_area html" do
|
542
|
-
actual_html = standard_builder.text_area(:about, :class => 'large')
|
543
|
-
assert_has_tag('textarea.large', :id => 'user_about', :name => 'user[about]') { actual_html }
|
544
|
-
end
|
545
|
-
|
546
|
-
should "display correct text_area html and content" do
|
547
|
-
actual_html = standard_builder.text_area(:about, :value => "Demo", :rows => '5', :cols => '6')
|
548
|
-
assert_has_tag('textarea', :id => 'user_about', :content => 'Demo', :rows => '5', :cols => '6') { actual_html }
|
549
|
-
end
|
550
|
-
|
551
|
-
should "display correct text_area in haml" do
|
552
|
-
visit '/haml/form_for'
|
553
|
-
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
554
|
-
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
555
|
-
end
|
556
|
-
|
557
|
-
should "display correct text_area in erb" do
|
558
|
-
visit '/erb/form_for'
|
559
|
-
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
560
|
-
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
561
|
-
end
|
562
|
-
|
563
|
-
should "display correct text_area in slim" do
|
564
|
-
visit '/slim/form_for'
|
565
|
-
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
566
|
-
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
567
|
-
end
|
568
|
-
end
|
569
|
-
|
570
|
-
context 'for #password_field method' do
|
571
|
-
should "display correct password_field html" do
|
572
|
-
actual_html = standard_builder.password_field(:code, :class => 'large')
|
573
|
-
assert_has_tag('input.large[type=password]', :id => 'user_code', :name => 'user[code]') { actual_html }
|
574
|
-
end
|
575
|
-
|
576
|
-
should "display correct password_field in haml" do
|
577
|
-
visit '/haml/form_for'
|
578
|
-
assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
|
579
|
-
assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
|
580
|
-
end
|
581
|
-
|
582
|
-
should "display correct password_field in erb" do
|
583
|
-
visit '/erb/form_for'
|
584
|
-
assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
|
585
|
-
assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
|
586
|
-
end
|
587
|
-
|
588
|
-
should "display correct password_field in slim" do
|
589
|
-
visit '/slim/form_for'
|
590
|
-
assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
|
591
|
-
assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
|
592
|
-
end
|
593
|
-
end
|
594
|
-
|
595
|
-
context 'for #file_field method' do
|
596
|
-
should "display correct file_field html" do
|
597
|
-
actual_html = standard_builder.file_field(:photo, :class => 'large')
|
598
|
-
assert_has_tag('input.large[type=file]', :id => 'user_photo', :name => 'user[photo]') { actual_html }
|
599
|
-
end
|
600
|
-
|
601
|
-
should "display correct file_field in haml" do
|
602
|
-
visit '/haml/form_for'
|
603
|
-
assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
604
|
-
assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
605
|
-
end
|
606
|
-
|
607
|
-
should "display correct file_field in erb" do
|
608
|
-
visit '/erb/form_for'
|
609
|
-
assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
610
|
-
assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
611
|
-
end
|
612
|
-
|
613
|
-
should "display correct file_field in slim" do
|
614
|
-
visit '/slim/form_for'
|
615
|
-
assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
616
|
-
assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
617
|
-
end
|
618
|
-
end
|
619
|
-
|
620
|
-
context 'for #select method' do
|
621
|
-
should "display correct select html" do
|
622
|
-
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :class => 'selecty')
|
623
|
-
assert_has_tag('select.selecty', :id => 'user_state', :name => 'user[state]') { actual_html }
|
624
|
-
assert_has_tag('select.selecty option', :count => 3) { actual_html }
|
625
|
-
assert_has_tag('select.selecty option', :value => 'California', :content => 'California') { actual_html }
|
626
|
-
assert_has_tag('select.selecty option', :value => 'Texas', :content => 'Texas') { actual_html }
|
627
|
-
assert_has_tag('select.selecty option', :value => 'Wyoming', :content => 'Wyoming') { actual_html }
|
628
|
-
end
|
629
|
-
|
630
|
-
should "display correct select html with selected item if it matches value" do
|
631
|
-
@user.stubs(:state => 'California')
|
632
|
-
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'])
|
633
|
-
assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
|
634
|
-
assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
|
635
|
-
assert_has_tag('select option', :value => 'California', :selected => 'selected') { actual_html }
|
636
|
-
end
|
637
|
-
|
638
|
-
should "display correct select html with selected item if it matches full value" do
|
639
|
-
@user.stubs(:state => 'Cali')
|
640
|
-
actual_html = standard_builder.select(:state, :options => ['Cali', 'California', 'Texas', 'Wyoming'])
|
641
|
-
assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
|
642
|
-
assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
|
643
|
-
assert_has_tag('select option', :value => 'Cali', :selected => 'selected') { actual_html }
|
644
|
-
assert_has_tag('select option', :value => 'California') { actual_html }
|
645
|
-
end
|
646
|
-
|
647
|
-
should "display correct select html with multiple selected items" do
|
648
|
-
@user.stubs(:pickles => ['foo', 'bar'])
|
649
|
-
actual_html = standard_builder.select(
|
650
|
-
:pickles, :options => [ ['Foo', 'foo'], ['Bar', 'bar'], ['Baz', 'baz'], ['Bar Buz', 'bar buz'] ]
|
651
|
-
)
|
652
|
-
assert_has_tag('option', :value => 'foo', :content => 'Foo', :selected => 'selected') { actual_html }
|
653
|
-
assert_has_tag('option', :value => 'bar', :content => 'Bar', :selected => 'selected') { actual_html }
|
654
|
-
assert_has_tag('option', :value => 'baz', :content => 'Baz') { actual_html }
|
655
|
-
assert_has_tag('option', :value => 'bar buz', :content => 'Bar Buz') { actual_html }
|
656
|
-
end
|
657
|
-
|
658
|
-
should "display correct select html with include_blank" do
|
659
|
-
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => true)
|
660
|
-
assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
|
661
|
-
assert_has_tag('select option', :count => 4) { actual_html }
|
662
|
-
assert_has_tag('select option:first-child', :content => '') { actual_html }
|
663
|
-
assert_has_tag('select option:first-child', :value => '') { actual_html }
|
664
|
-
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => 'Select')
|
665
|
-
assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
|
666
|
-
assert_has_tag('select option', :count => 4) { actual_html }
|
667
|
-
assert_has_tag('select option:first-child', :content => 'Select') { actual_html }
|
668
|
-
assert_has_tag('select option:first-child', :value => '') { actual_html }
|
669
|
-
end
|
670
|
-
|
671
|
-
should "display correct select html with collection passed in" do
|
672
|
-
actual_html = standard_builder.select(:role, :collection => @user.role_types, :fields => [:name, :id])
|
673
|
-
assert_has_tag('select', :id => 'user_role', :name => 'user[role]') { actual_html }
|
674
|
-
assert_has_tag('select option', :count => 3) { actual_html }
|
675
|
-
assert_has_tag('select option', :value => '1', :content => 'Admin', :selected => 'selected') { actual_html }
|
676
|
-
assert_has_tag('select option', :value => '2', :content => 'Moderate') { actual_html }
|
677
|
-
assert_has_tag('select option', :value => '3', :content => 'Limited') { actual_html }
|
678
|
-
end
|
679
|
-
|
680
|
-
should "display correct select in haml" do
|
681
|
-
visit '/haml/form_for'
|
682
|
-
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
683
|
-
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
684
|
-
end
|
685
|
-
|
686
|
-
should "display correct select in erb" do
|
687
|
-
visit '/erb/form_for'
|
688
|
-
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
689
|
-
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
690
|
-
end
|
691
|
-
|
692
|
-
should "display correct select in slim" do
|
693
|
-
visit '/slim/form_for'
|
694
|
-
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
695
|
-
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
696
|
-
end
|
697
|
-
end
|
698
|
-
|
699
|
-
context 'for #submit method' do
|
700
|
-
should "display correct submit button html with no options" do
|
701
|
-
actual_html = standard_builder.submit
|
702
|
-
assert_has_tag('input[type=submit]', :value => "Submit") { actual_html }
|
703
|
-
end
|
704
|
-
|
705
|
-
should "display correct submit button html" do
|
706
|
-
actual_html = standard_builder.submit("Commit", :class => 'large')
|
707
|
-
assert_has_tag('input.large[type=submit]', :value => "Commit") { actual_html }
|
708
|
-
end
|
709
|
-
|
710
|
-
should "display correct submit button in haml" do
|
711
|
-
visit '/haml/form_for'
|
712
|
-
assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
|
713
|
-
assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
|
714
|
-
end
|
715
|
-
|
716
|
-
should "display correct submit button in erb" do
|
717
|
-
visit '/erb/form_for'
|
718
|
-
assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
|
719
|
-
assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
|
720
|
-
end
|
721
|
-
|
722
|
-
should "display correct submit button in slim" do
|
723
|
-
visit '/slim/form_for'
|
724
|
-
assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
|
725
|
-
assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
|
726
|
-
end
|
727
|
-
end
|
728
|
-
|
729
|
-
context 'for #image_submit method' do
|
730
|
-
setup do
|
731
|
-
@stamp = stop_time_for_test.to_i
|
732
|
-
end
|
733
|
-
|
734
|
-
should "display correct image submit button html with no options" do
|
735
|
-
actual_html = standard_builder.image_submit('buttons/ok.png')
|
736
|
-
assert_has_tag('input[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
|
737
|
-
end
|
738
|
-
|
739
|
-
should "display correct image submit button html" do
|
740
|
-
actual_html = standard_builder.image_submit('/system/ok.png', :class => 'large')
|
741
|
-
assert_has_tag('input.large[type=image]', :src => "/system/ok.png") { actual_html }
|
742
|
-
end
|
743
|
-
|
744
|
-
should "display correct image submit button in haml" do
|
745
|
-
visit '/haml/form_for'
|
746
|
-
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
747
|
-
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
748
|
-
end
|
749
|
-
|
750
|
-
should "display correct image submit button in erb" do
|
751
|
-
visit '/erb/form_for'
|
752
|
-
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
753
|
-
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
754
|
-
end
|
755
|
-
|
756
|
-
should "display correct image submit button in slim" do
|
757
|
-
visit '/slim/form_for'
|
758
|
-
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
759
|
-
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
760
|
-
end
|
761
|
-
end
|
762
|
-
|
763
|
-
context 'for #fields_for method' do
|
764
|
-
setup do
|
765
|
-
@telephone = mock_model("Telephone", :number => "4568769876")
|
766
|
-
@user.stubs(:telephone).returns(@telephone)
|
767
|
-
@businesses = [ mock_model("Business", :name => "Silver", :new_record? => false, :id => 20) ]
|
768
|
-
@businesses << mock_model("Business", :name => "Gold", :new_record? => true)
|
769
|
-
@addresses = [ mock_model("Address", :name => "Foo", :new_record? => false, :id => 20, :businesses => @businesses) ]
|
770
|
-
@addresses << mock_model("Address", :name => "Bar", :new_record? => true, :businesses => @businesses)
|
771
|
-
@user.stubs(:addresses).returns(@addresses)
|
772
|
-
end
|
773
|
-
|
774
|
-
should "display nested children fields one-to-one within form" do
|
775
|
-
actual_html = standard_builder.fields_for :telephone do |child_form|
|
776
|
-
child_form.label(:number) +
|
777
|
-
child_form.text_field(:number) +
|
778
|
-
child_form.check_box('_destroy')
|
779
|
-
end
|
780
|
-
assert_has_tag('label', :for => 'user_telephone_attributes_number') { actual_html }
|
781
|
-
assert_has_tag('input', :type => 'text', :id => 'user_telephone_attributes_number', :name => 'user[telephone_attributes][number]', :value => "4568769876") { actual_html }
|
782
|
-
assert_has_tag('input', :type => 'hidden', :name => 'user[telephone_attributes][_destroy]', :value => '0') { actual_html }
|
783
|
-
assert_has_tag('input', :type => 'checkbox', :id => 'user_telephone_attributes__destroy', :name => 'user[telephone_attributes][_destroy]', :value => '1') { actual_html }
|
784
|
-
end
|
785
|
-
|
786
|
-
should "display nested children fields one-to-many within form" do
|
787
|
-
actual_html = standard_builder.fields_for(:addresses) do |child_form|
|
788
|
-
html = child_form.label(:name)
|
789
|
-
html << child_form.check_box('_destroy') unless child_form.object.new_record?
|
790
|
-
html << child_form.text_field(:name)
|
791
|
-
end
|
792
|
-
# Address 1 (Saved)
|
793
|
-
assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '20') { actual_html }
|
794
|
-
assert_has_tag('label', :for => 'user_addresses_attributes_0_name', :content => 'Name') { actual_html }
|
795
|
-
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]') { actual_html }
|
796
|
-
assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]') { actual_html }
|
797
|
-
# Address 2 (New)
|
798
|
-
assert_has_no_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_1_id') { actual_html }
|
799
|
-
assert_has_tag('label', :for => 'user_addresses_attributes_1_name', :content => 'Name') { actual_html }
|
800
|
-
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_name', :name => 'user[addresses_attributes][1][name]') { actual_html }
|
801
|
-
assert_has_no_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_1__destroy') { actual_html }
|
802
|
-
end
|
803
|
-
|
804
|
-
should "display fields for explicit instance object" do
|
805
|
-
address = mock_model("Address", :name => "Page", :new_record? => false, :id => 40)
|
806
|
-
actual_html = standard_builder.fields_for(:addresses, address) do |child_form|
|
807
|
-
html = child_form.label(:name)
|
808
|
-
html << child_form.text_field(:name)
|
809
|
-
html << child_form.check_box('_destroy')
|
810
|
-
end
|
811
|
-
assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '40') { actual_html }
|
812
|
-
assert_has_tag('label', :for => 'user_addresses_attributes_0_name', :content => 'Name') { actual_html }
|
813
|
-
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]', :value => "Page") { actual_html }
|
814
|
-
assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]', :value => '1') { actual_html }
|
815
|
-
end
|
816
|
-
|
817
|
-
should "display fields for collection object" do
|
818
|
-
addresses = @addresses + [mock_model("Address", :name => "Walter", :new_record? => false, :id => 50)]
|
819
|
-
actual_html = standard_builder.fields_for(:addresses, addresses) do |child_form|
|
820
|
-
child_form.label(:name) +
|
821
|
-
child_form.text_field(:name) +
|
822
|
-
child_form.check_box('_destroy')
|
823
|
-
end
|
824
|
-
# Address 1
|
825
|
-
assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '20') { actual_html }
|
826
|
-
assert_has_tag('label', :for => 'user_addresses_attributes_0_name', :content => 'Name') { actual_html }
|
827
|
-
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]', :value => "Foo") { actual_html }
|
828
|
-
assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]') { actual_html }
|
829
|
-
# Address 3
|
830
|
-
assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_2_id', :value => '50') { actual_html }
|
831
|
-
assert_has_tag('label', :for => 'user_addresses_attributes_2_name', :content => 'Name') { actual_html }
|
832
|
-
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_2_name', :name => 'user[addresses_attributes][2][name]', :value => "Walter") { actual_html }
|
833
|
-
assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_2__destroy') { actual_html }
|
834
|
-
end
|
835
|
-
|
836
|
-
should "display fields for arbitrarily deep nested forms" do
|
837
|
-
actual_html = standard_builder.fields_for :addresses do |child_form|
|
838
|
-
child_form.fields_for(:businesses) do |second_child_form|
|
839
|
-
second_child_form.label(:name) +
|
840
|
-
second_child_form.text_field(:name) +
|
841
|
-
second_child_form.check_box('_destroy')
|
842
|
-
end
|
843
|
-
end
|
844
|
-
assert_has_tag('label', :for => 'user_addresses_attributes_1_businesses_attributes_0_name', :content => 'Name') { actual_html }
|
845
|
-
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_0_name', :name => 'user[addresses_attributes][1][businesses_attributes][0][name]') { actual_html }
|
846
|
-
end
|
847
|
-
|
848
|
-
should "display nested children fields in erb" do
|
849
|
-
visit '/erb/fields_for'
|
850
|
-
# Telephone
|
851
|
-
assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
|
852
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
|
853
|
-
# Address 1 (Saved)
|
854
|
-
assert_have_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
|
855
|
-
assert_have_selector('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
|
856
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
|
857
|
-
assert_have_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
|
858
|
-
# Address 2 (New)
|
859
|
-
assert_have_no_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
|
860
|
-
assert_have_selector('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
|
861
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
|
862
|
-
assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
|
863
|
-
end
|
864
|
-
|
865
|
-
should "display nested children fields in haml" do
|
866
|
-
visit '/haml/fields_for'
|
867
|
-
# Telephone
|
868
|
-
assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
|
869
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
|
870
|
-
# Address 1 (Saved)
|
871
|
-
assert_have_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
|
872
|
-
assert_have_selector('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
|
873
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
|
874
|
-
assert_have_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
|
875
|
-
# Address 2 (New)
|
876
|
-
assert_have_no_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
|
877
|
-
assert_have_selector('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
|
878
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
|
879
|
-
assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
|
880
|
-
end
|
881
|
-
|
882
|
-
should "display nested children fields in slim" do
|
883
|
-
visit '/slim/fields_for'
|
884
|
-
# Telephone
|
885
|
-
assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
|
886
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
|
887
|
-
# Address 1 (Saved)
|
888
|
-
assert_have_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
|
889
|
-
assert_have_selector('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
|
890
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
|
891
|
-
assert_have_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
|
892
|
-
# Address 2 (New)
|
893
|
-
assert_have_no_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
|
894
|
-
assert_have_selector('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
|
895
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
|
896
|
-
assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
|
897
|
-
end
|
898
|
-
end
|
899
|
-
|
900
|
-
# ===========================
|
901
|
-
# StandardFormBuilder
|
902
|
-
# ===========================
|
903
|
-
|
904
|
-
context 'for #text_field_block method' do
|
905
|
-
should "display correct text field block html" do
|
906
|
-
actual_html = standard_builder.text_field_block(:first_name, :class => 'large', :caption => "FName")
|
907
|
-
assert_has_tag('p label', :for => 'user_first_name', :content => "FName") { actual_html }
|
908
|
-
assert_has_tag('p input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]') { actual_html }
|
909
|
-
end
|
910
|
-
|
911
|
-
should "display correct text field block in haml" do
|
912
|
-
visit '/haml/form_for'
|
913
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
|
914
|
-
assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
|
915
|
-
end
|
916
|
-
|
917
|
-
should "display correct text field block in erb" do
|
918
|
-
visit '/erb/form_for'
|
919
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
|
920
|
-
assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
|
921
|
-
end
|
922
|
-
|
923
|
-
should "display correct text field block in slim" do
|
924
|
-
visit '/slim/form_for'
|
925
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
|
926
|
-
assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
|
927
|
-
end
|
928
|
-
end
|
929
|
-
|
930
|
-
context 'for #text_area_block method' do
|
931
|
-
should "display correct text area block html" do
|
932
|
-
actual_html = standard_builder.text_area_block(:about, :class => 'large', :caption => "About Me")
|
933
|
-
assert_has_tag('p label', :for => 'user_about', :content => "About Me") { actual_html }
|
934
|
-
assert_has_tag('p textarea', :id => 'user_about', :name => 'user[about]') { actual_html }
|
935
|
-
end
|
936
|
-
|
937
|
-
should "display correct text area block in haml" do
|
938
|
-
visit '/haml/form_for'
|
939
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
|
940
|
-
assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
|
941
|
-
end
|
942
|
-
|
943
|
-
should "display correct text area block in erb" do
|
944
|
-
visit '/erb/form_for'
|
945
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
|
946
|
-
assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
|
947
|
-
end
|
948
|
-
|
949
|
-
should "display correct text area block in slim" do
|
950
|
-
visit '/slim/form_for'
|
951
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
|
952
|
-
assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
|
953
|
-
end
|
954
|
-
end
|
955
|
-
|
956
|
-
context 'for #password_field_block method' do
|
957
|
-
should "display correct password field block html" do
|
958
|
-
actual_html = standard_builder.password_field_block(:keycode, :class => 'large', :caption => "Code: ")
|
959
|
-
assert_has_tag('p label', :for => 'user_keycode', :content => "Code: ") { actual_html }
|
960
|
-
assert_has_tag('p input.large[type=password]', :id => 'user_keycode', :name => 'user[keycode]') { actual_html }
|
961
|
-
end
|
962
|
-
|
963
|
-
should "display correct password field block in haml" do
|
964
|
-
visit '/haml/form_for'
|
965
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
|
966
|
-
assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
|
967
|
-
end
|
968
|
-
|
969
|
-
should "display correct password field block in erb" do
|
970
|
-
visit '/erb/form_for'
|
971
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
|
972
|
-
assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
|
973
|
-
end
|
974
|
-
|
975
|
-
should "display correct password field block in slim" do
|
976
|
-
visit '/slim/form_for'
|
977
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
|
978
|
-
assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
|
979
|
-
end
|
980
|
-
end
|
981
|
-
|
982
|
-
context 'for #file_field_block method' do
|
983
|
-
should "display correct file field block html" do
|
984
|
-
actual_html = standard_builder.file_field_block(:photo, :class => 'large', :caption => "Photo: ")
|
985
|
-
assert_has_tag('p label', :for => 'user_photo', :content => "Photo: ") { actual_html }
|
986
|
-
assert_has_tag('p input.large[type=file]', :id => 'user_photo', :name => 'user[photo]') { actual_html }
|
987
|
-
end
|
988
|
-
|
989
|
-
should "display correct file field block in haml" do
|
990
|
-
visit '/haml/form_for'
|
991
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
|
992
|
-
assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
993
|
-
end
|
994
|
-
|
995
|
-
should "display correct file field block in erb" do
|
996
|
-
visit '/erb/form_for'
|
997
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
|
998
|
-
assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
999
|
-
end
|
1000
|
-
|
1001
|
-
should "display correct file field block in slim" do
|
1002
|
-
visit '/slim/form_for'
|
1003
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
|
1004
|
-
assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
1005
|
-
end
|
1006
|
-
end
|
1007
|
-
|
1008
|
-
context 'for #check_box_block method' do
|
1009
|
-
should "display correct check box block html" do
|
1010
|
-
actual_html = standard_builder.check_box_block(:remember_me, :class => 'large', :caption => "Remember session?")
|
1011
|
-
assert_has_tag('p label', :for => 'user_remember_me', :content => "Remember session?") { actual_html }
|
1012
|
-
assert_has_tag('p input.large[type=checkbox]', :id => 'user_remember_me', :name => 'user[remember_me]') { actual_html }
|
1013
|
-
end
|
1014
|
-
|
1015
|
-
should "display correct check box block in haml" do
|
1016
|
-
visit '/haml/form_for'
|
1017
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
|
1018
|
-
assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
|
1019
|
-
end
|
1020
|
-
|
1021
|
-
should "display correct check box block in erb" do
|
1022
|
-
visit '/erb/form_for'
|
1023
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
|
1024
|
-
assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
|
1025
|
-
end
|
1026
|
-
|
1027
|
-
should "display correct check box block in slim" do
|
1028
|
-
visit '/slim/form_for'
|
1029
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
|
1030
|
-
assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
|
1031
|
-
end
|
1032
|
-
end
|
1033
|
-
|
1034
|
-
context 'for #select_block method' do
|
1035
|
-
should "display correct select_block block html" do
|
1036
|
-
actual_html = standard_builder.select_block(:country, :options => ['USA', 'Canada'], :class => 'large', :caption => "Your country")
|
1037
|
-
assert_has_tag('p label', :for => 'user_country', :content => "Your country") { actual_html }
|
1038
|
-
assert_has_tag('p select', :id => 'user_country', :name => 'user[country]') { actual_html }
|
1039
|
-
assert_has_tag('p select option', :content => 'USA') { actual_html }
|
1040
|
-
assert_has_tag('p select option', :content => 'Canada') { actual_html }
|
1041
|
-
end
|
1042
|
-
|
1043
|
-
should "display correct select_block block in haml" do
|
1044
|
-
visit '/haml/form_for'
|
1045
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
|
1046
|
-
assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
|
1047
|
-
assert_have_selector '#demo2 p select option', :content => 'California'
|
1048
|
-
assert_have_selector '#demo2 p select option', :content => 'Texas'
|
1049
|
-
end
|
1050
|
-
|
1051
|
-
should "display correct select_block block in erb" do
|
1052
|
-
visit '/erb/form_for'
|
1053
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
|
1054
|
-
assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
|
1055
|
-
end
|
1056
|
-
|
1057
|
-
should "display correct select_block block in slim" do
|
1058
|
-
visit '/slim/form_for'
|
1059
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
|
1060
|
-
assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
|
1061
|
-
end
|
1062
|
-
end
|
1063
|
-
|
1064
|
-
context 'for #submit_block method' do
|
1065
|
-
should "display correct submit block html" do
|
1066
|
-
actual_html = standard_builder.submit_block("Update", :class => 'large')
|
1067
|
-
assert_has_tag('p input.large[type=submit]', :value => 'Update') { actual_html }
|
1068
|
-
end
|
1069
|
-
|
1070
|
-
should "display correct submit block in haml" do
|
1071
|
-
visit '/haml/form_for'
|
1072
|
-
assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
|
1073
|
-
end
|
1074
|
-
|
1075
|
-
should "display correct submit block in erb" do
|
1076
|
-
visit '/erb/form_for'
|
1077
|
-
assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
|
1078
|
-
end
|
1079
|
-
|
1080
|
-
should "display correct submit block in slim" do
|
1081
|
-
visit '/slim/form_for'
|
1082
|
-
assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
|
1083
|
-
end
|
1084
|
-
end
|
1085
|
-
|
1086
|
-
context 'for #image_submit_block method' do
|
1087
|
-
setup do
|
1088
|
-
@stamp = stop_time_for_test.to_i
|
1089
|
-
end
|
1090
|
-
|
1091
|
-
should "display correct image submit block html" do
|
1092
|
-
actual_html = standard_builder.image_submit_block("buttons/ok.png", :class => 'large')
|
1093
|
-
assert_has_tag('p input.large[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
|
1094
|
-
end
|
1095
|
-
|
1096
|
-
should "display correct image submit block in haml" do
|
1097
|
-
visit '/haml/form_for'
|
1098
|
-
assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
1099
|
-
end
|
1100
|
-
|
1101
|
-
should "display correct image submit block in slim" do
|
1102
|
-
visit '/slim/form_for'
|
1103
|
-
assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
1104
|
-
end
|
1105
|
-
end
|
1106
|
-
end
|