Class: RuboCop::Cop::RSpec::ChewyStrategy
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::RSpec::ChewyStrategy
- Defined in:
- lib/rubocop/cop/rspec/chewy_strategy.rb
Overview
Prevent to change the Chewy strategy in tests. Setting the strategy to atomic may try to import unnecessary data for the test which result to a slower test suite.
Constant Summary collapse
- MSG =
'Do not use Chewy.strategy in tests. Import data explicitly instead.'- RESTRICT_ON_SEND =
i[strategy].freeze
Instance Method Summary collapse
- #chewy_strategy?(node) ⇒ Object
- #on_send(node) ⇒ Object (also: #on_csend)
Instance Method Details
#chewy_strategy?(node) ⇒ Object
23 24 25 |
# File 'lib/rubocop/cop/rspec/chewy_strategy.rb', line 23 def_node_matcher :chewy_strategy?, "(send (const nil? :Chewy) :strategy ...)\n" |
#on_send(node) ⇒ Object Also known as: on_csend
27 28 29 30 31 |
# File 'lib/rubocop/cop/rspec/chewy_strategy.rb', line 27 def on_send(node) return unless chewy_strategy?(node) add_offense(node) end |