Class: ActionView::TestCase

Inherits:
ActiveSupport::TestCase
  • Object
show all
Includes:
ActionController::PolymorphicRoutes, ActionController::RecordIdentifier, ActionController::TestCase::Assertions, ActionController::TestProcess, 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::NumberHelper

Helpers::NumberHelper::STORAGE_UNITS

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

#formatted_polymorphic_path, #formatted_polymorphic_url, #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, #markdown, #pluralize, #reset_cycle, #simple_format, #textilize, #textilize_without_paragraph, #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, #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

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

Methods included from ActionController::TestProcess

#assigns, #build_request_uri, #cookies, #delete, #find_all_tag, #find_tag, #fixture_file_upload, #flash, #get, #head, #html_document, included, #post, #process, #put, #redirect_to_url, #session, #with_routing, #xml_http_request

Methods included from ActionController::TestCase::Assertions

#clean_backtrace

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



81
82
83
84
85
# File 'lib/action_view/test_case.rb', line 81

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



44
45
46
47
48
# File 'lib/action_view/test_case.rb', line 44

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

.helper_classObject



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

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



32
33
34
# File 'lib/action_view/test_case.rb', line 32

def tests(helper_class)
  self.helper_class = helper_class
end

Instance Method Details

#setup_with_helper_classObject



57
58
59
60
61
62
63
# File 'lib/action_view/test_case.rb', line 57

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