Class: ActionView::TestCase

Inherits:
ActiveSupport::TestCase
  • Object
show all
Includes:
ActionController::Helpers, 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

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

Helpers::TagHelper::BOOLEAN_ATTRIBUTES

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

Constants included from ActionController::RecordIdentifier

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActionController::Helpers

included

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

#raw

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

#csrf_meta_tag

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



154
155
156
157
158
159
160
# File 'lib/action_view/test_case.rb', line 154

def method_missing(selector, *args)
  if ActionController::Routing::Routes.named_routes.helpers.include?(selector)
    @controller.__send__(selector, *args)
  else
    super
  end
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



51
52
53
# File 'lib/action_view/test_case.rb', line 51

def controller
  @controller
end

#output_bufferObject

Returns the value of attribute output_buffer.



51
52
53
# File 'lib/action_view/test_case.rb', line 51

def output_buffer
  @output_buffer
end

#renderedObject

Returns the value of attribute rendered.



51
52
53
# File 'lib/action_view/test_case.rb', line 51

def rendered
  @rendered
end

Class Method Details

.determine_default_helper_class(name) ⇒ Object



85
86
87
88
89
# File 'lib/action_view/test_case.rb', line 85

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

.helper_classObject



77
78
79
80
81
82
83
# File 'lib/action_view/test_case.rb', line 77

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

.helper_method(*methods) ⇒ Object



91
92
93
94
95
96
97
98
99
100
# File 'lib/action_view/test_case.rb', line 91

def helper_method(*methods)
  # Almost a duplicate from ActionController::Helpers
  methods.flatten.each do |method|
    master_helper_module.module_eval <<-end_eval
      def #{method}(*args, &block)                    # def current_user(*args, &block)
        _test_case.send(%(#{method}), *args, &block)  #   test_case.send(%(current_user), *args, &block)
      end                                             # end
    end_eval
  end
end

.tests(helper_class) ⇒ Object



73
74
75
# File 'lib/action_view/test_case.rb', line 73

def tests(helper_class)
  self.helper_class = helper_class
end

Instance Method Details

#protect_against_forgery?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/action_view/test_case.rb', line 68

def protect_against_forgery?
  false
end

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



63
64
65
66
# File 'lib/action_view/test_case.rb', line 63

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

#setup_with_controllerObject



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

def setup_with_controller
  @controller = TestController.new
  @output_buffer = ''
  @rendered = ''

  self.class.send(:include_helper_modules!)
  make_test_case_available_to_view!
end