1 require 'active_support/test_case'
5 alias_method
:initialize_without_template_tracking, :initialize
7 @_rendered = { :template => nil, :partials => Hash
.new(0) }
8 initialize_without_template_tracking(*args
)
13 alias_method
:render_without_template_tracking, :render
14 def render(view
, local_assigns
= {})
15 if respond_to
?(:path) && !is_a
?(InlineTemplate
)
16 rendered
= view
.instance_variable_get(:@_rendered)
17 rendered
[:partials][self] += 1 if is_a
?(RenderablePartial
)
18 rendered
[:template] ||= self
20 render_without_template_tracking(view
, local_assigns
)
24 class TestCase
< ActiveSupport
::TestCase
25 include ActionController
::TestCase::Assertions
26 include ActionController
::TestProcess
28 class_inheritable_accessor
:helper_class
32 def tests(helper_class
)
33 self.helper_class
= helper_class
37 if current_helper_class
= read_inheritable_attribute(:helper_class)
40 self.helper_class
= determine_default_helper_class(name
)
44 def determine_default_helper_class(name
)
45 name
.sub(/Test$/, '').constantize
51 include ActionView
::Helpers
52 include ActionController
::PolymorphicRoutes
53 include ActionController
::RecordIdentifier
55 setup
:setup_with_helper_class
57 def setup_with_helper_class
58 if helper_class
&& !self.class.ancestors
.include?(helper_class
)
59 self.class.send(:include, helper_class
)
62 self.output_buffer
= ''
65 class TestController
< ActionController
::Base
66 attr_accessor
:request, :response, :params
69 @request = ActionController
::TestRequest.new
70 @response = ActionController
::TestResponse.new
73 send(:initialize_current_url)
78 attr_accessor
:output_buffer
81 def method_missing(selector
, *args
)
82 controller
= TestController
.new
83 return controller
.__send__(selector
, *args
) if ActionController
::Routing::Routes.named_routes
.helpers
.include?(selector
)