123456789_123456789_123456789_123456789_123456789_

Module: ActionController::TestCase::Behavior::ClassMethods

Relationships & Source Files
Defined in: actionpack/lib/action_controller/test_case.rb

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#controller_class (rw)

[ GitHub ]

  
# File 'actionpack/lib/action_controller/test_case.rb', line 484

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) (rw)

[ GitHub ]

  
# File 'actionpack/lib/action_controller/test_case.rb', line 480

def controller_class=(new_class)
  self._controller_class = new_class
end

Instance Method Details

#determine_default_controller_class(name)

[ GitHub ]

  
# File 'actionpack/lib/action_controller/test_case.rb', line 492

def determine_default_controller_class(name)
  determine_constant_from_test_name(name) do |constant|
    Class === constant && constant < ActionController::Metal
  end
end

#tests(controller_class)

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'
[ GitHub ]

  
# File 'actionpack/lib/action_controller/test_case.rb', line 469

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