Class: ActionView::TestCase

Inherits:
ActiveSupport::TestCase
  • Object
show all
Includes:
ActionController::PolymorphicRoutes, ActionController::RecordIdentifier, Helpers
Defined in:
lib/action_view/test_case.rb

Defined Under Namespace

Classes: TestController

Constant Summary collapse

@@helper_class =
nil

Constants included from ActionController::RecordIdentifier

ActionController::RecordIdentifier::JOIN, ActionController::RecordIdentifier::NEW

Constants included from Helpers::JavaScriptHelper

Helpers::JavaScriptHelper::JAVASCRIPT_PATH, Helpers::JavaScriptHelper::JS_ESCAPE_MAP

Constants included from Helpers::PrototypeHelper

Helpers::PrototypeHelper::AJAX_OPTIONS, Helpers::PrototypeHelper::CALLBACKS

Constants included from Helpers::TextHelper

Helpers::TextHelper::AUTO_LINK_RE

Constants included from Helpers::TagHelper

Helpers::TagHelper::BOOLEAN_ATTRIBUTES

Constants included from ERB::Util

ERB::Util::HTML_ESCAPE, ERB::Util::JSON_ESCAPE

Constants included from Helpers::ScriptaculousHelper

Helpers::ScriptaculousHelper::TOGGLE_EFFECTS

Constants included from Helpers::AssetTagHelper

Helpers::AssetTagHelper::ASSETS_DIR, Helpers::AssetTagHelper::JAVASCRIPTS_DIR, Helpers::AssetTagHelper::JAVASCRIPT_DEFAULT_SOURCES, Helpers::AssetTagHelper::STYLESHEETS_DIR

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActionController::RecordIdentifier

#dom_class, #dom_id, #partial_path, #plural_class_name, #singular_class_name

Methods included from ActionController::PolymorphicRoutes

#polymorphic_path, #polymorphic_url

Methods included from Helpers

included

Methods included from Helpers::UrlHelper

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

Methods included from Helpers::JavaScriptHelper

#button_to_function, #escape_javascript, #javascript_cdata_section, #javascript_tag, #link_to_function

Methods included from Helpers::PrototypeHelper

#button_to_remote, #evaluate_remote_response, #form_remote_tag, #link_to_remote, #observe_field, #observe_form, #periodically_call_remote, #remote_form_for, #remote_function, #submit_to_remote, #update_page, #update_page_tag

Methods included from Helpers::TranslationHelper

#localize, #translate

Methods included from Helpers::TextHelper

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

Methods included from Helpers::TagHelper

#cdata_section, #content_tag, #escape_once, #tag

Methods included from ERB::Util

#html_escape, j, json_escape

Methods included from Helpers::ScriptaculousHelper

#draggable_element, #draggable_element_js, #drop_receiving_element, #drop_receiving_element_js, #sortable_element, #sortable_element_js, #visual_effect

Methods included from Helpers::SanitizeHelper

#sanitize, #sanitize_css, #strip_links, #strip_tags

Methods included from Helpers::RecordTagHelper

#content_tag_for, #div_for

Methods included from Helpers::RecordIdentificationHelper

#dom_class, #dom_id, #partial_path

Methods included from Helpers::NumberHelper

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

Methods included from Helpers::FormTagHelper

#check_box_tag, #field_set_tag, #file_field_tag, #form_tag, #hidden_field_tag, #image_submit_tag, #label_tag, #password_field_tag, #radio_button_tag, #select_tag, #submit_tag, #text_area_tag, #text_field_tag

Methods included from Helpers::FormOptionsHelper

#collection_select, #option_groups_from_collection_for_select, #options_for_select, #options_from_collection_for_select, #select, #time_zone_options_for_select, #time_zone_select

Methods included from Helpers::FormHelper

#apply_form_for_options!, #check_box, #fields_for, #file_field, #form_for, #hidden_field, #label, #password_field, #radio_button, #text_area, #text_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

Methods included from Helpers::CaptureHelper

#capture, #content_for, #with_output_buffer

Methods included from Helpers::CacheHelper

#cache

Methods included from Helpers::BenchmarkHelper

#benchmark

Methods included from Helpers::AtomFeedHelper

#atom_feed

Methods included from Helpers::AssetTagHelper

#auto_discovery_link_tag, cache_asset_timestamps, cache_asset_timestamps=, #image_path, #image_tag, #javascript_include_tag, #javascript_path, register_javascript_expansion, register_javascript_include_default, register_stylesheet_expansion, reset_javascript_include_default, #stylesheet_link_tag, #stylesheet_path

Methods included from Helpers::ActiveRecordHelper

#error_message_on, #error_messages_for, #form, #input

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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


55
56
57
58
59
# File 'lib/action_view/test_case.rb', line 55

def method_missing(selector, *args)
  controller = TestController.new
  return controller.__send__(selector, *args) if ActionController::Routing::Routes.named_routes.helpers.include?(selector)
  super
end

Class Method Details

.determine_default_helper_class(name) ⇒ Object


21
22
23
24
25
# File 'lib/action_view/test_case.rb', line 21

def determine_default_helper_class(name)
  name.sub(/Test$/, '').constantize
rescue NameError
  nil
end

.helper_classObject


13
14
15
16
17
18
19
# File 'lib/action_view/test_case.rb', line 13

def helper_class
  if current_helper_class = read_inheritable_attribute(:helper_class)
    current_helper_class
  else
    self.helper_class = determine_default_helper_class(name)
  end
end

.tests(helper_class) ⇒ Object


9
10
11
# File 'lib/action_view/test_case.rb', line 9

def tests(helper_class)
  self.helper_class = helper_class
end

Instance Method Details

#setup_with_helper_classObject


34
35
36
37
38
39
40
# File 'lib/action_view/test_case.rb', line 34

def setup_with_helper_class
  if helper_class && !self.class.ancestors.include?(helper_class)
    self.class.send(:include, helper_class)
  end

  self.output_buffer = ''
end