module ActionView::TestCase::Behavior
Constants
- INTERNAL_IVARS
Attributes
Public Instance Methods
Source
# File lib/action_view/test_case.rb, line 136 def _routes @controller._routes if @controller.respond_to?(:_routes) end
Source
# File lib/action_view/test_case.rb, line 175 def _test_case controller._test_case end
Source
# File lib/action_view/test_case.rb, line 122 def config @controller.config if @controller.respond_to?(:config) end
Source
# File lib/action_view/test_case.rb, line 171 def protect_against_forgery? false end
Source
# File lib/action_view/test_case.rb, line 126 def render(options = {}, local_assigns = {}, &block) view.assign(view_assigns) @rendered << output = view.render(options, local_assigns, &block) output end
Source
# File lib/action_view/test_case.rb, line 132 def rendered_views @_rendered_views ||= RenderedViewsCollection.new end
Source
# File 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 # empty string ensures buffer has UTF-8 encoding as # new without arguments returns ASCII-8BIT encoded buffer like String#new @output_buffer = ActiveSupport::SafeBuffer.new "" @rendered = +"" test_case_instance = self controller_class.define_method(:_test_case) { test_case_instance } end
Private Instance Methods
Source
# File lib/action_view/test_case.rb, line 251 def _user_defined_ivars instance_variables - INTERNAL_IVARS end
Source
# File lib/action_view/test_case.rb, line 183 def document_root_element Nokogiri::HTML::Document.parse(@rendered.blank? ? @output_buffer : @rendered).root end
Need to experiment if this priority is the best one: rendered => output_buffer
Source
# File lib/action_view/test_case.rb, line 265 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
Calls superclass method
Source
# File lib/action_view/test_case.rb, line 281 def respond_to_missing?(name, include_private = false) begin routes = defined?(@controller) && @controller.respond_to?(:_routes) && @controller._routes rescue # Don't call routes, if there is an error on _routes call end routes && (routes.named_routes.route_defined?(name) || routes.mounted_helpers.method_defined?(name)) end
Source
# File lib/action_view/test_case.rb, line 207 def view @view ||= begin view = @controller.view_context view.singleton_class.include(_helpers) view.extend(Locals) view.rendered_views = rendered_views view.output_buffer = output_buffer view end end
The instance of ActionView::Base
that is used by render
.
Also aliased as: _view
Source
# File lib/action_view/test_case.rb, line 259 def view_assigns Hash[_user_defined_ivars.map do |ivar| [ivar[1..-1].to_sym, instance_variable_get(ivar)] end] end
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. This is generally intended for internal use and extension frameworks.