Class: RuboCop::Cop::RSpec::SubjectDeclaration
- Defined in:
- lib/rubocop/cop/rspec/subject_declaration.rb
Overview
Ensure that subject is defined using subject helper.
Constant Summary collapse
- MSG_LET =
'Use subject explicitly rather than using let'
- MSG_REDUNDANT =
'Ambiguous declaration of subject'
Instance Method Summary collapse
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language::NodePattern
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#offensive_subject_declaration?(node) ⇒ Object
28 29 30 |
# File 'lib/rubocop/cop/rspec/subject_declaration.rb', line 28 def_node_matcher :offensive_subject_declaration?, <<~PATTERN (send nil? ${#Subjects.all #Helpers.all} {(sym :subject) (str "subject")} ...) PATTERN |
#on_send(node) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/rubocop/cop/rspec/subject_declaration.rb', line 32 def on_send(node) offense = offensive_subject_declaration?(node) return unless offense add_offense(node, message: (offense)) end |