Class: RuboCop::Cop::Captive::RSpec::NoDbInUnitSpecs
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Captive::RSpec::NoDbInUnitSpecs
- Defined in:
- lib/rubocop/cop/captive/rspec/no_db_in_unit_specs.rb
Overview
Do not create database records in unit tests.
Use build, instance_double, or stubs instead.
Constant Summary collapse
- MSG =
"Do not hit the database in unit tests. " \ "Use `instance_double` or `Model.new` instead. " \ "If testing a scope, move to spec/integration."
- DEFAULT_ALLOWED_PATHS =
%w[ spec/requests spec/system spec/features spec/integration spec/factories spec/services spec/jobs spec/support ].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rubocop/cop/captive/rspec/no_db_in_unit_specs.rb', line 36 def on_send(node) return unless unit_spec? return unless db_creation?(node) add_offense(node) end |