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
-
#tests(controller_class) ⇒ Object
Sets the controller class name.
Instance Method Details
#controller_class ⇒ Object
376 377 378 379 380 381 382 |
# File 'actionpack/lib/action_controller/test_case.rb', line 376 def controller_class if current_controller_class = _controller_class current_controller_class else self.controller_class = determine_default_controller_class(name) end end |
#controller_class=(new_class) ⇒ Object
372 373 374 |
# File 'actionpack/lib/action_controller/test_case.rb', line 372 def controller_class=(new_class) self._controller_class = new_class end |
#determine_default_controller_class(name) ⇒ Object
384 385 386 387 388 |
# File 'actionpack/lib/action_controller/test_case.rb', line 384 def determine_default_controller_class(name) determine_constant_from_test_name(name) do |constant| Class === constant && constant < ActionController::Metal end end |
#tests(controller_class) ⇒ Object
Sets the controller class name. Useful if the name can’t be inferred from test class. Normalizes controller_class
before using.
tests WidgetController
tests :widget
tests 'widget'
361 362 363 364 365 366 367 368 369 370 |
# File 'actionpack/lib/action_controller/test_case.rb', line 361 def tests(controller_class) case controller_class when String, Symbol self.controller_class = "#{controller_class.to_s.camelize}Controller".constantize when Class self.controller_class = controller_class else raise ArgumentError, "controller class must be a String, Symbol, or Class" end end |