Class: RuboCop::Cop::Rails::ActionControllerTestCase
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::ActionControllerTestCase
- Extended by:
- AutoCorrector, TargetRailsVersion
- Defined in:
- lib/rubocop/cop/rails/action_controller_test_case.rb
Overview
Using ‘ActionController::TestCase` is discouraged and should be replaced by `ActionDispatch::IntegrationTest`. Controller tests are too close to the internals of a controller whereas integration tests mimic the browser/user.
Constant Summary collapse
- MSG =
'Use `ActionDispatch::IntegrationTest` instead.'
Constants included from TargetRailsVersion
TargetRailsVersion::TARGET_GEM_NAME, TargetRailsVersion::USES_REQUIRES_GEM_API
Instance Method Summary collapse
Methods included from TargetRailsVersion
minimum_target_rails_version, support_target_rails_version?
Instance Method Details
#on_class(node) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/rubocop/cop/rails/action_controller_test_case.rb', line 37 def on_class(node) return unless action_controller_test_case?(node) add_offense(node.parent_class) do |corrector| corrector.replace(node.parent_class, 'ActionDispatch::IntegrationTest') end end |