Module: ActionController::TestCase::Behavior::ClassMethods
- Defined in:
- actionpack/lib/action_controller/test_case.rb
Instance Method Summary collapse
- #controller_class ⇒ Object
- #controller_class=(new_class) ⇒ Object
- #determine_default_controller_class(name) ⇒ Object
- #prepare_controller_class(new_class) ⇒ Object
-
#tests(controller_class) ⇒ Object
Sets the controller class name.
Instance Method Details
#controller_class ⇒ Object
343 344 345 346 347 348 349 |
# File 'actionpack/lib/action_controller/test_case.rb', line 343 def controller_class if current_controller_class = self._controller_class current_controller_class else self.controller_class = determine_default_controller_class(name) end end |
#controller_class=(new_class) ⇒ Object
338 339 340 341 |
# File 'actionpack/lib/action_controller/test_case.rb', line 338 def controller_class=(new_class) prepare_controller_class(new_class) if new_class self._controller_class = new_class end |
#determine_default_controller_class(name) ⇒ Object
351 352 353 354 355 |
# File 'actionpack/lib/action_controller/test_case.rb', line 351 def determine_default_controller_class(name) name.sub(/Test$/, '').constantize rescue NameError nil end |
#prepare_controller_class(new_class) ⇒ Object
357 358 359 |
# File 'actionpack/lib/action_controller/test_case.rb', line 357 def prepare_controller_class(new_class) new_class.send :include, ActionController::TestCase::RaiseActionExceptions end |
#tests(controller_class) ⇒ Object
Sets the controller class name. Useful if the name can’t be inferred from test class. Expects controller_class
as a constant. Example: tests WidgetController
.
334 335 336 |
# File 'actionpack/lib/action_controller/test_case.rb', line 334 def tests(controller_class) self.controller_class = controller_class end |