Module: ActionView::TestCase::Behavior

Defined Under Namespace

Modules: ClassMethods, Locals Classes: RenderedViewsCollection

Constant Summary

Constants included from RecordIdentifier

RecordIdentifier::JOIN, RecordIdentifier::NEW

Constants included from Helpers::UrlHelper

Helpers::UrlHelper::BUTTON_TAG_METHOD_VERBS

Constants included from Helpers::ContentExfiltrationPreventionHelper

Helpers::ContentExfiltrationPreventionHelper::CLOSE_CDATA_COMMENT, Helpers::ContentExfiltrationPreventionHelper::CLOSE_FORM_TAG, Helpers::ContentExfiltrationPreventionHelper::CLOSE_OPTION_TAG, Helpers::ContentExfiltrationPreventionHelper::CLOSE_QUOTES_COMMENT, Helpers::ContentExfiltrationPreventionHelper::CONTENT_EXFILTRATION_PREVENTION_MARKUP

Constants included from Helpers::TagHelper

Helpers::TagHelper::ARIA_PREFIXES, Helpers::TagHelper::BOOLEAN_ATTRIBUTES, Helpers::TagHelper::DATA_PREFIXES, Helpers::TagHelper::PRE_CONTENT_STRINGS, Helpers::TagHelper::TAG_TYPES

Constants included from Helpers::JavaScriptHelper

Helpers::JavaScriptHelper::JS_ESCAPE_MAP

Constants included from Helpers::DateHelper

Helpers::DateHelper::MINUTES_IN_QUARTER_YEAR, Helpers::DateHelper::MINUTES_IN_THREE_QUARTERS_YEAR, Helpers::DateHelper::MINUTES_IN_YEAR

Constants included from Helpers::ControllerHelper

Helpers::ControllerHelper::CONTROLLER_DELEGATES

Constants included from Helpers::AssetUrlHelper

Helpers::AssetUrlHelper::ASSET_EXTENSIONS, Helpers::AssetUrlHelper::ASSET_PUBLIC_DIRECTORIES, Helpers::AssetUrlHelper::URI_REGEXP

Constants included from ActionDispatch::Assertions::ResponseAssertions

ActionDispatch::Assertions::ResponseAssertions::RESPONSE_PREDICATES

Instance Attribute Summary collapse

Attributes included from Helpers::TranslationHelper

#raise_on_missing_translations

Attributes included from Context

#view_flow

Instance Method Summary collapse

Methods included from ActiveSupport::Concern

append_features, class_methods, extended, included, prepend_features, prepended

Methods included from RoutingUrlFor

#url_for, #url_options

Methods included from RecordIdentifier

#dom_class, #dom_id

Methods included from ModelNaming

#convert_to_model, #model_name_from_record_or_class

Methods included from Helpers

eager_load!

Methods included from ActiveSupport::Autoload

#autoload, #autoload_at, #autoload_under, #eager_autoload, #eager_load!, extended

Methods included from Helpers::UrlHelper

#button_to, #current_page?, #link_to, #link_to_if, #link_to_unless, #link_to_unless_current, #mail_to, #phone_to, #sms_to, #url_for

Methods included from Helpers::ContentExfiltrationPreventionHelper

#prevent_content_exfiltration

Methods included from Helpers::TagHelper

build_tag_values, #cdata_section, #content_tag, #escape_once, #tag, #token_list

Methods included from Helpers::OutputSafetyHelper

#raw, #safe_join, #to_sentence

Methods included from Helpers::CaptureHelper

#capture, #content_for, #content_for?, #provide, #with_output_buffer

Methods included from Helpers::TranslationHelper

#localize, #translate

Methods included from Helpers::TextHelper

#concat, #current_cycle, #cycle, #excerpt, #highlight, #pluralize, #reset_cycle, #safe_concat, #simple_format, #truncate, #word_wrap

Methods included from Helpers::SanitizeHelper

#sanitize, #sanitize_css, #strip_links, #strip_tags

Methods included from Helpers::RenderingHelper

#_layout_for

Methods included from Helpers::NumberHelper

#number_to_currency, #number_to_human, #number_to_human_size, #number_to_percentage, #number_to_phone, #number_with_delimiter, #number_with_precision

Methods included from Helpers::JavaScriptHelper

#escape_javascript, #javascript_cdata_section, #javascript_tag

Methods included from Helpers::FormTagHelper

#button_tag, #check_box_tag, #color_field_tag, #date_field_tag, #datetime_field_tag, #email_field_tag, #field_id, #field_name, #field_set_tag, #file_field_tag, #form_tag, #hidden_field_tag, #image_submit_tag, #label_tag, #month_field_tag, #number_field_tag, #password_field_tag, #radio_button_tag, #range_field_tag, #search_field_tag, #select_tag, #submit_tag, #telephone_field_tag, #text_area_tag, #text_field_tag, #time_field_tag, #url_field_tag, #utf8_enforcer_tag, #week_field_tag

Methods included from Helpers::FormOptionsHelper

#collection_check_boxes, #collection_radio_buttons, #collection_select, #grouped_collection_select, #grouped_options_for_select, #option_groups_from_collection_for_select, #options_for_select, #options_from_collection_for_select, #select, #time_zone_options_for_select, #time_zone_select, #weekday_options_for_select, #weekday_select

Methods included from Helpers::FormHelper

#_object_for_form_builder, #check_box, #color_field, #date_field, #datetime_field, #email_field, #fields, #fields_for, #file_field, #form_for, #form_with, #hidden_field, #label, #month_field, #number_field, #password_field, #radio_button, #range_field, #rich_text_area, #search_field, #telephone_field, #text_area, #text_field, #time_field, #url_field, #week_field

Methods included from Helpers::DebugHelper

#debug

Methods included from Helpers::DateHelper

#date_select, #datetime_select, #distance_of_time_in_words, #select_date, #select_datetime, #select_day, #select_hour, #select_minute, #select_month, #select_second, #select_time, #select_year, #time_ago_in_words, #time_select, #time_tag

Methods included from Helpers::CsrfHelper

#csrf_meta_tags

Methods included from Helpers::CspHelper

#csp_meta_tag

Methods included from Helpers::ControllerHelper

#assign_controller, #logger, #respond_to?

Methods included from Helpers::CacheHelper

#cache, #cache_fragment_name, #cache_if, #cache_unless, #caching?, #digest_path_from_template, #uncacheable!

Methods included from Helpers::AtomFeedHelper

#atom_feed

Methods included from Helpers::AssetUrlHelper

#asset_path, #asset_url, #audio_path, #audio_url, #compute_asset_extname, #compute_asset_host, #compute_asset_path, #font_path, #font_url, #image_path, #image_url, #javascript_path, #javascript_url, #stylesheet_path, #stylesheet_url, #video_path, #video_url

Methods included from Helpers::AssetTagHelper

#audio_tag, #auto_discovery_link_tag, #favicon_link_tag, #image_tag, #javascript_include_tag, #preload_link_tag, #stylesheet_link_tag, #video_tag

Methods included from ActiveSupport::Benchmarkable

#benchmark

Methods included from AbstractController::Helpers

#_helpers

Methods included from AbstractController::Helpers::Resolution

#all_helpers_from_path, #helper_modules_from_paths, #modules_for_helpers

Methods included from ActiveSupport::Deprecation::DeprecatedConstantAccessor

included

Methods included from ActionDispatch::Routing::PolymorphicRoutes

#polymorphic_path, #polymorphic_url

Methods included from Context

#_layout_for, #_prepare_context

Methods included from ActionController::TemplateAssertions

#assert_template

Methods included from ActionDispatch::Assertions

#html_document

Methods included from ActionDispatch::Assertions::RoutingAssertions

#assert_generates, #assert_recognizes, #assert_routing, #setup, #with_routing

Methods included from ActionDispatch::Assertions::ResponseAssertions

#assert_redirected_to, #assert_response

Methods included from ActionDispatch::TestProcess

#assigns, #cookies, #flash, #redirect_to_url, #session

Methods included from ActionDispatch::TestProcess::FixtureFile

#fixture_file_upload

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(selector, *args) ⇒ Object (private)



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'actionview/lib/action_view/test_case.rb', line 267

def method_missing(selector, *args)
  begin
    routes = @controller.respond_to?(:_routes) && @controller._routes
  rescue
    # Don't call routes, if there is an error on _routes call
  end

  if routes &&
     (routes.named_routes.route_defined?(selector) ||
       routes.mounted_helpers.method_defined?(selector))
    @controller.__send__(selector, *args)
  else
    super
  end
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller



60
61
62
# File 'actionview/lib/action_view/test_case.rb', line 60

def controller
  @controller
end

#output_bufferObject

Returns the value of attribute output_buffer



60
61
62
# File 'actionview/lib/action_view/test_case.rb', line 60

def output_buffer
  @output_buffer
end

#renderedObject

Returns the value of attribute rendered



60
61
62
# File 'actionview/lib/action_view/test_case.rb', line 60

def rendered
  @rendered
end

#requestObject

Returns the value of attribute request



60
61
62
# File 'actionview/lib/action_view/test_case.rb', line 60

def request
  @request
end

Instance Method Details

#_routesObject



134
135
136
# File 'actionview/lib/action_view/test_case.rb', line 134

def _routes
  @controller._routes if @controller.respond_to?(:_routes)
end

#configObject



120
121
122
# File 'actionview/lib/action_view/test_case.rb', line 120

def config
  @controller.config if @controller.respond_to?(:config)
end

#render(options = {}, local_assigns = {}, &block) ⇒ Object



124
125
126
127
128
# File 'actionview/lib/action_view/test_case.rb', line 124

def render(options = {}, local_assigns = {}, &block)
  view.assign(view_assigns)
  @rendered << output = view.render(options, local_assigns, &block)
  output
end

#rendered_viewsObject



130
131
132
# File 'actionview/lib/action_view/test_case.rb', line 130

def rendered_views
  @_rendered_views ||= RenderedViewsCollection.new
end

#setup_with_controllerObject



108
109
110
111
112
113
114
115
116
117
118
# File 'actionview/lib/action_view/test_case.rb', line 108

def setup_with_controller
  controller_class = Class.new(ActionView::TestCase::TestController)
  @controller = controller_class.new
  @request = @controller.request
  @view_flow = ActionView::OutputFlow.new
  @output_buffer = ActionView::OutputBuffer.new
  @rendered = +""

  test_case_instance = self
  controller_class.define_method(:_test_case) { test_case_instance }
end