Class: ActionController::TestCase
- Inherits:
-
ActiveSupport::TestCase
- Object
- ActiveSupport::TestCase
- ActionController::TestCase
show all
- Defined in:
- lib/action_controller/test_case.rb
Defined Under Namespace
Modules: RaiseActionExceptions
Constant Summary
collapse
- @@controller_class =
nil
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.controller_class ⇒ Object
53
54
55
56
57
58
59
|
# File 'lib/action_controller/test_case.rb', line 53
def controller_class
if current_controller_class = read_inheritable_attribute(:controller_class)
current_controller_class
else
self.controller_class = determine_default_controller_class(name)
end
end
|
.controller_class=(new_class) ⇒ Object
48
49
50
51
|
# File 'lib/action_controller/test_case.rb', line 48
def controller_class=(new_class)
prepare_controller_class(new_class)
write_inheritable_attribute(:controller_class, new_class)
end
|
.determine_default_controller_class(name) ⇒ Object
61
62
63
64
65
|
# File 'lib/action_controller/test_case.rb', line 61
def determine_default_controller_class(name)
name.sub(/Test$/, '').constantize
rescue NameError
raise NonInferrableControllerError.new(name)
end
|
.prepare_controller_class(new_class) ⇒ Object
67
68
69
|
# File 'lib/action_controller/test_case.rb', line 67
def prepare_controller_class(new_class)
new_class.send :include, RaiseActionExceptions
end
|
.tests(controller_class) ⇒ Object
44
45
46
|
# File 'lib/action_controller/test_case.rb', line 44
def tests(controller_class)
self.controller_class = controller_class
end
|
Instance Method Details
#rescue_action_in_public! ⇒ Object
Cause the action to be rescued according to the regular rules for rescue_action when the visitor is not local
79
80
81
|
# File 'lib/action_controller/test_case.rb', line 79
def rescue_action_in_public!
@request.remote_addr = '208.77.188.166' end
|
#setup_controller_request_and_response ⇒ Object
72
73
74
75
76
|
# File 'lib/action_controller/test_case.rb', line 72
def setup_controller_request_and_response
@controller = self.class.controller_class.new
@controller.request = @request = TestRequest.new
@response = TestResponse.new
end
|