Class: RuboCop::Cop::Ezcater::RspecRequireFeatureFlagMock
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Ezcater::RspecRequireFeatureFlagMock
- Defined in:
- lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb
Overview
Enforce use of ‘mock_feature_flag` helper instead of mocking `FeatureFlag.is_active?` directly.
Constant Summary collapse
- MSG =
"Use the `mock_feature_flag` helper instead of mocking `allow(FeatureFlag)`"
Instance Method Summary collapse
Instance Method Details
#on_const(node) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb', line 25 def on_const(node) return unless feature_flag_const?(node) # Walk to send node where method = :allow match_node = node match_node = match_node.parent while not_allow_send_node?(match_node.parent) match_node = match_node.parent # Validate send node, method = :allow; could have never been found return unless allow_send_node?(match_node) # Finish tree navigation to full line for highlighting match_node = match_node.parent while match_node.parent add_offense(match_node, location: :expression) end |