1 require 'active_support/test_case'
4 class TestCase
< ActiveSupport
::TestCase
5 class_inheritable_accessor
:helper_class
9 def tests(helper_class
)
10 self.helper_class
= helper_class
14 if current_helper_class
= read_inheritable_attribute(:helper_class)
17 self.helper_class
= determine_default_helper_class(name
)
21 def determine_default_helper_class(name
)
22 name
.sub(/Test$/, '').constantize
28 include ActionView
::Helpers
29 include ActionController
::PolymorphicRoutes
30 include ActionController
::RecordIdentifier
32 setup
:setup_with_helper_class
34 def setup_with_helper_class
35 if helper_class
&& !self.class.ancestors
.include?(helper_class
)
36 self.class.send(:include, helper_class
)
39 self.output_buffer
= ''
42 class TestController
< ActionController
::Base
43 attr_accessor
:request, :response
46 @request = ActionController
::TestRequest.new
47 @response = ActionController
::TestResponse.new
52 attr_accessor
:output_buffer
55 def method_missing(selector
, *args
)
56 controller
= TestController
.new
57 return controller
.__send__(selector
, *args
) if ActionController
::Routing::Routes.named_routes
.helpers
.include?(selector
)