Module: ActionController::TestCase::Behavior::ClassMethods
- Defined in:
- 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
321 322 323 324 325 326 327 |
# File 'lib/action_controller/test_case.rb', line 321 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
316 317 318 319 |
# File 'lib/action_controller/test_case.rb', line 316 def controller_class=(new_class) prepare_controller_class(new_class) if new_class write_inheritable_attribute(:controller_class, new_class) end |
#determine_default_controller_class(name) ⇒ Object
329 330 331 332 333 |
# File 'lib/action_controller/test_case.rb', line 329 def determine_default_controller_class(name) name.sub(/Test$/, '').constantize rescue NameError nil end |
#prepare_controller_class(new_class) ⇒ Object
335 336 337 |
# File 'lib/action_controller/test_case.rb', line 335 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
.
312 313 314 |
# File 'lib/action_controller/test_case.rb', line 312 def tests(controller_class) self.controller_class = controller_class end |