Class: RuboCop::Cop::Vicenzo::RSpec::DerivedPremises
- Inherits:
-
RSpec::Base
- Object
- RSpec::Base
- RuboCop::Cop::Vicenzo::RSpec::DerivedPremises
- Includes:
- PremiseTracking
- Defined in:
- lib/rubocop/cop/vicenzo/rspec/derived_premises.rb
Overview
Do not derive a premise from another premise.
let(:params) { base_params.merge(age: 10) } does not mutate anything, but it splits a single premise
across two definitions: to know what params holds in a context you have to read another let — usually
one that exists only to be modified. Declare the complete value in the context that needs it.
Only premise definitions (let, let_it_be, subject) are inspected, and only when the copy starts from
another premise: deriving from a factory or from a literal is untouched.
Constant Summary collapse
- MSG =
'Do not derive the premise `%<name>s` from `%<source>s`. ' \ 'Declare the complete value in the context that needs it.'
- DERIVING_METHODS =
%i[merge deep_merge reverse_merge dup clone except slice].freeze
Constants included from PremiseTracking
Instance Method Summary collapse
- #on_block(node) ⇒ Object (also: #on_numblock)
Methods included from PremiseTracking
#premise_name, #root_receiver_name
Instance Method Details
#on_block(node) ⇒ Object Also known as: on_numblock
46 47 48 49 50 |
# File 'lib/rubocop/cop/vicenzo/rspec/derived_premises.rb', line 46 def on_block(node) return unless example_group?(node) && outermost_example_group?(node) walk_example_group(node, all_premises(node)) end |