Class: ActionView::TestCase
Overview
Read more about TestCase
in Testing Rails Applications in the guides.
Constant Summary
::ActiveSupport::Testing::Assertions
- Included
::ActiveSupport::TestCase
- Inherited
::ActionDispatch::Assertions::ResponseAssertions
- Included
Helpers::AssetUrlHelper
- Included
ASSET_EXTENSIONS, ASSET_PUBLIC_DIRECTORIES, URI_REGEXP
Helpers::TagHelper
- Included
ARIA_PREFIXES, BOOLEAN_ATTRIBUTES, DATA_PREFIXES, PRE_CONTENT_STRINGS, TAG_TYPES
Helpers::AssetTagHelper
- Included
Helpers::ContentExfiltrationPreventionHelper
- Included
CLOSE_CDATA_COMMENT, CLOSE_FORM_TAG, CLOSE_OPTION_TAG, CLOSE_QUOTES_COMMENT, CONTENT_EXFILTRATION_PREVENTION_MARKUP
Helpers::ControllerHelper
- Included
Helpers::DateHelper
- Included
MINUTES_IN_QUARTER_YEAR, MINUTES_IN_THREE_QUARTERS_YEAR, MINUTES_IN_YEAR
Helpers::UrlHelper
- Included
BUTTON_TAG_METHOD_VERBS, STRINGIFIED_COMMON_METHODS
RecordIdentifier
- Included
Helpers::JavaScriptHelper
- Included
Helpers::TranslationHelper
- Included
MISSING_TRANSLATION, NO_DEFAULT
Behavior
- Included
Behavior
- Attributes & Methods
Class Attribute Summary
::ActiveSupport::TestCase
- Inherited
.file_fixture_path, .file_fixture_path?, | |
.test_order | Returns the order in which test cases are run. |
.test_order= | Sets the order in which test cases are run. |
Class Method Summary
::ActiveSupport::TestCase
- Inherited
.fixture_paths | Returns the |
.fixture_paths= | Sets the given path to the fixture set. |
.parallelize | Parallelizes the test suite. |
.parallelize_setup | Set up hook for parallel testing. |
.parallelize_teardown | Clean up hook for parallel testing. |
::ActiveSupport::Testing::Declarative
- Extended
Instance Attribute Summary
Behavior
- Included
#_helper_methods, #_helper_methods?, #controller, #lookup_context, #output_buffer, | |
#rendered | Returns the content rendered by the last |
#request |
RoutingUrlFor
- Included
Helpers
- Included
Helpers::TranslationHelper
- Included
#raise_on_missing_translations | Specify whether an error should be raised for missing translations. |
Helpers::FormHelper
- Included
#default_form_builder, #form_with_generates_ids, #form_with_generates_remote_forms, #multiple_file_field_include_hidden |
Helpers::FormTagHelper
- Included
Helpers::SanitizeHelper
- Included
Helpers::UrlHelper
- Included
Helpers::ControllerHelper
- Included
Helpers::ContentExfiltrationPreventionHelper
- Included
Helpers::CacheHelper
- Included
#caching? | Returns whether the current view fragment is within a |
Helpers::AssetTagHelper
- Included
Context
- Included
::ActiveSupport::TestCase
- Inherited
::ActiveSupport::Testing::TimeHelpers
- Included
::ActiveSupport::Testing::TaggedLogging
- Included
Instance Method Summary
Behavior
- Included
#_routes, #_user_defined_ivars, | |
#_view | Alias for Behavior#view. |
#config, #method_missing, #render, #rendered_views, #respond_to_missing?, #setup_with_controller, | |
#view | The instance of |
#view_assigns | Returns a |
#document_root_element | Need to experiment if this priority is the best one: rendered => output_buffer. |
RoutingUrlFor
- Included
#url_for | Returns the URL for the set of |
#_generate_paths_by_default, #_routes_context, #ensure_only_path_option, #url_options |
Helpers::TranslationHelper
- Included
#l | Alias for Helpers::TranslationHelper#localize. |
#localize | Delegates to |
#t | Alias for Helpers::TranslationHelper#translate. |
#translate | Delegates to |
#missing_translation, #scope_key_by_partial |
Helpers::RenderingHelper
- Included
#_layout_for | Overrides _layout_for in the context object so it supports the case a block is passed to a partial. |
#render | Renders a template and returns the result. |
Helpers::NumberHelper
- Included
Helpers::JavaScriptHelper
- Included
#escape_javascript | Escapes carriage returns and single and double quotes for JavaScript segments. |
#j | Alias for Helpers::JavaScriptHelper#escape_javascript. |
#javascript_tag | Returns a JavaScript tag with the |
#javascript_cdata_section |
Helpers::FormOptionsHelper
- Included
#collection_check_boxes | |
#collection_checkboxes | Returns check box tags for the collection of existing return values of |
#collection_radio_buttons | Returns radio button tags for the collection of existing return values of |
#collection_select | Returns |
#grouped_collection_select | Returns |
#grouped_options_for_select | Returns a string of |
#option_groups_from_collection_for_select | Returns a string of |
#options_for_select | Accepts a container (hash, array, enumerable, your type) and returns a string of option tags. |
#options_from_collection_for_select | Returns a string of option tags that have been compiled by iterating over the |
#select | Create a select tag and a series of contained option tags for the provided object and method. |
#time_zone_options_for_select | Returns a string of option tags for pretty much any time zone in the world. |
#time_zone_select | Returns select and option tags for the given object and method, using |
#weekday_options_for_select | Returns a string of option tags for the days of the week. |
#weekday_select | Returns select and option tags for the given object and method, using |
#extract_selected_and_disabled, #extract_values_from_collection, #option_html_attributes, #option_text_and_value, #option_value_selected?, #prompt_text, #value_for_collection |
Helpers::FormHelper
- Included
#check_box | Alias for Helpers::FormHelper#checkbox. |
#checkbox | Returns a checkbox tag tailored for accessing a specified attribute (identified by |
#color_field | Returns a text_field of type “color”. |
#date_field | Returns a text_field of type “date”. |
#datetime_field | Returns a text_field of type “datetime-local”. |
#datetime_local_field | Alias for Helpers::FormHelper#datetime_field. |
#email_field | Returns a text_field of type “email”. |
#fields | Scopes input fields with either an explicit scope or model. |
#fields_for | Creates a scope around a specific model object like |
#file_field | Returns a file upload input tag tailored for accessing a specified attribute (identified by |
#form_for | Creates a form that allows the user to create or update the attributes of a specific model object. |
#form_with | Creates a form tag based on mixing URLs, scopes, or models. |
#hidden_field | Returns a hidden input tag tailored for accessing a specified attribute (identified by |
#label | Returns a label tag tailored for labelling an input field for a specified attribute (identified by |
#month_field | Returns a text_field of type “month”. |
#number_field | Returns an input tag of type “number”. |
#password_field | Returns an input tag of the “password” type tailored for accessing a specified attribute (identified by |
#phone_field | Alias for Helpers::FormHelper#telephone_field. |
#radio_button | Returns a radio button tag for accessing a specified attribute (identified by |
#range_field | Returns an input tag of type “range”. |
#search_field | Returns an input of type “search” for accessing a specified attribute (identified by |
#telephone_field | Returns a text_field of type “tel”. |
#text_area | Alias for Helpers::FormHelper#textarea. |
#text_field | Returns an input tag of the “text” type tailored for accessing a specified attribute (identified by |
#textarea | Returns a textarea opening and closing tag set tailored for accessing a specified attribute (identified by |
#time_field | Returns a text_field of type “time”. |
#url_field | Returns a text_field of type “url”. |
#week_field | Returns a text_field of type “week”. |
#default_form_builder_class, #html_options_for_form_with, #instantiate_builder, #_object_for_form_builder, #apply_form_for_options! |
RecordIdentifier
- Included
#dom_class | The DOM class convention is to use the singular form of an object or class. |
#dom_id | The DOM id convention is to use the singular form of an object or class with the id following an underscore. |
#record_key_for_dom_id | Returns a string representation of the key attribute(s) that is suitable for use in an HTML DOM id. |
ModelNaming
- Included
#convert_to_model | Converts the given object to an Active Model compliant one. |
#model_name_from_record_or_class |
Helpers::FormTagHelper
- Included
#button_tag | Creates a button element that defines a |
#check_box_tag | Alias for Helpers::FormTagHelper#checkbox_tag. |
#checkbox_tag | Creates a check box form input tag. |
#color_field_tag | Creates a text field of type “color”. |
#date_field_tag | Creates a text field of type “date”. |
#datetime_field_tag | Creates a text field of type “datetime-local”. |
#datetime_local_field_tag | Alias for Helpers::FormTagHelper#datetime_field_tag. |
#email_field_tag | Creates a text field of type “email”. |
#field_id | Generate an HTML |
#field_name | Generate an HTML |
#field_set_tag | Creates a field set for grouping HTML form elements. |
#fieldset_tag | Alias for Helpers::FormTagHelper#field_set_tag. |
#file_field_tag | Creates a file upload field. |
#form_tag | Starts a form tag that points the action to a URL configured with |
#hidden_field_tag | Creates a hidden form input field used to transmit data that would be lost due to HTTP’s statelessness or data that should be hidden from the user. |
#image_submit_tag | Displays an image which when clicked will submit the form. |
#label_tag | Creates a label element. |
#month_field_tag | Creates a text field of type “month”. |
#number_field_tag | Creates a number field. |
#password_field_tag | Creates a password field, a masked text field that will hide the users input behind a mask character. |
#phone_field_tag | Alias for Helpers::FormTagHelper#telephone_field_tag. |
#radio_button_tag | Creates a radio button; use groups of radio buttons named the same to allow users to select from a group of options. |
#range_field_tag | Creates a range form element. |
#search_field_tag | Creates a text field of type “search”. |
#select_tag | Creates a dropdown selection box, or if the |
#submit_tag | Creates a submit button with the text |
#telephone_field_tag | Creates a text field of type “tel”. |
#text_area_tag | Alias for Helpers::FormTagHelper#textarea_tag. |
#text_field_tag | Creates a standard text field; use these text fields to input smaller chunks of text like a username or a search query. |
#textarea_tag | Creates a text input area; use a textarea for longer text inputs such as blog posts or descriptions. |
#time_field_tag | Creates a text field of type “time”. |
#url_field_tag | Creates a text field of type “url”. |
#utf8_enforcer_tag | Creates the hidden UTF-8 enforcer tag. |
#week_field_tag | Creates a text field of type “week”. |
#convert_direct_upload_option_to_url, #extra_tags_for_form, #form_tag_html, #form_tag_with_body, #html_options_for_form, | |
#sanitize_to_id | |
#set_default_disable_with |
Helpers::TextHelper
- Included
#concat | The preferred method of outputting text in your views is to use the |
#current_cycle | Returns the current cycle string after a cycle has been started. |
#cycle | Creates a Cycle object whose |
#excerpt | Extracts the first occurrence of |
#highlight | Highlights occurrences of |
#pluralize | Attempts to pluralize the |
#reset_cycle | Resets a cycle so that it starts from the first element the next time it is called. |
#safe_concat, | |
#simple_format | Returns |
#truncate | Truncates |
#word_wrap | Wraps the |
#cut_excerpt_part, | |
#get_cycle | The cycle helpers need to store the cycles in a place that is guaranteed to be reset every time a page is rendered, so it uses an instance variable of |
#set_cycle, #split_paragraphs |
Helpers::SanitizeHelper
- Included
#sanitize | Sanitizes HTML input, stripping all but known-safe tags and attributes. |
#sanitize_css | Sanitizes a block of CSS code. |
#strip_links | Strips all link tags from |
#strip_tags | Strips all HTML tags from |
Helpers::UrlHelper
- Included
#button_to | Generates a form containing a single button that submits to the URL created by the set of |
#current_page? | True if the current request URI was generated by the given |
#link_to | Creates an anchor element of the given |
#link_to_if | Creates a link tag of the given |
#link_to_unless | Creates a link tag of the given |
#link_to_unless_current | Creates a link tag of the given |
#mail_to | Creates a mailto link tag to the specified |
#phone_to | Creates a TEL anchor link tag to the specified |
#sms_to | Creates an SMS anchor link tag to the specified |
#add_method_to_attributes!, #convert_options_to_data_attributes, #link_to_remote_options?, #method_for_options, #method_not_get_method?, #method_tag, #remove_trailing_slash!, | |
#to_form_params | Returns an array of hashes each containing |
#token_tag, #url_target, | |
#url_for | Basic implementation of url_for to allow use helpers without routes existence. |
#_back_url, #_filtered_referrer |
Helpers::DebugHelper
- Included
#debug | Returns a YAML representation of |
Helpers::DateHelper
- Included
#date_select | Returns a set of select tags (one for year, month, and day) pre-selected for accessing a specified date-based attribute (identified by |
#datetime_select | Returns a set of select tags (one for year, month, day, hour, and minute) pre-selected for accessing a specified datetime-based attribute (identified by |
#distance_of_time_in_words | Reports the approximate distance in time between two |
#distance_of_time_in_words_to_now | Alias for Helpers::DateHelper#time_ago_in_words. |
#select_date | Returns a set of HTML select-tags (one for year, month, and day) pre-selected with the |
#select_datetime | Returns a set of HTML select-tags (one for year, month, day, hour, minute, and second) pre-selected with the |
#select_day | Returns a select tag with options for each of the days 1 through 31 with the current day selected. |
#select_hour | Returns a select tag with options for each of the hours 0 through 23 with the current hour selected. |
#select_minute | Returns a select tag with options for each of the minutes 0 through 59 with the current minute selected. |
#select_month | Returns a select tag with options for each of the months January through December with the current month selected. |
#select_second | Returns a select tag with options for each of the seconds 0 through 59 with the current second selected. |
#select_time | Returns a set of HTML select-tags (one for hour and minute). |
#select_year | Returns a select tag with options for each of the five years on each side of the current, which is selected. |
#time_ago_in_words | Like |
#time_select | Returns a set of select tags (one for hour, minute, and optionally second) pre-selected for accessing a specified time-based attribute (identified by |
#time_tag | Returns an HTML time tag for the given date or time. |
#normalize_distance_of_time_argument_to_time |
Helpers::CsrfHelper
- Included
#csrf_meta_tag | Alias for Helpers::CsrfHelper#csrf_meta_tags. |
#csrf_meta_tags | Returns meta tags “csrf-param” and “csrf-token” with the name of the cross-site request forgery protection parameter and token, respectively. |
Helpers::CspHelper
- Included
#csp_meta_tag | Returns a meta tag “csp-nonce” with the per-session nonce value for allowing inline <script> tags. |
Helpers::ControllerHelper
- Included
Helpers::ContentExfiltrationPreventionHelper
- Included
Helpers::CacheHelper
- Included
#cache | This helper exposes a method for caching fragments of a view rather than an entire action or page. |
#cache_fragment_name | This helper returns the name of a cache key for a given fragment cache call. |
#cache_if | Cache fragments of a view if |
#cache_unless | Cache fragments of a view unless |
#uncacheable! | Raises |
#fragment_for, #fragment_name_with_digest, #read_fragment_for, #write_fragment_for, #digest_path_from_template |
Helpers::AtomFeedHelper
- Included
#atom_feed | Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on |
Helpers::AssetTagHelper
- Included
#audio_tag | Returns an HTML audio tag for the |
#auto_discovery_link_tag | Returns a link tag that browsers and feed readers can use to auto-detect an RSS, Atom, or JSON feed. |
#favicon_link_tag | Returns a link tag for a favicon managed by the asset pipeline. |
#image_tag | Returns an HTML image tag for the |
#javascript_include_tag | Returns an HTML script tag for each of the |
#picture_tag | Returns an HTML picture tag for the |
#preload_link_tag | Returns a link tag that browsers can use to preload the |
#stylesheet_link_tag | Returns a stylesheet link tag for the sources specified as arguments. |
#video_tag | Returns an HTML video tag for the |
#check_for_image_tag_errors, #extract_dimensions, #multiple_sources_tag_builder, #resolve_asset_source, #resolve_link_as, #send_preload_links_header |
Helpers::TagHelper
- Included
#cdata_section | Returns a CDATA section with the given |
#class_names | Alias for Helpers::TagHelper#token_list. |
#content_tag | Returns an HTML block tag of type |
#escape_once | Returns an escaped version of |
#tag | Returns an HTML tag. |
#token_list | Returns a string of tokens built from |
#build_tag_values, #ensure_valid_html5_tag_name, #tag_builder |
Helpers::OutputSafetyHelper
- Included
#raw | This method outputs without escaping a string. |
#safe_join | This method returns an HTML safe string similar to what |
#to_sentence | Converts the array to a comma-separated sentence where the last element is joined by the connector word. |
Helpers::CaptureHelper
- Included
#capture | The capture method extracts part of a template as a string object. |
#content_for | Calling |
#content_for? |
|
#provide | The same as |
#with_output_buffer | Use an alternate output buffer for the duration of the block. |
Helpers::AssetUrlHelper
- Included
#asset_path | This is the entry point for all assets. |
#asset_url | Computes the full URL to an asset in the public directory. |
#audio_path | Computes the path to an audio asset in the public audios directory. |
#audio_url | Computes the full URL to an audio asset in the public audios directory. |
#compute_asset_extname | Compute extname to append to asset path. |
#compute_asset_host | Pick an asset host for this source. |
#compute_asset_path | Computes asset path to public directory. |
#font_path | Computes the path to a font asset. |
#font_url | Computes the full URL to a font asset. |
#image_path | Computes the path to an image asset. |
#image_url | Computes the full URL to an image asset. |
#javascript_path | Computes the path to a JavaScript asset in the public javascripts directory. |
#javascript_url | Computes the full URL to a JavaScript asset in the public javascripts directory. |
#path_to_asset | Alias for Helpers::AssetUrlHelper#asset_path. |
#path_to_audio | Alias for Helpers::AssetUrlHelper#audio_path. |
#path_to_font | Alias for Helpers::AssetUrlHelper#font_path. |
#path_to_image | Alias for Helpers::AssetUrlHelper#image_path. |
#path_to_javascript | Alias for Helpers::AssetUrlHelper#javascript_path. |
#path_to_stylesheet | Alias for Helpers::AssetUrlHelper#stylesheet_path. |
#path_to_video | Alias for Helpers::AssetUrlHelper#video_path. |
#public_compute_asset_path | Alias for Helpers::AssetUrlHelper#compute_asset_path. |
#stylesheet_path | Computes the path to a stylesheet asset in the public stylesheets directory. |
#stylesheet_url | Computes the full URL to a stylesheet asset in the public stylesheets directory. |
#url_to_asset | Alias for Helpers::AssetUrlHelper#asset_url. |
#url_to_audio | Alias for Helpers::AssetUrlHelper#audio_url. |
#url_to_font | Alias for Helpers::AssetUrlHelper#font_url. |
#url_to_image | Alias for Helpers::AssetUrlHelper#image_url. |
#url_to_javascript | Alias for Helpers::AssetUrlHelper#javascript_url. |
#url_to_stylesheet | Alias for Helpers::AssetUrlHelper#stylesheet_url. |
#url_to_video | Alias for Helpers::AssetUrlHelper#video_url. |
#video_path | Computes the path to a video asset in the public videos directory. |
#video_url | Computes the full URL to a video asset in the public videos directory. |
::ActiveSupport::Benchmarkable
- Included
#benchmark | Allows you to measure the execution time of a block in a template and records the result to the log. |
::AbstractController::Helpers
- Included
::ActionDispatch::Routing::PolymorphicRoutes
- Included
#polymorphic_path | Returns the path component of a URL for the given record. |
#polymorphic_url | Constructs a call to a named RESTful route for the given record and returns the resulting URL string. |
#polymorphic_mapping, #polymorphic_path_for_action, #polymorphic_url_for_action |
Context
- Included
#_layout_for | Encapsulates the interaction with the view flow so it returns the correct buffer on |
#_prepare_context | Prepares the context by setting the appropriate instance variables. |
::ActionController::TemplateAssertions
- Included
::ActionDispatch::Assertions
- Included
::ActionDispatch::Assertions::RoutingAssertions
- Included
#assert_generates | Asserts that the provided options can be used to generate the provided path. |
#assert_recognizes | Asserts that the routing of the given |
#assert_routing | Asserts that path and options match both ways; in other words, it verifies that |
#method_missing | ROUTES TODO: These assertions should really work in an integration context. |
#with_routing | A helper to make it easier to test different route configurations. |
#create_routes, #fail_on, | |
#recognized_request_for | Recognizes the route for a given path. |
#reset_routes, #setup |
::ActionDispatch::Assertions::ResponseAssertions
- Included
#assert_redirected_to | Asserts that the response is a redirect to a URL matching the given options. |
#assert_response | Asserts that the response is one of the following types: |
#code_with_name, #exception_if_present, #generate_response_message, #location_if_redirected, #normalize_argument_to_redirection, | |
#parameterize | Proxy to to_param if the object will respond to it. |
#response_body_if_short |
::ActionDispatch::TestProcess
- Included
::ActionDispatch::TestProcess::FixtureFile
- Included
#file_fixture_upload | Shortcut for ‘Rack::Test::UploadedFile.new(File.join(ActionDispatch::IntegrationTest.file_f ixture_path, path), type)`: |
#fixture_file_upload |
::ActiveSupport::TestCase
- Inherited
#assert_no_match | Alias for: refute_match. |
#assert_not_empty | Alias for: refute_empty. |
#assert_not_equal | Alias for: refute_equal. |
#assert_not_in_delta | Alias for: refute_in_delta. |
#assert_not_in_epsilon | Alias for: refute_in_epsilon. |
#assert_not_includes | Alias for: refute_includes. |
#assert_not_instance_of | Alias for: refute_instance_of. |
#assert_not_kind_of | Alias for: refute_kind_of. |
#assert_not_nil | Alias for: refute_nil. |
#assert_not_operator | Alias for: refute_operator. |
#assert_not_predicate | Alias for: refute_predicate. |
#assert_not_respond_to | Alias for: refute_respond_to. |
#assert_not_same | Alias for: refute_same. |
#method_name, #inspect |
::ActiveSupport::Testing::FileFixtures
- Included
#file_fixture | Returns a |
::ActiveSupport::Testing::TimeHelpers
- Included
#after_teardown, | |
#freeze_time | Calls |
#travel | Changes current time to the time in the future or in the past by a given time difference by stubbing |
#travel_back | Returns the current time back to its original state, by removing the stubs added by |
#travel_to | Changes current time to the given time by stubbing |
#unfreeze_time | |
#simple_stubs |
::ActiveSupport::Testing::ConstantStubbing
- Included
#stub_const | Changes the value of a constant for the duration of a block. |
::ActiveSupport::Testing::Deprecation
- Included
#assert_deprecated | Asserts that a matching deprecation warning was emitted by the given deprecator during the execution of the yielded block. |
#assert_not_deprecated | Asserts that no deprecation warnings are emitted by the given deprecator during the execution of the yielded block. |
#collect_deprecations | Returns the return value of the block and an array of all the deprecation warnings emitted by the given deprecator during the execution of the yielded block. |
::ActiveSupport::Testing::ErrorReporterAssertions
- Included
#assert_error_reported | Assertion that the block should cause at least one exception to be reported to Rails.error. |
#assert_no_error_reported | Assertion that the block should not cause an exception to be reported to Rails.error. |
::ActiveSupport::Testing::Assertions
- Included
#assert_changes | Assertion that the result of evaluating an expression is changed before and after invoking the passed in block. |
#assert_difference | Test numeric difference between the return value of an expression as a result of what is evaluated in the yielded block. |
#assert_no_changes | Assertion that the result of evaluating an expression is not changed before and after invoking the passed in block. |
#assert_no_difference | Assertion that the numeric result of evaluating an expression is not changed before and after invoking the passed in block. |
#assert_not | Asserts that an expression is not truthy. |
#assert_nothing_raised | Assertion that the block should not raise an exception. |
#assert_raise | |
#assert_raises | Asserts that a block raises one of |
#_assert_nothing_raised_or_warn, #_callable_to_source_string |
::ActiveSupport::Testing::TestsWithoutAssertions
- Included
::ActiveSupport::Testing::SetupAndTeardown
- Included
::ActiveSupport::Testing::TaggedLogging
- Included
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActionView::TestCase::Behavior
Class Attribute Details
.content_class (rw)
[ GitHub ]# File 'actionview/lib/action_view/test_case.rb', line 200
class_attribute :content_class, instance_accessor: false, default: RenderedViewContent
.content_class? ⇒ Boolean
(rw)
[ GitHub ]
# File 'actionview/lib/action_view/test_case.rb', line 200
class_attribute :content_class, instance_accessor: false, default: RenderedViewContent