Class: RuboCop::Cop::RSpec::LeadingSubject
- Extended by:
- AutoCorrector
- Includes:
- InsideExampleGroup
- Defined in:
- lib/rubocop/cop/rspec/leading_subject.rb
Overview
Enforce that subject is the first definition in the test.
Constant Summary collapse
- MSG =
'Declare `subject` above any other `%<offending>s` declarations.'
Instance Method Summary collapse
-
#on_block(node) ⇒ Object
rubocop:disable InternalAffairs/NumblockHandler.
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#on_block(node) ⇒ Object
rubocop:disable InternalAffairs/NumblockHandler
40 41 42 43 44 45 |
# File 'lib/rubocop/cop/rspec/leading_subject.rb', line 40 def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler return unless subject?(node) return unless inside_example_group?(node) check_previous_nodes(node) end |