Class: RuboCop::Cop::Betterment::SpecHelperRequiredOutsideSpecDir

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/betterment/spec_helper_required_outside_spec_dir.rb

Overview

If a file requires spec_helper or rails_helper, make sure it is located in a spec/ directory.

Examples:

# bad
app/models/whatever_spec.rb
require 'rails_helper'

# good
spec/models/my_class_spec.rb
require 'rails_helper'

Constant Summary collapse

MSG =
'Spec helper required outside of a spec/ directory.'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



25
26
27
# File 'lib/rubocop/cop/betterment/spec_helper_required_outside_spec_dir.rb', line 25

def on_send(node)
  add_offense(node) if requires_spec_helper?(node) && !spec_directory?
end