123456789_123456789_123456789_123456789_123456789_

Class: ActionView::TestCase

Relationships & Source Files
Namespace Children
Modules:
Classes:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActiveSupport::TestCase
Defined in: actionview/lib/action_view/test_case.rb

Constant Summary

::ActiveSupport::Callbacks - Inherited

CALLBACK_FILTER_TYPES

::ActiveSupport::TestCase - Inherited

Assertion

::ActionController::TemplateAssertions - Included

RENDER_TEMPLATE_INSTANCE_VARIABLES

Helpers::AssetUrlHelper - Included

ASSET_EXTENSIONS, ASSET_PUBLIC_DIRECTORIES, URI_REGEXP

Helpers::TagHelper - Included

BOOLEAN_ATTRIBUTES, PRE_CONTENT_STRINGS, TAG_PREFIXES

Helpers::DateHelper - Included

MINUTES_IN_QUARTER_YEAR, MINUTES_IN_THREE_QUARTERS_YEAR, MINUTES_IN_YEAR

Helpers::UrlHelper - Included

BUTTON_TAG_METHOD_VERBS

Helpers::JavaScriptHelper - Included

JS_ESCAPE_MAP

RecordIdentifier - Included

JOIN, NEW

Behavior - Included

INTERNAL_IVARS

Class Attribute Summary

Class Method Summary

::ActiveSupport::TestCase - Inherited

::ActiveSupport::DescendantsTracker - Inherited

clear, descendants, direct_descendants,
store_inherited

This is the only method that is not thread safe, but is only ever called during the eager loading phase.

::ActiveSupport::Testing::Declarative - Extended

test

Helper to define a test method using a ::String.

Instance Attribute Summary

Instance Method Summary

Behavior - Included

#_routes, #_user_defined_ivars,
#_view

Alias for Behavior#view.

#config, #method_missing, #render, #rendered_views, #setup_with_controller,
#view

The instance of Base that is used by render.

#view_assigns

Returns a ::Hash of instance variables and their values, as defined by the user in the test case, which are then assigned to the view being rendered.

RoutingUrlFor - Included

#url_for

Returns the URL for the set of options provided.

Helpers::TranslationHelper - Included

#l
#localize

Delegates to I18n.localize with no additional functionality.

#t
#translate

Delegates to I18n#translate but also performs three additional functions.

Helpers::RenderingHelper - Included

#_layout_for

Overwrites _layout_for in the context object so it supports the case a block is passed to a partial.

#render

Returns the result of a render that's dictated by the options hash.

Helpers::RecordTagHelper - Included

#content_tag_for

content_tag_for creates an HTML element with id and class parameters that relate to the specified Active Record object.

#div_for

Produces a wrapper DIV element with id and class parameters that relate to the specified Active Record object.

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.

Helpers::NumberHelper - Included

#number_to_currency

Formats a number into a currency string (e.g., $13.65).

#number_to_human

Pretty prints (formats and approximates) a number in a way it is more readable by humans (eg.: 1200000000 becomes “1.2 Billion”).

#number_to_human_size

Formats the bytes in number into a more understandable representation (e.g., giving it 1500 yields 1.5 KB).

#number_to_percentage

Formats a number as a percentage string (e.g., 65%).

#number_to_phone

Formats a number into a US phone number (e.g., (555) 123-9876).

#number_with_delimiter

Formats a number with grouped thousands using delimiter (e.g., 12,324).

#number_with_precision

Formats a number with the specified level of :precision (e.g., 112.32 has a precision of 2 if :significant is false, and 5 if :significant is true).

Helpers::JavaScriptHelper - Included

#escape_javascript

Escapes carriage returns and single and double quotes for JavaScript segments.

#j
#javascript_tag

Returns a JavaScript tag with the content inside.

Helpers::FormOptionsHelper - Included

#collection_check_boxes

Returns check box tags for the collection of existing return values of method for object's class.

#collection_radio_buttons

Returns radio button tags for the collection of existing return values of method for object's class.

#collection_select

Returns <select> and <option> tags for the collection of existing return values of method for object's class.

#grouped_collection_select

Returns <select>, <optgroup> and <option> tags for the collection of existing return values of method for object's class.

#grouped_options_for_select

Returns a string of <option> tags, like options_for_select, but wraps them with <optgroup> tags:

#option_groups_from_collection_for_select

Returns a string of <option> tags, like options_from_collection_for_select, but groups them by <optgroup> tags based on the object relationships of the arguments.

#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 collection and assigning the result of a call to the value_method as the option value and the text_method as the option text.

#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 #time_zone_options_for_select to generate the list of option tags.

Helpers::FormHelper - Included

#check_box

Returns a checkbox tag tailored for accessing a specified attribute (identified by method) on an object assigned to the template (identified by object).

#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”.

#datetime_local_field

Returns a text_field of type “datetime-local”.

#email_field

Returns a text_field of type “email”.

#fields_for

Creates a scope around a specific model object like form_for, but doesn't create the form tags themselves.

#file_field

Returns a file upload input tag tailored for accessing a specified attribute (identified by method) on an object assigned to the template (identified by object).

#form_for

Creates a form that allows the user to create or update the attributes of a specific model object.

#hidden_field

Returns a hidden input tag tailored for accessing a specified attribute (identified by method) on an object assigned to the template (identified by object).

#label

Returns a label tag tailored for labelling an input field for a specified attribute (identified by method) on an object assigned to the template (identified by object).

#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 method) on an object assigned to the template (identified by object).

#phone_field
#radio_button

Returns a radio button tag for accessing a specified attribute (identified by method) on an object assigned to the template (identified by object).

#range_field

Returns an input tag of type “range”.

#search_field

Returns an input of type “search” for accessing a specified attribute (identified by method) on an object assigned to the template (identified by object_name).

#telephone_field

Returns a text_field of type “tel”.

#text_area

Returns a textarea opening and closing tag set tailored for accessing a specified attribute (identified by method) on an object assigned to the template (identified by object).

#text_field

Returns an input tag of the “text” type tailored for accessing a specified attribute (identified by method) on an object assigned to the template (identified by object).

#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”.

ModelNaming - Included

#convert_to_model

Converts the given object to an ::ActiveModel compliant one.

#model_name_from_record_or_class

Helpers::FormTagHelper - Included

#button_tag

Creates a button element that defines a submit button, resetbutton or a generic button which can be used in JavaScript, for example.

#check_box_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”.

#datetime_local_field_tag

Creates a text field of type “datetime-local”.

#email_field_tag

Creates a text field of type “email”.

#field_set_tag

Creates a field set for grouping HTML form elements.

#file_field_tag

Creates a file upload field.

#form_tag

Starts a form tag that points the action to an url configured with url_for_options just like ActionController::Base#url_for.

#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
#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 :multiple option is set to true, a multiple choice selection box.

#submit_tag

Creates a submit button with the text value as the caption.

#telephone_field_tag

Creates a text field of type “tel”.

#text_area_tag

Creates a text input area; use a textarea for longer text inputs such as blog posts or descriptions.

#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.

#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 UTF8 enforcer tag.

#week_field_tag

Creates a text field of type “week”.

Helpers::TextHelper - Included

#concat

The preferred method of outputting text in your views is to use the <%= “text” %> eRuby syntax.

#current_cycle

Returns the current cycle string after a cycle has been started.

#cycle

Creates a Cycle object whose to_s method cycles through elements of an array every time it is called.

#excerpt

Extracts an excerpt from text that matches the first instance of phrase.

#highlight

Highlights one or more phrases everywhere in text by inserting it into a :highlighter string.

#pluralize

Attempts to pluralize the singular word unless count is 1.

#reset_cycle

Resets a cycle so that it starts from the first element the next time it is called.

#safe_concat,
#simple_format

Returns text transformed into HTML using simple formatting rules.

#truncate

Truncates a given text after a given :length if text is longer than :length (defaults to 30).

#word_wrap

Wraps the text into lines no longer than line_width width.

Helpers::SanitizeHelper - Included

#sanitize

Sanitizes HTML input, stripping all tags and attributes that aren't whitelisted.

#sanitize_css

Sanitizes a block of CSS code.

#strip_links

Strips all link tags from html leaving just the link text.

#strip_tags

Strips all HTML tags from html, including comments.

Helpers::UrlHelper - Included

#button_to

Generates a form containing a single button that submits to the URL created by the set of options.

#current_page?

True if the current request ::URI was generated by the given options.

#link_to

Creates a link tag of the given name using a URL created by the set of options.

#link_to_if

Creates a link tag of the given name using a URL created by the set of options if condition is true, otherwise only the name is returned.

#link_to_unless

Creates a link tag of the given name using a URL created by the set of options unless condition is true, in which case only the name is returned.

#link_to_unless_current

Creates a link tag of the given name using a URL created by the set of options unless the current request ::URI is the same as the links, in which case only the name is returned (or the given block is yielded, if one exists).

#mail_to

Creates a mailto link tag to the specified email_address, which is also used as the name of the link unless name is specified.

Helpers::DebugHelper - Included

#debug

Returns a YAML representation of object wrapped with <pre> and </pre>.

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 method) on an object assigned to the template (identified by object).

#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 method) on an object assigned to the template (identified by object).

#distance_of_time_in_words

Reports the approximate distance in time between two ::Time, ::Date or ::DateTime objects or integers as seconds.

#distance_of_time_in_words_to_now
#select_date

Returns a set of HTML select-tags (one for year, month, and day) pre-selected with the date.

#select_datetime

Returns a set of HTML select-tags (one for year, month, day, hour, minute, and second) pre-selected with the datetime.

#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 distance_of_time_in_words, but where to_time is fixed to Time.now.

#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 method) on an object assigned to the template (identified by object).

#time_tag

Returns an HTML time tag for the given date or time.

Helpers::CsrfHelper - Included

#csrf_meta_tag
#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::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 condition is true.

#cache_unless

Cache fragments of a view unless condition is true.

Helpers::AtomFeedHelper - Included

#atom_feed

Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on ::ERB or any other template languages).

Helpers::AssetTagHelper - Included

#audio_tag

Returns an HTML audio tag for the source.

#auto_discovery_link_tag

Returns a link tag that browsers and feed readers can use to auto-detect an RSS or Atom feed.

#favicon_link_tag

Returns a link tag for a favicon managed by the asset pipeline.

#image_alt

Returns a string suitable for an HTML image tag alt attribute.

#image_tag

Returns an HTML image tag for the source.

#javascript_include_tag

Returns an HTML script tag for each of the sources provided.

#stylesheet_link_tag

Returns a stylesheet link tag for the sources specified as arguments.

#video_tag

Returns an HTML video tag for the sources.

Helpers::TagHelper - Included

#cdata_section

Returns a CDATA section with the given content.

#content_tag

Returns an HTML block tag of type name surrounding the content.

#escape_once

Returns an escaped version of html without affecting existing escaped entities.

#tag

Returns an empty HTML tag of type name which by default is XHTML compliant.

Helpers::CaptureHelper - Included

#capture

The capture method allows you to extract part of a template into a variable.

#content_for

Calling content_for stores a block of markup in an identifier for later use.

#content_for?

content_for? checks whether any content has been captured yet using content_for.

#provide

The same as content_for but when used with streaming flushes straight back to the layout.

Helpers::AssetUrlHelper - Included

#asset_path

Computes the path to asset in public directory.

#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
#path_to_audio
#path_to_font
#path_to_image
#path_to_javascript
#path_to_stylesheet
#path_to_video
#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
#url_to_audio
#url_to_font
#url_to_image
#url_to_javascript
#url_to_stylesheet
#url_to_video
#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.

::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.

::ActionController::ModelNaming - Included

#convert_to_model

Converts the given object to an ::ActiveModel compliant one.

#model_name_from_record_or_class

Context - Included

#_layout_for

Encapsulates the interaction with the view flow so it returns the correct buffer on yield.

#_prepare_context

Prepares the context by setting the appropriate instance variables.

::ActionController::TemplateAssertions - Included

#assert_template

Asserts that the request was rendered with the appropriate template file or partials.

#process, #reset_template_assertion, #setup_subscriptions, #teardown_subscriptions

::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 path was handled correctly and that the parsed options (given in the expected_options hash) match path.

#assert_routing

Asserts that path and options match both ways; in other words, it verifies that path generates options and then that options generates path.

#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.

::ActionDispatch::Assertions::ResponseAssertions - Included

#assert_redirected_to

Assert that the redirection options passed in match those of the redirect called in the latest action.

#assert_response

Asserts that the response is one of the following types:

::ActionDispatch::TestProcess - Included

#assigns, #cookies,
#fixture_file_upload

Shortcut for Rack::Test::UploadedFile.new(File.join(ActionController::TestCase.fixture_path, path), type):

#flash, #redirect_to_url, #session

::ActiveSupport::TestCase - Inherited

::ActiveRecord::TestFixtures - Included

::ActiveSupport::Testing::TimeHelpers - Included

#travel

Changes current time to the time in the future or in the past by a given time difference by stubbing Time.now, Date.today, and DateTime.now.

#travel_back

Returns the current time back to its original state, by removing the stubs added by travel and travel_to.

#travel_to

Changes current time to the given time by stubbing Time.now, Date.today, and DateTime.now to return the time or date passed into this method.

::ActiveSupport::Testing::Assertions - Included

#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_difference

Assertion that the numeric result of evaluating an expression is not changed before and after invoking the passed in block.

#assert_not

Assert that an expression is not truthy.

::ActiveSupport::Callbacks - Inherited

#run_callbacks

Runs the callbacks for the given event.

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActionView::TestCase::Behavior