Class: RuboCop::Cop::RSpec::LeadingSubject
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::RSpec::LeadingSubject
- Includes:
- RSpec::Language, RSpec::SpecOnly
- Defined in:
- lib/rubocop/cop/rspec/leading_subject.rb
Overview
Checks for ‘subject` definitions that come after `let` definitions.
Constant Summary collapse
- MSG =
'Declare `subject` above any other `let` declarations'.freeze
Constants included from RSpec::SpecOnly
RSpec::SpecOnly::DEFAULT_CONFIGURATION
Constants included from RSpec::Language
Instance Method Summary collapse
Methods included from RSpec::SpecOnly
Instance Method Details
#on_block(node) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rubocop/cop/rspec/leading_subject.rb', line 36 def on_block(node) return unless subject?(node) && !in_spec_block?(node) node.parent.each_child_node do |sibling| break if sibling.equal?(node) if sibling.method_name.equal?(:let) break add_offense(node, :expression) end end end |